//后台登录直接回车提交
function Control_Login_OnKey(e){
	if(window.event) // IE
	{
		keynum = e.keyCode
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which
	}
	if(keynum==13){
		Control_Login_Check(); 
	}
}
//后台登录判断文本框
function Control_Login_Check()
{
	if(document.Control_Login.SiteControl_LoginName.value=="")
	{
		alert("请填写用户名");
		document.Control_Login.SiteControl_LoginName.focus();
		return false
	}
	if(document.Control_Login.SiteControl_LoginPass.value=="")
	{
		alert("请填写密码");
		document.Control_Login.SiteControl_LoginPass.focus();
		return false
	}
	if(document.Control_Login.Login_CheckCode.value=="")
	{
		alert("请填写验证码");
		document.Control_Login.Login_CheckCode.focus();
		return false
	}
	if(document.Control_Login.Login_CheckCode.value.length<4)
	{
		alert("验证码必须为4位");
		document.Control_Login.Login_CheckCode.focus();
		return false;
	}
	var re = /^[0-9]+[0-9]*$/;
	if (!re.test(document.Control_Login.Login_CheckCode.value))
	{
		alert("验证码必须是纯数字");
		document.Control_Login.Login_CheckCode.focus();
		return false;
	}
	document.Control_Login.submit();
	return true;
}
//添加菜单分类判断
function Class_Add_Check()
{
	if(document.Class_Add.Menu_Name.value=="")
	{
		alert("请填写分类名称");
		document.Class_Add.Menu_Name.focus();
		return false
	}
	if(document.Class_Add.Hand_ID.value=="")
	{
		alert("请填写手工序号");
		document.Class_Add.Hand_ID.focus();
		return false
	}
	var re = /^[1-9]+[0-9]*$/;
	if (!re.test(document.Class_Add.Hand_ID.value))
	{
		alert("手工序号必须是大于0的整数");
		document.Class_Add.Hand_ID.focus();
		return false;
	}
	return true;
}
//编辑菜单分类判断
function Class_Edit_Check()
{
	if(document.Class_Edit.Menu_Name.value=="")
	{
		alert("请填写分类名称");
		document.Class_Edit.Menu_Name.focus();
		return false
	}
	if(document.Class_Edit.Hand_ID.value=="")
	{
		alert("请填写手工序号");
		document.Class_Edit.Hand_ID.focus();
		return false
	}
	var re = /^[1-9]+[0-9]*$/;
	if (!re.test(document.Class_Edit.Hand_ID.value))
	{
		alert("手工序号必须是大于0的整数");
		document.Class_Edit.Hand_ID.focus();
		return false;
	}
	return true;
}
//添加产品、新闻等信息判断
function Info_Add_Check()
{
	var re = /^[1-9]+[0-9]*$/;
	if(document.Info_Add.ADD_MenuID.value=="0")
	{
		alert("请选择分类");
		document.Info_Add.ADD_MenuID.focus();
		return false
	}
	if (!re.test(document.Info_Add.ADD_MenuID.value))
	{
		alert("分类非法");
		document.Info_Add.ADD_MenuID.focus();
		return false;
	}
	if(document.Info_Add.Title.value=="")
	{
		alert("请填写标题名称");
		document.Info_Add.Title.focus();
		return false
	}
	if(document.Info_Add.Hand_ID.value=="")
	{
		alert("请填写手工序号");
		document.Info_Add.Hand_ID.focus();
		return false
	}
	if (!re.test(document.Info_Add.Hand_ID.value))
	{
		alert("手工序号必须是大于0的整数");
		document.Info_Add.Hand_ID.focus();
		return false;
	}
	return true;
}
//编辑产品、新闻等信息判断
function Info_Edit_Check()
{
	var re = /^[1-9]+[0-9]*$/;
	if(document.Info_Edit.ADD_MenuID.value=="0")
	{
		alert("请选择分类");
		document.Info_Edit.ADD_MenuID.focus();
		return false
	}
	if (!re.test(document.Info_Edit.ADD_MenuID.value))
	{
		alert("分类非法");
		document.Info_Edit.ADD_MenuID.focus();
		return false;
	}
	if(document.Info_Edit.Title.value=="")
	{
		alert("请填写标题名称");
		document.Info_Edit.Title.focus();
		return false
	}
	if(document.Info_Edit.Hand_ID.value=="")
	{
		alert("请填写手工序号");
		document.Info_Edit.Hand_ID.focus();
		return false
	}
	if (!re.test(document.Info_Edit.Hand_ID.value))
	{
		alert("手工序号必须是大于0的整数");
		document.Info_Edit.Hand_ID.focus();
		return false;
	} 
	return true;
}
//全选信息
function SelectAll(obj,cName)
{
	var checkboxs = document.getElementsByName(cName);
	for(var i=0;i<checkboxs.length;i++){checkboxs[i].checked = obj.checked;}
}
//信息选择删除
function del_select(pagename,Menu_ID,page)
	{
	var checkt=document.getElementsByName("SelectID");
	//alert(checkt.length);

	var temp_select="";
	for(var i=0;i<checkt.length;i++)
	{
		if(checkt[i].checked==true)
		{
			temp_select +=checkt[i].value+",";
		}
	}
	if(temp_select=="")
	{
		alert("请选择需要删除的信息");
		return false
	}
	//alert(temp_select);
	//return;


	var xmlhttp;
	try{
		xmlhttp=new XMLHttpRequest();
	}
	catch(e){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			var data=xmlhttp.responseText;
			//alert(data);//显示执行页面的数据
			//alert("删除成功");
			window.location.href=pagename+'?Menu_ID='+Menu_ID+'&page='+page;
			//window.location.reload();//FF下显示页面数据竟然有问题
			}
		else{
			 alert("操作失败");
			}
		}
	else{
		//$("span")[1].innerHTML=Hand_ID;
		}
	}
	if(confirm('确定要删除选择的信息吗？'))
	{
		xmlhttp.open("post", pagename+"?Action=Info_DelAll&page="+page+"&Menu_ID="+Menu_ID+"&ALLID="+temp_select, true);
		xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
		xmlhttp.send();
	}
	else
	{
		window.location.href=pagename+'?Menu_ID='+Menu_ID+'&page='+page;
		//window.location.reload();//FF下显示页面数据竟然有问题
	}

}
//手工序号支持回车直接修改
function EnterPress(e,pagename,sid,Menu_ID,page){
	var e = e || window.event; 
	if(e.keyCode == 13){ 
		Change_HID(pagename,sid,Menu_ID,page);
	}
}
//手工序号修改
function Change_HID(pagename,sid,Menu_ID,page){
	var re = /^[1-9]+[0-9]*$/;
	if(sid=="")
	{
		alert("ID号不能为空");
		return false
	}	
	if (!re.test(sid))
	{
		alert("ID号必须是大于0的整数");
		return false;
	}
	if(Menu_ID=="")
	{
		alert("Menu_ID号不能为空");
		return false
	}
	if (!re.test(Menu_ID))
	{
		alert("Menu_ID号必须是大于0的整数");
		return false;
	}
	if(page=="")
	{
		alert("page号不能为空");
		return false
	}
	if (!re.test(page))
	{
		alert("page号必须是大于0的整数");
		return false;
	}	
	if(document.getElementById("Hand_ID"+sid).value=="")
	{
		alert("请填写手工序号");
		document.getElementById("Hand_ID"+sid).focus();
		return false
	}
	if (!re.test(document.getElementById("Hand_ID"+sid).value))
	{
		alert("手工序号必须是大于0的整数");
		document.getElementById("Hand_ID"+sid).focus();
		return false;
	}
	var Hand_ID=document.getElementById("Hand_ID"+sid).value;
	//alert(checkt.length);
	var xmlhttp;
	try{
		xmlhttp=new XMLHttpRequest();
		}
	catch(e){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	xmlhttp.onreadystatechange=function(){
	if (xmlhttp.readyState==4){
		if (xmlhttp.status==200){
			var data=xmlhttp.responseText;
			//alert(data);//显示执行页面的数据
			alert("修改成功");
			window.location.href=pagename+'?Menu_ID='+Menu_ID+'&page='+page;
			//window.location.reload();//FF下显示页面数据竟然有问题
			}
		else{
			alert("操作失败");
			}
		}
	else{
		//$("span")[1].innerHTML=Hand_ID;
		}
	}
	xmlhttp.open("post", pagename+"?Action=Change_HID&page="+page+"&Menu_ID="+Menu_ID+"&ID="+sid+"&Hand_ID="+Hand_ID, true);
	xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	xmlhttp.send();
}
//添加后台管理员判断
function SysAdmin_Add_Check()
{
	if(document.SysAdmin_Add.SiteControl_LoginName.value=="")
	{
		alert("请填写用户名");
		document.SysAdmin_Add.SiteControl_LoginName.focus();
		return false
	}
	
	if(document.SysAdmin_Add.SiteControl_LoginPass.value=="")
	{
		alert("请填写密码");
		document.SysAdmin_Add.SiteControl_LoginPass.focus();
		return false
	}

	if(document.SysAdmin_Add.SiteControl_RealName.value=="")
	{
		alert("请填写真实姓名");
		document.SysAdmin_Add.SiteControl_RealName.focus();
		return false
	}	 
	return true;
}
//编辑后台管理员判断
function SysAdmin_Edit_Check()
{
	if(document.SysAdmin_Edit.SiteControl_LoginName.value=="")
	{
		alert("请填写用户名");
		document.SysAdmin_Edit.SiteControl_LoginName.focus();
		return false
	}
	if(document.SysAdmin_Edit.SiteControl_RealName.value=="")
	{
		alert("请填写真实姓名");
		document.SysAdmin_Edit.SiteControl_RealName.focus();
		return false
	}
	 
	return true;
}
//后台开关边侧
function preloadImg(src)
{
	var img=new Image();
	img.src=src
}
preloadImg("images/top_close.gif");

var displayBar=true;
function switchBar(obj)
{
	if (displayBar)
	{
		window.parent.document.getElementById("frame").cols="0,*";
		displayBar=false;
		obj.src="images/top_open.gif";
		obj.title="打开左边管理菜单";
	}
	else{
		window.parent.document.getElementById("frame").cols="199,*";
		displayBar=true;
		obj.src="images/top_close.gif";
		obj.title="关闭左边管理菜单";
	}
}
//后台边侧折叠菜单
function SDMenu(id) {
	if (!document.getElementById || !document.getElementsByTagName)
		return false;
	this.menu = document.getElementById(id);
	this.submenus = this.menu.getElementsByTagName("div");
	this.remember = true;
	this.speed = 3;
	this.markCurrent = true;
	this.oneSmOnly = false;
}
SDMenu.prototype.init = function() {
	var mainInstance = this;
	for (var i = 0; i < this.submenus.length; i++)
		this.submenus[i].getElementsByTagName("span")[0].onclick = function() {
			mainInstance.toggleMenu(this.parentNode);
		};
	if (this.markCurrent) {
		var links = this.menu.getElementsByTagName("a");
		for (var i = 0; i < links.length; i++)
			if (links[i].href == document.location.href) {
				links[i].className = "current";
				break;
			}
	}
	if (this.remember) {
		var regex = new RegExp("sdmenu_" + encodeURIComponent(this.menu.id) + "=([01]+)");
		var match = regex.exec(document.cookie);
		if (match) {
			var states = match[1].split("");
			for (var i = 0; i < states.length; i++)
				this.submenus[i].className = (states[i] == 0 ? "collapsed" : "");
		}
	}
};
SDMenu.prototype.toggleMenu = function(submenu) {
	if (submenu.className == "collapsed")
		this.expandMenu(submenu);
	else
		this.collapseMenu(submenu);
};
SDMenu.prototype.expandMenu = function(submenu) {
	var fullHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var links = submenu.getElementsByTagName("a");
	for (var i = 0; i < links.length; i++)
		fullHeight += links[i].offsetHeight;
	var moveBy = Math.round(this.speed * links.length);
	
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight + moveBy;
		if (newHeight < fullHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "";
			mainInstance.memorize();
		}
	}, 30);
	this.collapseOthers(submenu);
};
SDMenu.prototype.collapseMenu = function(submenu) {
	var minHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
	var moveBy = Math.round(this.speed * submenu.getElementsByTagName("a").length);
	var mainInstance = this;
	var intId = setInterval(function() {
		var curHeight = submenu.offsetHeight;
		var newHeight = curHeight - moveBy;
		if (newHeight > minHeight)
			submenu.style.height = newHeight + "px";
		else {
			clearInterval(intId);
			submenu.style.height = "";
			submenu.className = "collapsed";
			mainInstance.memorize();
		}
	}, 30);
};
SDMenu.prototype.collapseOthers = function(submenu) {
	if (this.oneSmOnly) {
		for (var i = 0; i < this.submenus.length; i++)
			if (this.submenus[i] != submenu && this.submenus[i].className != "collapsed")
				this.collapseMenu(this.submenus[i]);
	}
};
SDMenu.prototype.expandAll = function() {
	var oldOneSmOnly = this.oneSmOnly;
	this.oneSmOnly = false;
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className == "collapsed")
			this.expandMenu(this.submenus[i]);
	this.oneSmOnly = oldOneSmOnly;
};
SDMenu.prototype.collapseAll = function() {
	for (var i = 0; i < this.submenus.length; i++)
		if (this.submenus[i].className != "collapsed")
			this.collapseMenu(this.submenus[i]);
};
SDMenu.prototype.memorize = function() {
	if (this.remember) {
		var states = new Array();
		for (var i = 0; i < this.submenus.length; i++)
			states.push(this.submenus[i].className == "collapsed" ? 0 : 1);
		var d = new Date();
		d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
		document.cookie = "sdmenu_" + encodeURIComponent(this.menu.id) + "=" + states.join("") + "; expires=" + d.toGMTString() + "; path=/";
	}
};

<!-- 
//图片等比例缩小
function DrawImage(ImgD,kw,kh)
{
var image=new Image();
image.src=ImgD.src;

	if(image.height>kh)
	{
		ImgD.height=kh;
		ImgD.width=(image.width*kh)/image.height;
		if(ImgD.width>kw)
		{
			ImgD.width=kw;
			ImgD.height=(image.height*kw)/image.width;
		}
	}
	else
	{
	ImgD.width=image.width; 
	ImgD.height=image.height;
		if(ImgD.width>kw)
		{
			ImgD.width=kw;
			ImgD.height=(image.height*kw)/image.width;
		}
	}

/*if(image.height<image.width)//说明宽》高＝＝》以宽为标准
{
	if(image.width>kw)
	{
		ImgD.width=kw;
		ImgD.height=(image.height*kw)/image.width;
	}
	else
	{
		ImgD.width=image.width; 
		ImgD.height=image.height;
	}
}
else//以高为标准
{
	if(image.height>kh)
	{
		ImgD.height=kh;
		ImgD.width=(image.width*kh)/image.height;
	}
	else
	{
		ImgD.width=image.width; 
		ImgD.height=image.height;
	}
}*/
}

//显示当前时间，有秒数自动显示
function initArray(){
	for(i=0;i<initArray.arguments.length;i++)
	this[i]=initArray.arguments[i];
}
	var isnMonths=new initArray("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");
	var isnDays=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日");
	today=new Date();
	hrs=today.getHours();
	min=today.getMinutes();
	sec=today.getSeconds();
	clckh=""+((hrs>12)?hrs:hrs);
	clckm=((min<10)?"0":"")+min;
	clcks=((sec<10)?"0":"")+sec;
	clck=(hrs>=12)?"下午":"上午";
	var stnr="";
	var ns="0123456789";
	var a="";
function getFullYear(d){
	yr=d.getYear();if(yr<1000)
	yr+=1900;return yr;
};
function showTime(){
	document.write("<span id=\"timebox\"></span>");
	getTimes();
	setInterval(getTimes,450);
}
function getTimes(){
	today=new Date();
	hrs=today.getHours();
	min=today.getMinutes();
	sec=today.getSeconds();
	clckh=""+((hrs>12)?hrs:hrs);
	clckm=((min<10)?"0":"")+min;
	clcks=((sec<10)?"0":"")+sec;
	times=getFullYear(today)+"年"+isnMonths[today.getMonth()]+today.getDate()+"日 "+isnDays[today.getDay()]+" "+clckh+":"+clckm+":"+clcks+"";
	document.getElementById("timebox").innerHTML=times;
}