var old_bg="";
function inStyle(obj)
{
    old_bg=obj.style.background;
	if(!old_bg)old_bg=obj.getAttribute("bgcolor");
	obj.style.background="#E1EBF3";
}
function outStyle(obj)
{
    obj.style.background=old_bg;
}
function headInStyle(obj){
	old_bg=obj.style.background;
	if(!old_bg)old_bg=obj.getAttribute("bgcolor");
	obj.style.background="#C9DFFE";
	obj.style.border="1 solid #999999";
	obj.style.cursor = 'hand';
}
function headOutStyle(obj)
{
    obj.style.background=old_bg;
	obj.style.border="0";
	obj.style.cursor = 'hand';
}

function IconInStyle(obj){
	icon_old_bg=obj.style.background;
	if(!icon_old_bg)icon_old_bg=obj.getAttribute("bgcolor");
	//obj.style.background="#C9DFFE";
	obj.style.border="1 solid #999999";
}
function IconOutStyle(obj)
{
    //obj.style.background=old_bg;
	obj.style.border="0";
}

function selectAll(form,obj,targetName){
    for(i=0;i<form.length;i++){
	   if(form[i].name.indexOf(targetName)!=-1)  {
		   if(obj.checked) form[i].checked=true;
		   else form[i].checked=false;
	   } 
    }
}

function IfNumber(iV) //每次输入都要检查是否合法的数字
{
	var newPar=/^(-|\+)?\d+$/;
	aa=iV+String.fromCharCode(event.keyCode)+'0';
	event.returnValue =newPar.test(aa);
}


function Trim(input){
   input = input.replace(/^ {1,}/g,"");
   input = input.replace(/ {1,}$/g,"");
   return input;
}

function IsEmail(email){
   var regx = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
   return regx.test(email);
}

function IsDomain(domain){
   var regx = /^[0-9a-z\.]+[0-9a-z\-0-9a-z]+[\.]+[0-9a-z]+[\.]{0,1}[0-9a-z]{0,3}$/;
   return regx.test(domain);
}

function IsTel(tel){
   var regx = /^[0-9]{3,4}\-[0-9]{6,8}(\-[0-9]{1,6}){0,1}$/;
   return regx.test(tel);
}

function IsFax(fax){
   var regx = /^[0-9]{3,4}\-[0-9]{6,8}$/;
   return regx.test(fax);
}

/*===================================== customer_question ===================================*/

function checkEmail(str){
   var par=/^[a-zA-Z0-9\._-]+@[a-zA-Z0-9]+[a-zA-Z0-9\.-]+$/;
   return par.test(str);
}
function checksubmit(form){
   if(form.UserName.value!=""){
	  if(form.Password.value==""){
		 alert("请输入密码");
		 form.Password.focus();
		 return false;
	  }
   }
   if(form.Contact.value==""){
	   alert("请输入联系人");
	   form.Contact.focus();
	   return false;
   }
   if(!checkEmail(form.Email.value)){
	   alert("请输入正确的E-Mail地址");
	   form.Email.focus();
	   return false;
   }
   if(form.Content.value==""){
	   alert("请输入您所遇到的问题");
	   form.Email.focus();
	   return false;
   }
}






/*======================================  user_reg =====================================*/
function change2cn(en, cninput){
	str = getSpell(en, " ");
	if(str!='') cninput.value=str;
	else cninput.value=en;
}



function Sum(form){
	if(form.Num)
	{
		var Num =parseInt(form.Num.value);
	}
	else
	{
		var Num =1;
	}
	//var Num = form.Num?parseInt(form.Num.value):1;
	form.Charge.value = Num * parseInt(form.UnitPrice.value) * parseInt(form.iYear.value);
}



window.onload = function(){
	Sum(document.forms.shop);
}


/*====================================== user_password =====================================*/
function checkpwd(form){
   if(form.OldPassword.value==""){
	   alert("请输入旧密码");
	   form.OldPassword.focus();
	   return false;
   }
   if(form.Password.value==""){
	   alert("请输入新密码");
	   form.Password.focus();
	   return false;
   }
   if(form.Password.value!=form.Password_C.value){
	   alert("新密码与确认密码不相同");
	   form.Password.focus();
	   return false;
   }
}



/*====================================== user_modify =====================================*/
function checkmodify(form){
	form.Company_GB.value=form.Company_GB.value.replace(/^ {1,}/g,"");
	form.Company_GB.value=form.Company_GB.value.replace(/ {1,}$/g,"");
	if(form.Company_GB.value==""){
	   alert("请输入单位名称(中文)");
	   form.Company_GB.focus();
	   return false;
	}
	var hasChinese=false;
	for(i=0;i<form.Company_GB.value.length;i++){
	   if(form.Company_GB.value.charCodeAt(i)>127){
		   hasChinese=true;
		   break;
	   }
	}
	if(!hasChinese){
		 alert("单位名称(中文)没有任何中文字符");
		 form.Company_GB.focus();
		 return false;
	}
	form.Company_EN.value=form.Company_EN.value.replace(/^ {1,}/g,"");
	form.Company_EN.value=form.Company_EN.value.replace(/ {1,}$/g,"");
	if(form.Company_EN.value==""){
	   alert("请输入单位名称(英文)");
	   form.Company_EN.focus();
	   return false;
	}
	for(i=0;i<form.Company_EN.value.length;i++){
	   if(form.Company_EN.value.charCodeAt(i)>127){
		 alert("单位名称(英文)请输入英文字符");
		 form.Company_EN.focus();
		 return false;
	   }
	}
	if(form.Country.value==""){
	   alert("请输入国家");
	   form.Country.focus();
	   return false;
	}
	if(/^[A-Z]{2,2}$/.test(form.Country.value)==false){
	   alert("请输入正确的国家");
	   form.Country.focus();
	   return false;
	}
	form.Province_GB.value=form.Province_GB.value.replace(/^ {1,}/g,"");
	form.Province_GB.value=form.Province_GB.value.replace(/ {1,}$/g,"");
	if(form.Province_GB.value==""){
	   alert("请输入省份");
	   form.Province_GB.focus();
	   return false;
	}
	form.City_GB.value=form.City_GB.value.replace(/^ {1,}/g,"");
	form.City_GB.value=form.City_GB.value.replace(/ {1,}$/g,"");
	if(form.City_GB.value==""){
	   alert("请输入城市");
	   form.City_GB.focus();
	   return false;
	}
	form.Addr_GB.value=form.Addr_GB.value.replace(/^ {1,}/g,"");
	form.Addr_GB.value=form.Addr_GB.value.replace(/ {1,}$/g,"");
	if(form.Addr_GB.value==""){
	   alert("请输入通讯地址(中文)");
	   form.Addr_GB.focus();
	   return false;
	}
	form.Addr_EN.value=form.Addr_EN.value.replace(/^ {1,}/g,"");
	form.Addr_EN.value=form.Addr_EN.value.replace(/ {1,}$/g,"");
	if(form.Addr_EN.value==""){
	   alert("请输入通讯地址(英文)");
	   form.Addr_EN.focus();
	   return false;
	}
	for(i=0;i<form.Addr_EN.value.length;i++){
	   if(form.Addr_EN.value.charCodeAt(i)>127){
		 alert("通讯地址(英文)请输入英文字符");
		 form.Addr_EN.focus();
		 return false;
	   }
	}
	if(/^[0-9]{6,6}$/.test(form.PostCode.value)==false){
	   alert("邮政编码只能六位数字");
	   form.PostCode.focus();
	   return false;
	}
	form.Contact_GB.value=form.Contact_GB.value.replace(/^ {1,}/g,"");
	form.Contact_GB.value=form.Contact_GB.value.replace(/ {1,}$/g,"");
	if(form.Contact_GB.value==""){
	   alert("请输入联系人姓名(中文)");
	   form.Contact_GB.focus();
	   return false;
	}
	for(i=0;i<form.Contact_GB.value.length;i++){
	   if(form.Contact_GB.value.charCodeAt(i)<=127){
		 alert("联系人姓名(中文)请输入中文字符");
		 form.Contact_GB.focus();
		 return false;
	   }
	}
	form.Contact_EN.value=form.Contact_EN.value.replace(/^ {1,}/g,"");
	form.Contact_EN.value=form.Contact_EN.value.replace(/ {1,}$/g,"");
	if(/^[A-Za-z ]{1,20}$/.test(form.Contact_EN.value)==false){
	   alert("联系人姓名(英文)请输入英文字符");
	   form.Contact_EN.focus();
	   return false;
	}
	if(/^\+{1,1}[0-9]{1,3}\.{1,1}[0-9]{1,12}-{0,}[0-9]{0,}$/.test(form.Tel.value)==false){alert("电话号码格式不正确,请重新输入!");form.Tel.focus();return(false);}
	if(/^\+{1,1}[0-9]{1,3}\.{1,1}[0-9]{1,12}-{0,}[0-9]{0,}$/.test(form.Fax.value)==false){alert("传真号码格式不正确,请重新输入!");form.Fax.focus();return(false);}
	if(form.Email.value.indexOf("@")<1||form.Email.value.indexOf(".")<1){
	   alert("请输入正确的邮件地址");
	   form.Email.focus();
	   return false;
	}
}


function changePrice_new(){
	var account = document.getElementById("accountNum");
	var select = document.getElementById("year");
	var total=document.getElementById("price");
	var realSize =document.getElementById("realsize");
	var defval = document.getElementById("defval");
	var checknum = 0;
	if(defval.value==100) checknum=10;
	else checknum =1;
	if((realSize.value)%(checknum)!=0){
		alert("不符合要求");
		return;
	}
	account.innerHTML = realSize.value/checknum;
	total.innerHTML = price*(select.value)*realSize.value;
}

function checkOrder_mohost(form){
    
	if(form.pwd.value==""||form.pwd2.value==""){
		alert("请输入您的密码");
		form.pwd.focus();
		return false;
	}
	if(form.pwd.value!=form.pwd2.value){
		alert("两次输入的密码不一致");
		form.pwd2.focus();
		return false;
	}
	if(form.pwd.value.length<6){
		alert("密码长度太短");
		form.pwd.focus();
		return false;
	}
	if(form.pwd.value.length>16){
		alert("密码长度太长");
		form.pwd.focus();
		return false;
	}
   
	return true;   
}
function cz_button(pice)
{
	$("#price").html(pice);
}
function vhost_button(form_new)
{
	$('#shop')[0].reset();
	Sum(form_new);
}