//标签切换
function showCon(ids){
	for(xm=1;xm<=3;xm++){
		document.getElementById("sitem"+xm).style.display="none";
	}
	document.getElementById(ids).style.display="block";
}

function CheckForm()
{
    if(document.Form1.Name.value=="")
    {
        alert("姓名不能为空！")
        document.Form1.Name.focus()
        return(false)
    }
    if(document.Form1.validateNum.value=="")
    {
        alert("请输入右侧的验证码！")
        document.Form1.validateNum.focus()
        return(false)
    }
    if(document.Form1.content.value=="")
    {
        alert("内容不为空！")
        document.Form1.content.focus()
        return(false)
    }
    if(document.Form1.content.value.length>300)
    { 
        document.Form1.content.focus(); 
        alert("评论内容字数超过300！"); 
        return false;
    }
}

function getCookie(Name) {
  var search = Name + "=";
  var returnvalue = "";
  if (document.cookie.length > 0) {
        var offset = document.cookie.indexOf(search);
        if (offset != -1) {      
              offset += search.length;
              var end = document.cookie.indexOf(";", offset);                        
              if (end == -1)
                    end = document.cookie.length;
              returnvalue=unescape(document.cookie.substring(offset,end));
        }
  }
  return returnvalue;
}

//动态加载
function loadTop()
{
    var username=getCookie("UserName");
    if(username != ""&&username!=null)
    {
        document.write('<span class="nav_l">IT知识与应用技巧资讯站 &nbsp;&nbsp;&nbsp;&nbsp;'+ username +',您好! &nbsp;&nbsp;<a id="A1" runat="server" href="http://www.qeqoo.com/userInfo.aspx?flag=userd" target="_parent" style="color:Blue;TEXT-DECORATION: none">会员中心</a></span>');
    }
    else 
    {
        document.write('<span class="nav_l">IT知识与应用技巧资讯站 &nbsp;&nbsp;&nbsp;&nbsp;<a id="A1" runat="server" href="http://www.qeqoo.com/login.aspx" target="_parent" style="color:Blue;TEXT-DECORATION: none">登录</a> | <a id="A2" runat="server" href="http://www.qeqoo.com/userReg.aspx" target="_parent" style="color:Blue;TEXT-DECORATION: none">注册</a> </span>');
    }
}
//运行代码
function runEx(cod1)  {
	 cod=document.getElementById(cod1)
	  var code=cod.value;
	  if (code!=""){
		  var newwin=window.open('','','');  
		  newwin.opener = null 
		  newwin.document.write(code);  
		  newwin.document.close();
	}
}
//复制代码
function doCopy2(ID) { 
	if (document.all){
		 textRange = document.getElementById(ID).createTextRange(); 
		 textRange.execCommand("Copy");
alert('复制成功');
	}
	else{
		 alert("此功能只能在IE上有效")
	}
}
//复制代码
function doCopy(obj) {
	var rng = document.body.createTextRange();
	rng.moveToElementText(obj);
	rng.scrollIntoView();
	rng.select();
	rng.execCommand("Copy");
	rng.collapse(false);
}

function doCopyUrl() 
{ 
document.getElementById("CopyUrl").value=parent.location.href; 
document.getElementById("CopyUrl").select(); 
document.execCommand("copy");
alert("网址成功复制到剪贴板！")
} 

//另存代码
function doSave(obj) {
	var winname = window.open('', '_blank', 'top=10000');
	winname.document.open('text/html', 'replace');
	winname.document.writeln(obj.value);
	winname.document.execCommand('saveas','','code.htm');
	winname.close();
} 
