//层显示
function showlayer(objname,bshow)
{
	if(bshow)
	{
		document.all[objname].style.visibility="visible";
	}
	else
	{
		document.all[objname].style.visibility="hidden";
	}
}
//注册验证
function register()
{
	if(document.all["form_email"].value=="")
	{
		alert("请输入你的email地址！");
		document.all["form_email"].focus();
		return false;
	}
	else
	{
		if(!checkValMail(document.all["form_email"].value))
		{
			alert("请输入正确的email地址！");
			document.all["form_email"].focus();
			return false;
		}
	}
	if(document.all["form_password"].value=="")
	{
		alert("请给自己设一个密码！");
		document.all["form_password"].focus();
		return false;
	}
	if(document.all["form_name"].value=="")
	{
		alert("请给自己起一个名号！");
		document.all["form_name"].focus();
		return false;
	}
}
//显示日期星期
function ShowCurrentDate() 
{
	var y=new Date();                        
							
	var gy=y.getYear();                        
							
	var dName=new Array("星期天","星期一 ","星期二","星期三","星期四","星期五","星期六");                        
							
	var mName=new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");                        
							
	document.write("<font color=\"#F36B27\">"+y.getFullYear()+"年"+mName[y.getMonth()]+y.getDate()+"日"+dName[y.getDay()]+"</font>");                                          
}
//display item
function tdClassChange(curid,iTotal,classOver,classOut)
{
	for(i=1;i<=iTotal;i++)
	{
		tdname=eval("td"+i);
		tbname=eval("tb"+i);
		if(tdname.className==classOver)
		{
			tdname.className=classOut;
			tbname.style.display="none";
		}
	}
	curtdname=eval("td"+curid);
	curtbname=eval("tb"+curid);
	curtdname.className=classOver;
	curtbname.style.display="inline";
}
//search
function searchsubmit(url,textboxname)
{
	var keyword=document.all[textboxname].value;
	location.href="http://"+location.host+url+"?kw="+keyword;
}
//生成html选择关键字
function selectkeyword()
{
	var keytype=document.all["keytype"].value;
	returnValue = window.showModalDialog("selectkeyword.asp?url_keytype="+keytype, "", "dialogWidth:720px; dialogHeight:580px; status:no; directories:yes;scrollbars:no;Resizable=no;;help:no;scroll:no ");
	if(returnValue!=undefined)
	{
		var arr=returnValue.split(',');
		document.all["keyid"].value=arr[0];
		document.all["keyword"].value=arr[1];
	}
}
function returnkeyvalue(strKey)
{
	window.returnValue=strKey;
	window.close();
}
function clearKey()
{
	document.all["keyword"].value="";
	document.all["keyid"].value="";
}
//删除提醒
function DeleteConfirm(msg)
{
    var confirmmsg=msg
    if (msg!=null) confirmmsg=msg;
	if (window.confirm(confirmmsg))
	{
		return true ;
	}
	return false;
}
//确认提醒
function Confirm(msg)
{
    var confirmmsg=msg
    if (msg!=null) confirmmsg=msg;
	if (window.confirm(confirmmsg))
	{
		return true ;
	}
	return false;
}
//创建cookie
function setCookie(name, value) {
    var today = new Date();
    var expires = new Date();
    expires.setTime(today.getTime() + 1000*60*60*24*365);
    document.cookie = name + "=" + escape(value)    + "; expires=" + expires.toGMTString();
}
//获取cookie
function getCookie(Name) {
   var search = Name + "=";
   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;
         return unescape(document.cookie.substring(offset, end));
      }
      else return "";
   }
}
//修改类别名称
function ModifyKeyWordClassName(id)
{
	returnValue = window.showModalDialog("ModifyClassName.asp?id="+id, "", "dialogWidth:220px; dialogHeight:80px; status:no; directories:yes;scrollbars:no;Resizable=no;;help:no;scroll:no ");
	if(returnValue==1)
	{
		location.href="hotkeywordclasslist.asp";
	}
}
function checkValMail(objv)
{
	var pattern = /^([a-zA-Z0-9_-])+(\.([a-zA-Z0-9_-])+)*@([a-zA-Z0-9_-])+(\.([a-zA-Z0-9_-])+)+$/;
	flag = pattern.test(objv);
	if( !flag ) 
	{
		return false;
	}
	else
	{
		return true;
	}
}
//具有在输入非数字字符不回显的效果，即对非数字字符的输入不作反应。
function numbersonly(field,event)
{
	var key,keychar;
	if(window.event){
	key = window.event.keyCode;
	}
	else if (event){
	key = event.which;
	}
	else{
	return true
	}
	keychar = String.fromCharCode(key);
	if((key == null)||(key == 0)||(key == 8)||(key == 9)||(key == 13)||(key == 27)){
		return true;
	}
	else if(("0123456789").indexOf(keychar)>-1){
		window.status = "";
		return true;
	}
	else {
		window.status = "此处只能输入整数数字.";
		return false;
	}
}
//会员充值
function UserPayMoney(userid)
{
	returnValue = window.showModalDialog("paymoney.asp?userid="+userid, "", "dialogWidth:450px; dialogHeight:450px; status:no; directories:yes;scrollbars:no;Resizable=no;;help:no;scroll:no ");
	if(returnValue==1)
	{
		location.href="userlist.asp";
	}
}
//公用新建窗口
function addnew(addurl,locationurl,iwidth,iheight)
{
	returnValue = window.showModalDialog(addurl, "", "dialogWidth:"+iwidth+"px; dialogHeight:"+iheight+"px; status:no; directories:yes;scrollbars:no;Resizable=no;;help:no;scroll:no ");
	if(returnValue==1)
	{
		location.href=locationurl;
	}
}
function tdClassOnclick(curid,iTotal,classOver,classOut)
{
	for(i=1;i<=iTotal;i++)
	{
		tdname=eval("td"+i);
		tbname=eval("tb"+i);
		if(tdname.className==classOver)
		{
			tdname.className=classOut;
			tbname.style.display="none";
		}
	}
	curtdname=eval("td"+curid);
	curtbname=eval("tb"+curid);
	curtdname.className=classOver;
	curtbname.style.display="inline";
}