// JavaScript Document
var prox;
var proy;
var proxc;
var proyc;
var IsLogin=false;
var OrderNo="";

function show(id,Height,width)
{/*--打开--*/
	try{
	clearInterval(prox);
	clearInterval(proy);
	clearInterval(proxc);
	clearInterval(proyc);
	var o = document.getElementById(id);
	o.style.display = "block";
	o.style.width = "1px";
	o.style.height = "1px"; 
	//alert(window.screen.height);
	//alert(document.documentElement.scrollTop);
	o.style.top=(window.screen.height/2)-(Height/2)+document.documentElement.scrollTop-100+"px";
	o.style.left=(document.body.clientWidth /2)+(document.body.clientWidth-981)/2-(width /2)+"px";
	prox = setInterval(function(){openx(o,width,Height)},10);
	}catch(e){}
}

function openx(o,x,Height){/*--打开x--*/
var cx = parseInt(o.style.width);
if(cx < x)
{
o.style.width = (cx + Math.ceil((x-cx)/5)) +"px";
}
else
{
clearInterval(prox);
proy = setInterval(function(){openy(o,Height)},10);
}
}
function openy(o,y){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy < y)
{
o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
}
else
{
clearInterval(proy);
}
}
function closeed(id){/*--关闭--*/
clearInterval(prox);
clearInterval(proy);
clearInterval(proxc);
clearInterval(proyc);
var o = document.getElementById(id);
if(o.style.display == "block")
{
proyc = setInterval(function(){closey(o)},10);
}
}
function closey(o){/*--打开y--*/
var cy = parseInt(o.style.height);
if(cy > 0)
{
o.style.height = (cy - Math.ceil(cy/5)) +"px";
}
else
{
clearInterval(proyc);
proxc = setInterval(function(){closex(o)},10);
}
}
function closex(o){/*--打开x--*/
var cx = parseInt(o.style.width);
if(cx > 0)
{
o.style.width = (cx - Math.ceil(cx/5)) +"px";
}
else
{
clearInterval(proxc);
o.style.display = "none";
}
}

/*-------------------------鼠标拖动---------------------
	var od = document.getElementById("fd");
	var dx,dy,mx,my,mouseD;
	var odrag;
	var isIE = document.all ? true : false;
	document.onmousedown = function(e){
	var e = e ? e : event;
	if(e.button == (document.all ? 1 : 0))
	{
	mouseD = true;
	}
	}
	document.onmouseup = function(){
	mouseD = false;
	odrag = "";
	if(isIE)
	{
	od.releaseCapture();
	od.filters.alpha.opacity = 100;
	}
	else
	{
	window.releaseEvents(od.MOUSEMOVE);
	od.style.opacity = 1;
	}
	}
	
	
	//function readyMove(e){
	od.onmousedown = function(e){
	odrag = this;
	var e = e ? e : event;
	if(e.button == (document.all ? 1 : 0))
	{
	mx = e.clientX;
	my = e.clientY;
	od.style.left = od.offsetLeft + "px";
	od.style.top = od.offsetTop + "px";
	if(isIE)
	{
	od.setCapture();
	od.filters.alpha.opacity = 50;
	}
	else
	{
	window.captureEvents(Event.MOUSEMOVE);
	od.style.opacity = 0.5;
	}
	
	//alert(mx);
	//alert(my);
	
	} 
	}
	document.onmousemove = function(e){
	var e = e ? e : event;
	//alert(mrx);
	//alert(e.button);
	if(mouseD==true && odrag)
	{
	var mrx = e.clientX - mx;
	var mry = e.clientY - my;
	od.style.left = parseInt(od.style.left) +mrx + "px";
	od.style.top = parseInt(od.style.top) + mry + "px";
	mx = e.clientX;
	my = e.clientY;
	
	}
	}
*/

//用户提交表单的处理
function TiJiao()
{
	var username,userpwd;
	username=document.getElementById("username");
	userpwd=document.getElementById("userpwd");
	if((username.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写登陆帐户！");	
		username.focus();
		return false;
	}
	else
	{
		if((username.value).length < 6 || (username.value).length > 50)
		{
			alert("请按标准填写帐户信息！");	
			username.select();
			return false;
		}
	}
	
	if((userpwd.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写登陆密码！");	
		userpwd.focus();
		return false;
	}
	else
	{
		if((userpwd.value).length < 6 || (userpwd.value).length > 50)
		{
			alert("请按标准填写登陆密码！");	
			userpwd.select();
			return false;
		}
	}
	Login(username.value,userpwd.value);
	return true;
}
 
function Login(name,pwd)
{
	var xmlhttp=new createxmlhttp();
	var QueryString="Name="+escape(name)+"&pwd="+escape(pwd);
	xmlhttp.onreadystatechange = function(){Event_Login(xmlhttp);};
	xmlhttp.open("POST","../Ajax/Ajlogin.asp",true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send(QueryString);
}

function Event_Login(xmlhttp)
{
	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			var text=xmlhttp.responseText;
			text=text.slice(text.indexOf("$")+1,text.lastIndexOf("$"));
			if(text.indexOf("OK")>-1)
			{
				IsLogin=true;
				alert("恭喜您登陆成功！");
				closeed("fd");
				CloseZheZhao("ZheZhao");
				window.location.href=window.location.href;
				try{
					document.getElementById("userlogin").innerHTML="<a href='Order.asp'>"+(text.split("|"))[1]+"</a>";
					document.getElementById("userreg").innerHTML=(text.split("|"))[2];
					}catch(e){}
			}
			else
			{
				IsLogin=false;	
			}
			
			if(text.indexOf("Error")>-1)
			{
				alert("数据出错，登陆失败！");	
				document.getElementById("username").select();
			}
			
			if(text.indexOf("Failure")>-1)
			{
				alert("用户名或密码出错，登陆失败，请重新填写！");	
				document.getElementById("username").select();
			}
		}
	}
}


//用户提交表单的处理
function TiJiaoEn()
{
	var username,userpwd;
	username=document.getElementById("username");
	userpwd=document.getElementById("userpwd");
	if((username.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("Please fill in the login account！");	
		username.focus();
		return false;
	}
	else
	{
		if((username.value).length < 6 || (username.value).length > 50)
		{
			alert("Please fill out the account information in accordance with the standard！");	
			username.select();
			return false;
		}
	}
	
	if((userpwd.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("Please fill in password！");	
		userpwd.focus();
		return false;
	}
	else
	{
		if((userpwd.value).length < 6 || (userpwd.value).length > 50)
		{
			alert("Please fill out the landing in accordance with the standard password！");	
			userpwd.select();
			return false;
		}
	}
	LoginEn(username.value,userpwd.value);
	return true;
}
 
function LoginEn(name,pwd)
{
	var xmlhttp=new createxmlhttp();
	var QueryString="Name="+escape(name)+"&pwd="+escape(pwd);
	xmlhttp.onreadystatechange = function(){Event_LoginEn(xmlhttp);};
	xmlhttp.open("POST","../Ajax/Ajlogin.asp",true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send(QueryString);
}

function Event_LoginEn(xmlhttp)
{
	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			var text=xmlhttp.responseText;
			text=text.slice(text.indexOf("$")+1,text.lastIndexOf("$"));
			if(text.indexOf("OK")>-1)
			{
				IsLogin=true;
				alert("Congratulations on the success of your landing！");
				closeed("fd");
				CloseZheZhao("ZheZhao");
				window.location.href=window.location.href;
				try{
					document.getElementById("userlogin").innerHTML="<a href='Order.asp'>"+(text.split("|"))[1]+"</a>";
					document.getElementById("userreg").innerHTML=(text.split("|"))[2];
					}catch(e){}
			}
			else
			{
				IsLogin=false;	
			}
			
			if(text.indexOf("Error")>-1)
			{
				alert("Data error, landing failure！");	
				document.getElementById("username").select();
			}
			
			if(text.indexOf("Failure")>-1)
			{
				alert("Username or password error, landing failed, please re-fill！");	
				document.getElementById("username").select();
			}
		}
	}
}



//修改用户基本信息的表单揭交验证代码
function UserCheckValue()
{
	var PassPwd,RePassPwd,UserTel,UserZipCode,UserEmail
	var UserName,MailingAddress
	PassPwd=document.getElementById("PassPwd");
	RePassPwd=document.getElementById("RePassPwd");
	UserTel=document.getElementById("UserTel");
	UserZipCode=document.getElementById("UserZipCode");
	UserEmail=document.getElementById("UserEmail");
	UserName=document.getElementById("UserName");
	MailingAddress=document.getElementById("MailingAddress");
	
	if((PassPwd.value).replace(/^\s*|\s*$/g,'')!="")
	{
		if((PassPwd.value).replace(/^\s*|\s*$/g,'') != (RePassPwd.value).replace(/^\s*|\s*$/g,''))	
		{
			alert("两次密码不一致，请重新输入！");	
			PassPwd.select();
			return false;
		}
	}
	
	if((UserTel.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写联系电话！");	
		UserTel.focus();
		return false;
	}
	else
	{
		 var pattern =/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
		  if(!pattern.exec((UserTel.value).replace(/^\s*|\s*$/g,'')))
		  {
			  alert("请填写正确的联系电话！");
			  UserTel.select();
			  return false;
		  }
	}
	
	if((UserZipCode.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写邮政编码！");	
		UserZipCode.focus();
		return false;
	}
	else
	{
		var testzipcode=/^[0-9]{6}$/;	
		if(!testzipcode.exec((UserZipCode.value).replace(/^\s*|\s*$/g,'')))
		{
			alert("请填写正确的邮政编码信息！");	
			UserZipCode.select();
			return false;
		}
	}
	
	if((UserEmail.value).replace(/^\s*|\s*$/g,'')!="")
	{
		var TestMail=/^[a-zA-Z0-9_\-]{1,}@[a-zA-Z0-9_\-]{1,}\.[a-zA-Z0-9_\-.]{1,}$/;	
		if(!TestMail.exec((UserEmail.value).replace(/^\s*|\s*$/g,'')))
		{
			alert("请填写正确的Email地址！");	
			UserEmail.select();
			return false;
		}
	}
	
	if((MailingAddress.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写邮寄地址信息！");	
		MailingAddress.focus();
		return false;
	}
	return true;
}

//文本框失去交点的事件
function TestPassPort(Objects)
{	
	if((Objects.value).replace(/^\s*|\s*$/g,'')!="")
	{
		var QueryString="PassPort="+escape(Objects.value);
		var xmlhttp=new createxmlhttp();
		xmlhttp.onreadystatechange = function(){Event_TestPassPort(xmlhttp,Objects);};
		xmlhttp.open("POST","../Ajax/TestPassPort.asp",true);
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlhttp.send(QueryString);
	}
}
function Event_TestPassPort(xmlhttp,Objects)
{
	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			var text=xmlhttp.responseText;
			text=text.slice(text.indexOf("$")+1,text.lastIndexOf("$"));
			if(text.indexOf("True")>-1)
			{
				alert("帐户名与存在，请重新输入！");	
				Objects.select();
				
			}
		}
	}
}

//用户注册信息处理程序
function EventRegLogin()
{
	var UserPort,UserPortPwd,ReUserPortPwd,RealName,Sex;
	var UserTel,UserEmail,UserAddrs,UserZipCode,RHomePage,WorkUnits,Engaged;
	var Language;
	
	UserPort=document.getElementById("UserPort");
	UserPortPwd=document.getElementById("UserPortPwd");
	ReUserPortPwd=document.getElementById("ReUserPortPwd");
	RealName=document.getElementById("RealName");
	Engaged=document.getElementById("Engaged");
	Sex=GetSexValue("RSex");
	
	if(Sex=="undefined")
	{
		Sex=0;	
	}
	
	UserTel=document.getElementById("RUserTel");
	UserEmail=document.getElementById("RUserEmail");
	UserAddrs=document.getElementById("RUserAddrs");
	UserZipCode=document.getElementById("RUserZipCode");
	RHomePage=document.getElementById("RHomePage");
	WorkUnits=document.getElementById("RWorkUnits");
	Language=document.getElementById("Language");
	
	if((UserPort.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写登陆用户名！");
		UserPort.focus();
		return false;
	}
	
	if((UserAddrs.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写通信地址信息！");	
		UserAddrs.focus();
		return false;
	}
	
	if((Engaged.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写你所重事的行业信息！");
		Engaged.focus();
		return false;
	}
	
	if((UserPortPwd.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写登陆密码！");
		UserPortPwd.focus();
		return false
	}
	
	if((ReUserPortPwd.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写确认密码!");
		ReUserPortPwd.focus();
		return false;
	}
	
	if(UserPortPwd.value!=ReUserPortPwd.value)
	{
		alert("两次密码不一致，请重新填写密码！");	
		ReUserPortPwd.select();
		return false;
	}
	
	if((RealName.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写真实姓名信息！");	
		RealName.focus();
		return false;
	}
	
	if((UserTel.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写联系电话信息！");	
		UserTel.focus();
		return false;
	}
	else
	{
		var pattern =/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
		if(!pattern.exec(UserTel.value))
		{
			alert("请填写正确的联系电话！");	
			UserTel.focus();
			return false;
		}
	}
	
	if((UserEmail.value).replace(/^\s*|\s*$/g,'')!="")
	{
		var TemEmail=/^[a-zA-Z0-9_\-]{1,}@[a-zA-Z0-9_\-]{1,}\.[a-zA-Z0-9_\-.]{1,}$/;
		if(!TemEmail.exec(UserEmail.value))
		{
			alert("请填写正确的邮件地址！");	
			UserEmail.select();
			return false;
		}
	}
	
	if((UserZipCode.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写邮政编码！");	
		UserZipCode.focus();
		return false;
	}
	else
	{
		var TestZipCode=/^[0-9]{6}$/;
		if(!TestZipCode.exec(UserZipCode.value))
		{
			alert("请填写正确的邮政编码！");	
			UserZipCode.select();
			return false;
		}
	}
	
	Send(UserPort.value,UserPortPwd.value,RealName.value,Sex,UserTel.value,UserEmail.value,UserAddrs.value,UserZipCode.value,RHomePage.value,WorkUnits.value,Language.value,Engaged.value);
	return true;
}


//用户注册信息处理程序
function EventRegLoginEn()
{
	var UserPort,UserPortPwd,ReUserPortPwd,RealName,Sex;
	var UserTel,UserEmail,UserAddrs,UserZipCode,RHomePage,WorkUnits,Engaged;
	var Language;
	
	UserPort=document.getElementById("UserPort");
	UserPortPwd=document.getElementById("UserPortPwd");
	ReUserPortPwd=document.getElementById("ReUserPortPwd");
	RealName=document.getElementById("RealName");
	Engaged=document.getElementById("Engaged");
	Sex=GetSexValue("RSex");
	
	if(Sex=="undefined")
	{
		Sex=0;	
	}
	
	UserTel=document.getElementById("RUserTel");
	UserEmail=document.getElementById("RUserEmail");
	UserAddrs=document.getElementById("RUserAddrs");
	UserZipCode=document.getElementById("RUserZipCode");
	RHomePage=document.getElementById("RHomePage");
	WorkUnits=document.getElementById("RWorkUnits");
	Language=document.getElementById("Language");
	
	if((UserPort.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("Please fill in the login UserName！");
		UserPort.focus();
		return false;
	}
	
	if((Engaged.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("Please fill in the Engaged!");	
		Engaged.focus();
		return false;
	}
	
	if((UserAddrs.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("Please fill in th UserAddrs!");	
		UserAddrs.focus();
		return false;
	}
	
	if((UserPortPwd.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("Please fill in password！");
		UserPortPwd.focus();
		return false
	}
	
	if((ReUserPortPwd.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("Please fill in the Confirm Password!");
		ReUserPortPwd.focus();
		return false;
	}
	
	if(UserPortPwd.value!=ReUserPortPwd.value)
	{
		alert("Two different password, please fill out the password！");	
		ReUserPortPwd.select();
		return false;
	}
	
	if((RealName.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("Please fill out the real name information！");	
		RealName.focus();
		return false;
	}
	
	if((UserTel.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("Please fill out the contact telephone information！");	
		UserTel.focus();
		return false;
	}
	else
	{
		var pattern =/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
		if(!pattern.exec(UserTel.value))
		{
			alert("Please fill in correct Phone！");	
			UserTel.focus();
			return false;
		}
	}
	
	if((UserEmail.value).replace(/^\s*|\s*$/g,'')!="")
	{
		var TemEmail=/^[a-zA-Z0-9_\-]{1,}@[a-zA-Z0-9_\-]{1,}\.[a-zA-Z0-9_\-.]{1,}$/;
		if(!TemEmail.exec(UserEmail.value))
		{
			alert("Please fill in the correct e-mail address！");	
			UserEmail.select();
			return false;
		}
	}
	
	if((UserZipCode.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("Please fill in the postcode！");	
		UserZipCode.focus();
		return false;
	}
	else
	{
		var TestZipCode=/^[0-9]{6}$/;
		if(!TestZipCode.exec(UserZipCode.value))
		{
			alert("Please fill in the correct postcode！");	
			UserZipCode.select();
			return false;
		}
	}
	
	SendEn(UserPort.value,UserPortPwd.value,RealName.value,Sex,UserTel.value,UserEmail.value,UserAddrs.value,UserZipCode.value,RHomePage.value,WorkUnits.value,Language.value,Engaged.value);
	return true;
}


//发送数据
function SendEn(UserPort,UserPortPwd,RealName,Sex,UserTel,UserEmail,UserAddrs,UserZipCode,RHomePage,WorkUnits,Language,Engaged)
{
	var QueryString="UserPort="+escape(UserPort)+"&UserPortPwd="+escape(UserPortPwd)+"&RealName="+escape(RealName)+"&Sex="+escape(Sex)+"&UserTel="+escape(UserTel)+"&UserEmail="+escape(UserEmail)+"&UserAddrs="+escape(UserAddrs)+"&UserZipCode="+escape(UserZipCode)+"&RHomePage="+escape(RHomePage)+"&WorkUnits="+escape(WorkUnits)+"&Language="+escape(Language)+"&Engaged="+escape(Engaged);
	var xmlhttp=new createxmlhttp();
	xmlhttp.onreadystatechange = function(){Event_SendEn(xmlhttp);};
	xmlhttp.open("POST","../Ajax/RegUser.asp",true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send(QueryString);
}
function Event_SendEn(xmlhttp)
{
	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			var text=xmlhttp.responseText;
			text=text.slice(text.indexOf("$")+1,text.lastIndexOf("$"));
			if(text.indexOf("Ok")>-1)
			{
				alert("Registered with the success in mind！");
				closeed("Reg");
				CloseZheZhao("ZheZhao");
				window.location.href=window.location.href;
			}
			else
			{
				alert("System error, the new user registration failure！");	
			}
		}
	}
}



//取用户性别的值 
function GetSexValue(ID)
{
	var Radio=document.getElementsByTagName("input");	
	for(var i=0; i<Radio.length;i++)
	{
		if(Radio[i].type=="radio")
		{	
			if(Radio[i].id==ID)
			{
				if(Radio[i].status)
				{
					return Radio[i].value;	
				}
			}
		}
	}
	
}
//发送数据
function Send(UserPort,UserPortPwd,RealName,Sex,UserTel,UserEmail,UserAddrs,UserZipCode,RHomePage,WorkUnits,Language,Engaged)
{
	var QueryString="UserPort="+escape(UserPort)+"&UserPortPwd="+escape(UserPortPwd)+"&RealName="+escape(RealName)+"&Sex="+escape(Sex)+"&UserTel="+escape(UserTel)+"&UserEmail="+escape(UserEmail)+"&UserAddrs="+escape(UserAddrs)+"&UserZipCode="+escape(UserZipCode)+"&RHomePage="+escape(RHomePage)+"&WorkUnits="+escape(WorkUnits)+"&Language="+escape(Language)+"&Engaged="+escape(Engaged);
	var xmlhttp=new createxmlhttp();
	xmlhttp.onreadystatechange = function(){Event_Send(xmlhttp);};
	xmlhttp.open("POST","../Ajax/RegUser.asp",true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send(QueryString);
}
function Event_Send(xmlhttp)
{
	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			var text=xmlhttp.responseText;
			text=text.slice(text.indexOf("$")+1,text.lastIndexOf("$"));
			if(text.indexOf("Ok")>-1)
			{
				alert("用记注册成功！");
				closeed("Reg");
				CloseZheZhao("ZheZhao");
				window.location.href=window.location.href;
			}
			else
			{
				alert("系统出错，新用户注册失败！");	
			}
		}
	}
}

//定购事件
function DingGou(ID)
{
	show('Order',430,500);
	try{
	var ShowProdInfo=document.getElementById("ShowProdInfo");
	ShowProdInfo.innerHTML=GetString(ID);
	CreateOrderNo();
	}catch(e){}
}

function CreateOrderNo() //产生一个订单号
{
	var xmlhttp=new createxmlhttp();
	xmlhttp.onreadystatechange = function(){Event_CreateOrderNo(xmlhttp);};
	xmlhttp.open("GET","Ajax/CreteOrderNo.asp?"+Math.random(),true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send(null);	
}
function Event_CreateOrderNo(xmlhttp)
{
	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			var text=xmlhttp.responseText;
			text=text.slice(text.indexOf("$")+1,text.lastIndexOf("$"));
			if(text.indexOf("Error")<0)
			{
				OrderNo=text;
			}
		}
	}
}

function GetString(ID) //获取产品的基本信息
{
	var str="";
	str=str+"<table border=0 cellpadding=0 cellspacing=0 width='95%' align='center' style='margin-top:10px;'>";
		str=str+"<tr>";
			str=str+"<td class='Order_Prod'>";
				str=str+"<strong>订购产品信息：</strong>";
			str=str+"</td>";
		str=str+"</tr>";
		str=str+"<tr>";
			str=str+"<td id='Prodinfo'>";
				str=str+GetProdInfo(ID);
			str=str+"</td>";
		str=str+"</tr>";
		str=str+"<tr>";
			str=str+"<td class='Order_Prod' style='padding-top:10px;'>";
				str=str+"<strong>个人信息：</strong>";
			str=str+"</td>";
		str=str+"</tr>";
		str=str+"<tr>";
			str=str+"<td id='UserInfo'>";
				str=str+GetUserInfo();
			str=str+"</td>";
		str=str+"</tr>";

		str=str+"<tr>"
			str=str+"<td style='padding-left:70px; padding-top:10px;'>";
				str=str+"<input type='button' name='OrderTiJiao' value='提交定单' class='button' style='margin-right:10px;' onclick='SaveOrder("+ID+");'>";
				str=str+"<input type='button' name='OrderRest' value='重 置' class='button' onclick='Reset("+ID+");'>";
			str=str+"</td>";
		str=str+"</tr>";
	str=str+"</table>";
	return str;
}

function Reset(ID)
{
	try{
	var ShowProdInfo=document.getElementById("ShowProdInfo");
	ShowProdInfo.innerHTML=GetString(ID);	
	}catch(e){}
}

function GetProdInfo(ID)
{
	var xmlhttp=new createxmlhttp();
	var QueryString="ID="+escape(ID);
	xmlhttp.onreadystatechange = function(){Event_GetProdInfo(xmlhttp);};
	xmlhttp.open("POST","Ajax/ProdInfo.asp",true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send(QueryString);
}
function Event_GetProdInfo(xmlhttp)
{
	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			var text=xmlhttp.responseText;
			text=text.slice(text.indexOf("$")+1,text.lastIndexOf("$"));
			try{
				var prod=document.getElementById("Prodinfo");
				prod.innerHTML=text;
				}catch(e){}
		}
	}
}

function GetUserInfo()
{
	var xmlhttp=new createxmlhttp();
	var QueryString="";
	xmlhttp.onreadystatechange = function(){Event_GetUserInfo(xmlhttp);};
	xmlhttp.open("POST","Ajax/UserInfo.asp",true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send(QueryString);	
}

function Event_GetUserInfo(xmlhttp)
{
	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			var text=xmlhttp.responseText;
			text=text.slice(text.indexOf("$")+1,text.lastIndexOf("$"));
			try{
				var Objects=document.getElementById("UserInfo");
				Objects.innerHTML=text;
				}catch(e){}
		}
	}
}

function SaveOrder(ID)
{
	var ProdNum,OrderDate;
	var Order_Names,Order_Sex,Order_Tele,Order_Email,Order_ZipCode,Order_WorkUnits;
	var Order_Address,Order_MailingAddress;
	
	try{
		ProdNum=document.getElementById("ProdNum");
		OrderDate=document.getElementById("OrderDate");
		
		Order_Names=document.getElementById("Order_Names");
		Order_Sex=document.getElementById("Order_Sex");
		Order_Tele=document.getElementById("Order_Tele");
		Order_Email=document.getElementById("Order_Email");
		Order_ZipCode=document.getElementById("Order_ZipCode");
		Order_WorkUnits=document.getElementById("Order_WorkUnits");
		Order_Address=document.getElementById("Order_Address");
		Order_MailingAddress=document.getElementById("Order_MailingAddress");
	}catch(e){
		alert("获取数据出错，提交失败！");
		return false;
		}
		
	if((ProdNum.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写订购数量！");	
		ProdNum.focus();
		return false;
	}
	else
	{
		if((ProdNum.value).search("^-?\\d+$")!=0)
		{
			alert("订购数量请填写整数！");	
			ProdNum.select();
			return false;
		}
	}
	
	if((OrderDate.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写订购日期！");	
		OrderDate.focus();
		return false;
	}
	else
	{
		//var patrn=/^((\d{2}(([02468][048])|([13579][26]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|([1-2][0-9])))))|(\d{2}(([02468][1235679])|([13579][01345789]))[\-\/\s]?((((0?[13578])|(1[02]))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\-\/\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\-\/\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\s(((0?[0-9])|([1-2][0-3]))\:([0-5]?[0-9])((\s)|(\:([0-5]?[0-9])))))?$/;	
		var patrn=/^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/;

		if(!patrn.exec(OrderDate.value))
		{
			alert("请填写正确的定购日期！");	
			OrderDate.select();
			return false;
		}
	}
	
	if((Order_Names.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写订购人信息！");	
		Order_Names.focus();
		return false;
	}
	
	if((Order_Tele.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写订购人联系电话！");	
		Order_Tele.focus();
		return false;
	}
	else
	{
		var TestTel=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
		if(!TestTel.exec(Order_Tele.value))
		{
			alert("请填写正确联系电话！");	
			Order_Tele.select();
			return false;
		}
	}
	
	if((Order_Email.value).replace(/^\s*|\s*$/g,'')!="")
	{
		var TestEmail=/^[a-zA-Z0-9_\-]{1,}@[a-zA-Z0-9_\-]{1,}\.[a-zA-Z0-9_\-.]{1,}$/;
		if(!TestEmail.exec(Order_Email.value))
		{
			alert("请填写正确的电子邮件地址！");
			Order_Email.select();
			return false;
		}
	}
	
	if((Order_ZipCode.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写邮编信息！");	
		Order_ZipCode.focus();
		return false;
	}
	else
	{
		var TestZipCode=/^[0-9]{6}$/;
		if(!TestZipCode.exec(Order_ZipCode.value))
		{
			alert("请填写正确的邮编号码！");	
			Order_ZipCode.select();
			return false;
		}
	}
	
	if((Order_MailingAddress.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert("请填写邮寄地址！");	
		Order_MailingAddress.focus();
		return false;
	}
	
	var sex
	sex=document.getElementsByTagName("input");
	for(var i=0;i<sex.length;i++)
	{
		if(sex[i].type=="radio")
		{
			if(sex[i].name=="Order_Sex")
			{
				if(sex[i].status)
				{
				 var sexvalue=sex[i].value;
				}
			}
		}
	}
	
	SendOrderData(ID,ProdNum.value,OrderDate.value,Order_Names.value,sexvalue,Order_Tele.value,Order_Email.value,Order_ZipCode.value,Order_WorkUnits.value,Order_Address.value,Order_MailingAddress.value);
	return true;
}

function SendOrderData(ProdID,ProdNum,OrderDate,Names,Sex,Tele,Email,ZipCode,WorkUnits,Address,MailingAddress)
{
	var xmlhttp=new createxmlhttp();
	var QuerString="ProdID="+escape(ProdID)+"&OrderNo="+escape(OrderNo)+"&ProdNum="+escape(ProdNum)+"&OrderDate="+escape(OrderDate)+"&Names="+escape(Names)+"&Sex="+escape(Sex)+"&Tele="+escape(Tele)+"&Email="+escape(Email)+"&ZipCode="+escape(ZipCode)+"&WorkUnits="+escape(WorkUnits)+"&Address="+escape(Address)+"&MailingAddress="+escape(MailingAddress);
	xmlhttp.onreadystatechange = function(){Event_SendOrderData(xmlhttp);};
	xmlhttp.open("POST","Ajax/SaveOrder.asp",true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlhttp.send(QuerString);	
}

function Event_SendOrderData(xmlhttp)
{
	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			var text=xmlhttp.responseText;
			text=text.slice(text.indexOf("$")+1,text.lastIndexOf("$"));
			if(text.indexOf("existence")>-1)
			{
				alert("订单号重复！提交失败！");	
			}
			if(text.indexOf("Error")>-1)
			{
				alert("系统出错，提交失败！");	
			}
			if(text.indexOf("Ok")>-1)
			{
				alert("订单提交成功！");	
				closeed("Order");
			}
			if(text.indexOf("NotLogin")>-1)
			{
				alert("登陆超时，请重新登陆！");	
				document.getElementById("Order").style.display="none";
				show('fd',180,500);	
			}
		}
	}
}


function ShowLogin(Button,ID)
{
	if(IsLogin)
	{
		DingGou(ID);
	}
	else
	{
		show('fd',180,500);	
	}
}

//全选或反选功能代码
function SelectAll()
{
	var SelectId=document.getElementsByTagName("input");
	for(var i=0;i < SelectId.length-1;i++)
	{
		/*if(SelectId[i].type=="checkbox")
		{
			if(SelectId[i].checked==true)
			{
				SelectId[i].checked=false;	
			}
			else
			{
				SelectId[i].checked=true;
			}*/
			
			if(SelectId[i].status)
			{
				SelectId[i].status=false;
			}
			else
			{
				SelectId[i].status=true;
			}
	}
}

function Diago()
	{
		var DelId=document.getElementsByTagName("input");
		var flag=false;
		for(var i=0; i < DelId.length;i++)
		{
			if(DelId[i].type=="checkbox")
			{
				if(DelId[i].status)
				{
					flag=true;
				}
			}
		}
		
		if(! flag)
		{
			alert("对不起，你还没选择记录！");
			return false;
		}
		if(confirm("您确认是否删除所选记录？"))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
//创建遮照层
function CrateZheZhao(ID)
{	
	//判断用户是否已经登陆，如果已经登陆则提示用户已经登陆，如果要重新申请，请退出
	/*if(IsLogin)
	{
		if(confirm(Msg)==true)
		{
			window.location.href="Channels.asp?Action=OutLogin";
			return false;
		}
		return false;
	}*/
	var Div=document.createElement("div");
	Div.setAttribute("id",ID);
	Div.style.width=document.body.scrollWidth+"px";
	Div.style.height=document.body.scrollHeight+"px";
	Div.style.position="absolute";
	Div.style.top=0+"px";
	Div.style.zIndex = "100";
	Div.style.filter = "Alpha(opacity=40)";
	document.body.appendChild(Div);
}


//关闭遮照层
function CloseZheZhao(ID)
{
	try{
		var div=document.getElementById(ID);
		document.body.removeChild(div);
		document.getElementById("Category").style.display="";
		document.getElementById("KeyWord").style.display="";
	}catch(e){}
}

//跳转到指定的面页
function GotoRedirect(Url)
{
	window.location.href=Url;	
}

//创建xmlhttp对像
function createxmlhttp()
{
	var xmlHttp;
	if(window.ActiveXObject)
	{
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e)
				{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
	}
	else if(window.XMLHttpRequest)
	{
		xmlHttp=new XMLHttpRequest();
		if(xmlHttp.overrideMimeType)
		{
			xmlHttp.overrideMimeType("text/xml");	
		}
	}
	if(!xmlHttp)
	{
		alert("无法创建xmlHttp对象.");	
		return null;
	}
	return xmlHttp;
}

//检查修改用户密码
function CheckPwd(text1,text2,text3)
{
	var OldPwd,NewsPwd,NewsPwd1;
	OldPwd=document.getElementById("OldPwd");
	NewsPwd=document.getElementById("NewsPwd");
	NewsPwd1=document.getElementById("NewsPwd1");
	
	if((OldPwd.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert(text1);
		OldPwd.focus();
		return false;
	}
	
	if((NewsPwd.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert(text1);
		NewsPwd.focus();
		return false;
	}
	
	if((NewsPwd1.value).replace(/^\s*|\s*$/g,'')=="")
	{
		alert(text1);
		NewsPwd1.focus();
		return false;
	}
	
	if((NewsPwd.value).length < 6 || (NewsPwd.value).length > 30)
	{
		alert(text3);	
		NewsPwd.select();
		return false;
	}
	
	if((NewsPwd1.value).length < 6 || (NewsPwd1.value).length > 30)
	{
		alert(text3);	
		NewsPwd1.select();
		return false;
	}
	
	if(NewsPwd.value!=NewsPwd1.value)
	{
		alert(text2);	
		NewsPwd.select();
		return false;
	}
	return true;
}

//用户申请经销商
var RetFalg=true;

function ShengQing(Text,DText,Language)
{
	if(Text!="Null")
	{
		var xmlhttp=new createxmlhttp();
		var QueryString="PassPort="+escape(Text);
		xmlhttp.onreadystatechange = function(){Event_ShengQing(xmlhttp,Language);};
		xmlhttp.open("POST","../Ajax/ShengQing.asp",true);
		setTimeout("ontimeout()",50000);//
		xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlhttp.send(QueryString);	
	}
	else
	{
		alert(DText);	
	}
}

function ontimeout()
{
	if(RetFalg) 
	{
		alert("Ajax Time Out!");	
	}
}

function Event_ShengQing(xmlhttp,Language)
{
	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{
			RetFalg=false;
			var text=xmlhttp.responseText;
			text=text.slice(text.indexOf("$")+1,text.lastIndexOf("$"));
			if(text !="")
			{
				if(text.indexOf("Error")>-1)
				{
					if(Language=="Si") 
					{
						alert("数据出错，申请失败！");	
					}
					else
					{
						alert("Data error, application failure");
					}
				}
				
				if(text.indexOf("existed")>-1)
				{
					if(Language=="Si")	
					{
						alert("对不起，你已经申请，请等待处理！");	
					}
					else
					{
						alert("Sorry, you have to apply, please wait to deal with！");	
					}
				}
				
				if(text.indexOf("TongGuo")>-1)
				{
					if(Language=="Si")
					{
						alert("对不起，你已经升级！");	
					}
					else
					{
						alert("Sorry, you have to upgrade!");	
					}
				}
				
				if(text.indexOf("NotFound")>-1)
				{
					if(Language=="Si")
					{
						alert("记录未找到，申请失败！");	
					}
					else
					{
						alert("Record not found, the application failed!");
					}
				}
				
				if(text.indexOf("Ok")>-1)
				{
					if(Language=="Si")	
					{
						alert("申请成功，请等待处理！");	
					}
					else
					{
						alert("The application is successful, please wait for processing！");	
					}
				}
			}
		}
	}
}

//判断用户是否已经登陆
function TestLogin()
{
	var xmlhttp=new createxmlhttp();
	xmlhttp.onreadystatechange = function(){Event_TestLogin(xmlhttp);};
	xmlhttp.open("Get","../Ajax/TestLogin.asp?"+Math.random(),true);
	xmlhttp.send(null);	
}
//向就程序
function Event_TestLogin(xmlhttp)
{
	if(xmlhttp.readyState==4)
	{
		if(xmlhttp.status==200)
		{	
			var text=xmlhttp.responseText;
			if(text.indexOf("true")>-1)
			{
				IsLogin=true;
			}
			else
			{
				IsLogin=false;
			}
		}
	}
}