﻿// JavaScript Document
function ChangeNav(No,Sum)
{
	var Sum=Sum+1;
	for(var i=1; i< Sum; i++)
	{
		if(i==No)
		{
			document.getElementById("Nav_"+i).style.background="url(/Images/Nav_0"+i+".gif)";
			document.getElementById("Nav_"+i).style.cursor="hand";
			document.getElementById("Nav_"+i).className="Nav_On";
			document.getElementById("NavTxt_"+i).style.display="block";
		}
		else
		{
			document.getElementById("Nav_"+i).style.background="url(/Images/Nav_"+i+".gif)";
			document.getElementById("Nav_"+i).className="Nav_Off";
			document.getElementById("NavTxt_"+i).style.display="none";
		}
	}
}
function show(no)
{
	if(no!=="")
	var showtr=eval(document.getElementById("show"+no));
	{
		if(showtr.style.display!="block")
		{
			showtr.style.display="block";
		}
		else
		{
			showtr.style.display="none";
		}
	}
}
function showadd()
{
  	var l=event.clientX;//(document.body.clientWidth-AddChannel.offsetWidth)/2   
  	var t=event.clientY+15;//(document.body.clientHeight-AddChannel.offsetHeight)/2 
 	with(AddChannel.style)
	{   
  		left=l   
  		top=t   
  		display="block"   
	}   	
}
function unshowadd()
{
	AddChannel.style.display="none";
}
function startMove(objDiv)
{
	document.attachEvent("onmousemove",moveDiv);
	document.attachEvent("onmouseup",endMove);
	document.attachEvent("onselectstart",selectNo);
	document["moveDiv"] = objDiv;
	document["startX"] = event.x;
	document["startY"] = event.y;
	document["oldX"] = objDiv.getBoundingClientRect().left;
	document["oldY"] = objDiv.getBoundingClientRect().top;
}
function moveDiv()
{
	//try{
	var obj = document["moveDiv"];
	if(obj)
	{
		var l = document["oldX"];
		var t = document["oldY"];
		obj.style.position = "absolute";
		obj.style.left = l + (event.x-document["startX"]);
		obj.style.top = t + (event.y-document["startY"]);
	}
//}catch(e){endMove();}
}
function endMove()
{
	document.detachEvent("onmousemove",moveDiv);
	document.detachEvent("onmouseup",endMove);
	document.detachEvent("onselectstart",selectNo);
	document["moveDiv"] = null;
	document["startX"] = null;
	document["startY"] = null;
}
function showadds()
{
  	var l=event.clientX-120;  
  	var t=event.clientY+15;
 	with(AddChannels.style)
	{   
  		left=l   
  		top=t   
  		display="block"   
	}   	
}
function unshowadds()
{
	AddChannels.style.display="none";
}
function selectNo()
{
	return false; 
}
function CheckFormToChannel()
{
	  var must = /^[\+\-]?\d*?\d*?$/;
	  if (document.myform.CName.value=="")
	  {
			alert(" 栏目名称不能为空！ ");
			document.myform.CName.focus();
			return false;
	  }
	  if (document.myform.Values.value=="")
	  {
			alert(" 属性值不能为空！ ");
			document.myform.Values.focus();
			return false;
	  }
	  if (!must.test(document.myform.Values.value))
	  {
			alert(" 属性值只能填写数字！ ");
			document.myform.Values.focus();
			return false;
	  }
	  if (document.myform.Orders.value=="")
	  {
			alert(" 排序值不能为空！ ");
			document.myform.Orders.focus();
			return false;
	  }
	  if (!must.test(document.myform.Orders.value))
	  {
			alert(" 排序值只能填写数字！ ");
			document.myform.Orders.focus();
			return false;
	  }
	  return true;  
}
function CheckForms()
{
	  var must = /^[\+\-]?\d*?\d*?$/;
	  if (document.myforms.CName.value=="")
	  {
			alert(" 栏目名称不能为空！ ");
			document.myforms.CName.focus();
			return false;
	  }
	  if (document.myforms.Values.value=="")
	  {
			alert(" 属性值不能为空！ ");
			document.myforms.Values.focus();
			return false;
	  }
	  if (!must.test(document.myforms.Values.value))
	  {
			alert(" 属性值只能填写数字！ ");
			document.myforms.Values.focus();
			return false;
	  }
	  if (document.myforms.Orders.value=="")
	  {
			alert(" 排序值不能为空！ ");
			document.myforms.Orders.focus();
			return false;
	  }
	  if (!must.test(document.myforms.Orders.value))
	  {
			alert(" 排序值只能填写数字！ ");
			document.myforms.Orders.focus();
			return false;
	  }
	  return true;  
}
function CheckFormMagager()
{
	  if (document.myform.username.value=="")
	  {
			alert(" 管理员名称不能为空！ ");
			document.myform.username.focus();
			return false;
	  }
	  if (document.myform.password.value=="")
	  {
			alert(" 管理员密码不能为空！ ");
			document.myform.password.focus();	
			return false;
	  }
	  return true;  
}
function CheckRepass()
{
	  if (document.newpassword.newpass.value=="")
	  {
			alert(" 密码不能为空！ ");
			document.newpassword.newpass.focus();
			return false;
	  }
	  return true;  
}
function showform()
{ 
	var oDiv = document.createElement('div'); 
	oDiv.id='OverLayDiv'; 
	with(oDiv.style)
	{ 
		width = '100%'; 
		height = '100%'; 
		position = 'absolute'; 
		left = '0px'; 
		top = '0px'; 
		zIndex = 1; 
	} 
	document.body.appendChild(oDiv); 
	var l=(document.body.clientWidth-demo.offsetWidth)/2 
	var t=(document.body.clientHeight-demo.offsetHeight)/2 
	with(demo.style)
	{ 
		left=l 
		top=t 
		visibility="visible" 
		zIndex = 2; 
	} 
} 
function showrepass(uid)
{
  	var l=event.clientX-240;
  	var t=event.clientY+10;
	if(uid!=="")
	{
		document.newpassword.uid.value=eval(uid);
	}
 	with(Repass.style)
	{   
  		left=l   
  		top=t   
  		display="block"   
	}   	
}
function unshowrepass()
{
	Repass.style.display="none";
}
function Chang_ShowBox(ObjName,No,Sum)
{
	var Sum=Sum+1;
	for(var i=1; i< Sum; i++)
	{
		if(i==No)
		{
			document.getElementById(ObjName+i).src="/Images/"+ObjName+i+"_.gif";
			document.getElementById(ObjName+"_Box"+i).style.display="block";
		}
		else
		{
			document.getElementById(ObjName+i).src="/Images/"+ObjName+i+".gif";
			document.getElementById(ObjName+"_Box"+i).style.display="none";
		}
	}
}
function ToSend()
{
	if(document.myform.UserName.value=="")
	{
		alert("请填写您的名字！")
		document.myform.UserName.focus()
		return false
	}
	if(document.myform.UserMail.value.length!=0)
	{
		if (document.myform.UserMail.value.charAt(0)=="." ||        
		document.myform.UserMail.value.charAt(0)=="@"||       
		document.myform.UserMail.value.indexOf('@', 0) == -1 || 
		document.myform.UserMail.value.indexOf('.', 0) == -1 || 
		document.myform.UserMail.value.lastIndexOf("@")==document.myform.UserMail.value.length-1 || 
		document.myform.UserMail.value.lastIndexOf(".")==document.myform.UserMail.value.length-1)
		{
		    alert("电子邮件格式不正确！");
		    document.myform.UserMail.focus();
		    return false;
		}
	}
	else
	{
		alert("电子邮件不能为空！");
		document.myform.UserMail.focus();
		return false;
	}
	if(document.myform.UserTel.value=="")
	{
		alert("请填写您的联系电话！")
		document.myform.UserTel.focus()
		return false
	}
	if(document.myform.Content.value=="")
	{
		alert("请填写您的留言内容！")
		document.myform.Content.focus()
		return false
	}
	if(document.myform.randNum.value=="")
	{
		alert("请填写验证码！")
		document.myform.randNum.focus()
		return false
	}
	document.myform.submit()
}
