﻿	<!--
	
function GE(a){return document.getElementById(a);}	
	
	
function creatCookie(mycookie,cookievalue){			//建立cookie
	var today = new Date();
	var expireDay = new Date();
	var msPerDay = 30*60*1000;
	expireDay.setTime( today.getTime() + msPerDay );
	document.cookie = mycookie+"="+escape(cookievalue)+";expires=" + expireDay.toGMTString()+"; path=/";
}


	function checkUser(){
		var objv = GE("Form_username").value;
		if(objv!=""){			
			if (objv.length<=3 || objv.length>50)
			 {
				GE("userinfo").innerHTML="<br>&nbsp;&nbsp;<img src=img/err.png width=15 style=\"vertical-align:middle;\"> please enter a valid Login Name";
				GE("Form_username").select();
				return ;
			  }else{
			    var pattern = /^[0-9,a-z,A-Z,_]+$/; 
			    flag2 = pattern.test(objv);
				if(!flag2){ 
				  GE("userinfo").innerHTML="<br>&nbsp;&nbsp;<img src=img/err.png width=15 style=\"vertical-align:middle;\"> please enter a valid Login Name";
				  GE("Form_username").select();
				  return ;
				}else{
				  var ajax=new AJAXRequest;				
				  ajax.get("user/regchk.asp?ckuser="+objv,					
					function(obj) {
						if(obj.responseText=="false"){
							GE("userinfo").innerHTML="<br>&nbsp;&nbsp;<img src=img/err.png width=15 style=\"vertical-align:middle;\"> This Login name had registered."
						}else if(obj.responseText=="true"){
							GE("userinfo").innerHTML="&nbsp;&nbsp;<img src=img/suc.gif style=\"vertical-align:middle;\"> "
						}
					 }
				  );
				}
			}
		}
	}


function checkSource(sourse){
	if(sourse=="Email" || sourse=="Fax" || sourse=="Letter"){
		GE("couponSpan").style.display="inline";
		if(sourse=="Email"){
			GE("enquiSp").innerHTML="email";
		}else if (sourse=="Fax"){
			GE("enquiSp").innerHTML="Fax";
		}else if (sourse=="Letter"){
			GE("enquiSp").innerHTML="Letter";
		}
		document.reg.coupon.focus();
	}else if(sourse=="Others"){
		GE("couponSpan").style.display="inline";
		GE("enquiSp").innerHtml="email";
	}else{
		GE("couponSpan").style.display="none";
	}
}

	
	
	var ValidationPassed = true;
	
	function form_onsubmit(obj){
		if(obj.Form_username.value=="" || obj.Form_username.value.length<=3 ){
			alert("Login Name:Please enter 3-50 characters");
			ValidationPassed = false;
			obj.Form_username.focus();
			return;
		}		
		
		
		if(obj.Form_username.value.length>50){
			alert("Login Name:Should less than 50 words!\n");
			ValidationPassed = false;
			obj.Form_username.focus();
			return;
		}

		
		if(obj.Form_password1.value=="" || obj.Form_password1.value.length<6){
			alert("Password:Please enter 6-20 characters");
			ValidationPassed = false;
			obj.Form_password1.focus();
			return;
		}
		
		if(obj.Form_password1.value.length>20){
			alert("Password:Should less than 20 words or number\n");
			ValidationPassed = false;
			obj.Form_password1.focus();
			return;
		}
		
		if(obj.Form_password1.value!=obj.Form_password2.value){
			alert("Password and Re-type Password is inconsistent!\n");
			ValidationPassed = false;
			obj.Form_password2.focus();
			return;
		}
		
		
	 if(obj.Form_mail.value.length!=0){
		if (obj.Form_mail.value.charAt(0)=="." ||        
			 obj.Form_mail.value.charAt(0)=="@"||       
			 obj.Form_mail.value.indexOf('@', 0) == -1 || 
			 obj.Form_mail.value.indexOf('.', 0) == -1 || 
			 obj.Form_mail.value.lastIndexOf("@")==obj.Form_mail.value.length-1 || 
			 obj.Form_mail.value.lastIndexOf(".")==obj.Form_mail.value.length-1)
		 {
		  alert("please enter a valid e-mail address");
		  ValidationPassed = false;
		  obj.Form_mail.focus();
		  return;
		  }
	  }else{
		 alert("Please input E-Mail address!\n"); 
		 ValidationPassed = false;
		 obj.Form_mail.focus();
		 return;
	  }
		


        if  (obj.Form_FirstName.value=="")
        {
            alert("Please input you First Name!\n");
			ValidationPassed = false;
			obj.Form_FirstName.focus();
            return;
        }

        if  (obj.Form_LastName.value==""){
            alert("Please input you Last Name!\n");
			ValidationPassed = false;
			obj.Form_LastName.focus();
            return;
        }
		
        if  (obj.bir_year.value==""){
            alert("Please select the year of your birthday.\n");
			ValidationPassed = false;
			obj.bir_year.focus();
            return;
        }
		
        if  (obj.bir_month.value==""){
            alert("Please select the month of your birthday.\n");
			ValidationPassed = false;
			obj.bir_month.focus();
            return;
        }

        if  (obj.bir_day.value==""){
            alert("Please select the day of your birthday.\n");
			ValidationPassed = false;
			obj.bir_day.focus();
            return;
        }

        if  (obj.Form_street.value==""){
            alert("Please input your address.\n");
			ValidationPassed = false;
			obj.Form_street.focus();
            return;
        }

        if  (obj.Form_city.value=="" || obj.Form_city.value.length<2){
            alert("The city should be more than 2 characters!\n");
	    ValidationPassed = false;
	    obj.Form_city.focus();
            return;
        }

        if  (obj.Form_state.value=="" || obj.Form_state.value.length<2)
        {
            alert("The state should be more than 2 characters!\n");
			ValidationPassed = false;
			obj.Form_state.focus();
            return;
        }


        if  (obj.Form_country.value=="" || obj.Form_country.value.length<2)
        {
            alert("The country should be more than 2 characters!\n");
			ValidationPassed = false;
			obj.Form_country.focus();
            return;
        }
		
	if (obj.Enquiry.value.length == 0) {
	   alert("Please filling in enquiry.");
	   obj.Enquiry.focus();
	   ValidationPassed = false;
	   return;
	}
		
		
	if((obj.Enquiry.value=="Email" || obj.Enquiry.value=="Fax" || obj.Enquiry.value=="Letter") && obj.coupon.value==""){
	   alert("Please input your coupon code");
	   obj.coupon.focus();
	   ValidationPassed = false;
	   return;
	}


	if((obj.Enquiry.value=="Alibaba" || obj.Enquiry.value=="Email" || obj.Enquiry.value=="Fax" || obj.Enquiry.value=="Letter") && obj.coupon.value!=""){
		checkCoupon(obj.coupon);
		if(ValidationPassed == false){return;}		
	}

	if(obj.Enquiry.value=="Others" && obj.coupon.value!=""){
		var couponStr2=obj.coupon.value.toLowerCase();
		if(couponStr2.indexOf("ay")>0){
			checkCoupon(obj.coupon);
			if(ValidationPassed == false){return;}		
		}
	}else if(obj.Enquiry.value=="Others" && obj.coupon.value==""){
		   alert("Please filling in enquiry.");
		   ValidationPassed = false;
		   return;
	}
	
	if(obj.Form_username.value!=""){
	  if(!checkIllegal(obj.Form_username.value)){	
	  	alert("There are illegal words in your username, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_username.focus();
		return;
	  }
	}
	if(obj.Form_password1.value!=""){
	  if(!checkIllegal(obj.Form_password1.value)){	
	  	alert("There are illegal words in your password, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_password1.focus();
		return;
	  }
	}
	if(obj.Form_mail.value!=""){
	  if(!checkIllegal(obj.Form_mail.value)){	
	  	alert("There are illegal words in your email, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_mail.focus();
		return;
	  }
	}
	if(obj.Form_FirstName.value!=""){
	  if(!checkIllegal(obj.Form_FirstName.value)){	
	  	alert("There are illegal words in your firstname, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_FirstName.focus();
		return;
	  }
	}
	if(obj.Form_LastName.value!=""){
	  if(!checkIllegal(obj.Form_LastName.value)){	
	  	alert("There are illegal words in your lastname, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_LastName.focus();
		return;
	  }
	}
	if(obj.Form_street.value!=""){
	  if(!checkIllegal(obj.Form_street.value)){	
	  	alert("There are illegal words in your address, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_street.focus();
		return;
	  }
	}
	if(obj.Form_city.value!=""){
	  if(!checkIllegal(obj.Form_city.value)){	
	  	alert("There are illegal words in your city, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_city.focus();
		return;
	  }
	}
	if(obj.Form_state.value!=""){
	  if(!checkIllegal(obj.Form_state.value)){	
	  	alert("There are illegal words in your State\/Province, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_state.focus();
		return;
	  }
	}
	if(obj.Form_phone.value!=""){
	  if(!checkIllegal(obj.Form_phone.value)){	
	  	alert("There are illegal words in your Phone \/ Mobile, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_phone.focus();
		return;
	  }
	}
	if(obj.Form_skype.value!=""){
	  if(!checkIllegal(obj.Form_skype.value)){	
	  	alert("There are illegal words in your Skype, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_skype.focus();
		return;
	  }
	}
	if(obj.Form_msn.value!=""){
	  if(!checkIllegal(obj.Form_msn.value)){	
	  	alert("There are illegal words in your msn, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_msn.focus();
		return;
	  }
	}
	try{
	if(obj.coupon.value!=""){
	  if(!checkIllegal(obj.coupon.value)){	
	  	alert("There are illegal words in your Source, please adjust or change it.");
		ValidationPassed = false;
		obj.coupon.focus();
		return;
	  }
	}
	}catch(e){}
	if(obj.Oweb.value!=""){
	  if(!checkIllegal(obj.Oweb.value)){	
	  	alert("There are illegal words in your buyed websites, please adjust or change it.");
		ValidationPassed = false;
		obj.Oweb.focus();
		return;
	  }
	}
	if(obj.Form_CompanyName.value!=""){
	  if(!checkIllegal(obj.Form_CompanyName.value)){	
	  	alert("There are illegal words in your company name, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_CompanyName.focus();
		return;
	  }
	}
	if(obj.Form_CompanyWeb.value!=""){
	  if(!checkIllegal(obj.Form_CompanyWeb.value)){	
	  	alert("There are illegal words in your company web, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_CompanyWeb.focus();
		return;
	  }
	}
	if(obj.Form_Memo.value!=""){
	  if(!checkIllegal(obj.Form_Memo.value)){	
	  	alert("There are illegal words in your company memo, please adjust or change it.");
		ValidationPassed = false;
		obj.Form_Memo.focus();
		return;
	  }
	}
		
		ValidationPassed = true;
		return ValidationPassed;
	}


	function ismail(mail) 
     { 
       return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail)); 
     }


	function submitonce(theform)
	{
		form_onsubmit(theform);
		if(ValidationPassed == false)return;
		if (document.all||document.getElementById)
		{
			for (i=0;i<theform.length;i++)
			{
				var tempobj=theform.elements[i];
				if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
				tempobj.disabled=true;
			}
		}
	}
	
	function checkIllegal(galStr){
		var IllegalStr="exec |exec%20|insert|delete from|master|%20|%22|IS_SRVROLEMEMBER|char(|%31%3D|truncate|declare|drop%20table|sysobjects|sysadmin|cast(|unicode(|substring(|len(|servername|version|[dbo]|c:\|d:\|e:\|System32|extendedproc|addextendedproc|procedure|db_name(|net%20user|xp_cmdshell|xp_regwrite|administrator|0x4445434C41524520|SandBoxMode|/add|)>|)<|servername|is_member|net localgroup|/script|<iframe|alert|escape|[url|replace|CreateObject|Domain|PortNo|XMLHTTP|goldsun|SERVER_PORT|WWWRoot|RootPath|http_host|LOCAL_ADDR|prompt|FileUp|UploadFile|SmtpMail|Adodb|Dictionary|Scripting|JetEngine|wscript|FileSystemObject|Session|Connection|MapPath|InStrRev|FolderExists|WinNT:|StartType|Disposition|CurrentControlSet|HKEY_LOCAL_MACHINE|HKLM\Software|HKLM\SYSTEM|CopyFile|MoveFile|EditFile|DownFile";
		var arr_gal=IllegalStr.split("|");	
		galStr=galStr.toLowerCase();
		for(i=0; i<arr_gal.length; i++){
			if(galStr.indexOf(arr_gal[i].toLowerCase())>=0){
				return false;
			}
		}
		return true;
	}
	
	function checkCoupon(objcop){
		var couponStr=objcop.value.toLowerCase();
		if (GE("Enquiry").value!="Others" || (GE("Enquiry").value=="Others" && couponStr.indexOf("ay")==0)){
		if(couponStr!="" ){			
			if (couponStr.length<4 || couponStr.length>10)
			 {
				alert("The coupon code is invalid. Please input the correct one.");
				objcop.focus();
				ValidationPassed = false;
			  }else{
				var ajax=new AJAXRequest;				
				ajax.post("js/uscoup.asp",	
					"coupon="+couponStr,	  
					function(obj) {
						if(obj.responseText==0){
						ValidationPassed = false;	
						alert("The coupon code is invalid. Please input the correct one.");
						}else{
						ValidationPassed = true;	
						}
					}
				);
				
			}
		}
		}
	}
	
	
	
function resetinfo(){
  try{
	document.reg.Form_username.value="";
	document.reg.Form_password1.value="";
	document.reg.Form_password2.value="";
	document.reg.Form_mail.value="";
	document.reg.Form_question.value="";
	document.reg.Form_answer.value="";
	document.reg.Form_state.value="";
	document.reg.Form_city.value="";
	document.reg.Form_street.value="";
	document.reg.Form_postalcode.value="";
	document.reg.Form_phone.value="";
	document.reg.Form_fax.value="";
	document.reg.Enquiry.value="";
	document.reg.Form_CompanyName.value="";
	document.reg.Form_CompanyWeb.value="";
	document.reg.Form_Memo.value="";
  }catch(e){}
}

function delcookie(){
	var today = new Date();
	var expireDay = new Date();
	var msPerDay = -30*60*1000;
	expireDay.setTime( today.getTime() + msPerDay );
	//document.cookie = mycookie+"="+escape(cookievalue)+";expires=" + expireDay.toGMTString();
	
//var today = new Date();				//删除Cookie
//var expireDay = new Date();
//var msPerDay = -30*24*60*60*1000;
//expireDay.setTime( today.getTime() + msPerDay );
try{document.cookie = "Form_username= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e1){};

try{document.cookie = "Form_mail= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e2){};
try{document.cookie = "Form_question= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e3){};
try{document.cookie = "Form_answer= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e4){};
try{document.cookie = "Form_state= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e5){};
try{document.cookie = "Form_city= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e6){};
try{document.cookie = "Form_street= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e7){};
try{document.cookie = "Form_postalcode= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e8){};
try{document.cookie = "Form_phone= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e9){};
try{document.cookie = "Form_fax= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e10){};
try{document.cookie = "Enquiry= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e11){};
try{document.cookie = "Form_CompanyName= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e12){};
try{document.cookie = "Form_CompanyWeb= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e13){};
try{document.cookie = "Form_Memo= ;expires=" + expireDay.toGMTString()+"; path=/";}catch(e14){};
alert("del coolies");
}
	-->

