function regInput(obj, reg, inputStr)
	{
		var docSel	= document.selection.createRange()
		if (docSel.parentElement().tagName != "INPUT")	return false
		oSel = docSel.duplicate()
		oSel.text = ""
		var srcRange	= obj.createTextRange()
		oSel.setEndPoint("StartToStart", srcRange)
		var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
		return reg.test(str)
	}

function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) 
  {
    str = str + ' ';
  }
  return (str == checkstr);
}

function regMatch(obj,reg)
{
  obj.value=reg.test(obj.value)? obj.value.match(reg,obj.value):'0';
}
function regjs()
{
//add by linken 2009-07-20
var formObj=document.reginfo;
var email=formObj.username.value;
var email1=formObj.username1.value;
var email_pattern = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;

if(!email_pattern.test(email) || !email) {
	document.reginfo.username.focus();
	alert("Sorry Please Confirm your The Email is correct!");
	return false;
}
if(!email_pattern.test(email1) || !email1) {
	document.reginfo.username1.focus();
	alert("Sorry Please Confirm your The Email is correct!");
	return false;
}
if(email!=email1) {
	document.reginfo.username1.focus();
	alert("Sorry Please Confirm your The Sencond Email is The Same As the first!");
	return false;
}
//end add

if(checkspace(document.reginfo.firstname.value)) 
{
	document.reginfo.firstname.focus();
    alert("Sorry Please Confirm your First Name is correct!");
	return false;
}

if(checkspace(document.reginfo.lastname.value)) {
	document.reginfo.lastname.focus();
    alert("Sorry Please Confirm your Last Name is correct!");
	return false;
}



    if(checkspace(document.reginfo.password.value) || document.reginfo.password.value.length < 6) {
	document.reginfo.password.focus();
    alert("Sorry Please Confirm your Password is correct!At least 6 character!");
	return false;
  }
    if(document.reginfo.password.value != document.reginfo.password1.value) {
	document.reginfo.password.focus();
	document.reginfo.password.value = '';
	document.reginfo.password1.value = '';
    alert("Sorry Please Confirm your Password is the same!");
	return false;
  }

if(checkspace(document.reginfo.shipping_firstname.value)) {
	document.reginfo.shipping_firstname.focus();
    alert("Sorry Please Confirm your Shopping First Name is correct!");
	return false;
}

if(checkspace(document.reginfo.shipping_lastname.value)) {
	document.reginfo.shipping_lastname.focus();
    alert("Sorry Please Confirm your Shopping Last Name is correct!");
	return false;
}

if(checkspace(document.reginfo.address.value)) {
	document.reginfo.address.focus();
    alert("Sorry Please Confirm your Address Line1 is correct!");
	return false;
}

if(checkspace(document.reginfo.city.value)) {
	document.reginfo.city.focus();
    alert("Sorry Please Confirm your City is correct!");
	return false;
}

if(checkspace(document.reginfo.state.value)) {
	document.reginfo.state.focus();
    alert("Sorry Please Confirm your State/Province/Region is correct!");
	return false;
}

if(checkspace(document.reginfo.postcode.value)) {
	document.reginfo.postcode.focus();
    alert("Sorry Please Confirm your Zip/Postal Code is correct!");
	return false;
}

if(checkspace(document.reginfo.phone.value)) {
	document.reginfo.phone.focus();
    alert("Sorry Please Confirm your Phone Number is correct!");
	return false;
}


}


function regjs1()
{

if(checkspace(document.reginfo.firstname.value)) {
	document.reginfo.firstname.focus();
    alert("Sorry Please Confirm your First Name is correct!");
	return false;
}

if(checkspace(document.reginfo.lastname.value)) {
	document.reginfo.lastname.focus();
    alert("Sorry Please Confirm your Last Name is correct!");
	return false;
}




    if(document.reginfo.password.value != document.reginfo.password1.value) {
	document.reginfo.password.focus();
	document.reginfo.password.value = '';
	document.reginfo.password1.value = '';
    alert("Sorry Please Confirm your Password is correct!");
	return false;
  }

    if(document.reginfo.sex.value == "")
	 {
		 alert("Please select your gender.");      
			
		 document.reginfo.sex.focus();   
			
		 return false; 
	 }

if(checkspace(document.reginfo.address.value)) {
	document.reginfo.address.focus();
    alert("Sorry Please Confirm your Address Line1 is correct!");
	return false;
}

if(checkspace(document.reginfo.city.value)) {
	document.reginfo.city.focus();
    alert("Sorry Please Confirm your City is correct!");
	return false;
}

if(checkspace(document.reginfo.state.value)) {
	document.reginfo.state.focus();
    alert("Sorry Please Confirm your State/Province/Region is correct!");
	return false;
}

if(checkspace(document.reginfo.postcode.value)) {
	document.reginfo.postcode.focus();
    alert("Sorry Please Confirm your Zip/Postal Code is correct!");
	return false;
}

if(document.reginfo.country.value == "")
{
	 alert("Please select your country.");      
		
	 document.reginfo.country.focus();   
		
	 return false; 
}

if(checkspace(document.reginfo.phone.value)) {
	document.reginfo.phone.focus();
    alert("Sorry Please Confirm your Phone Number is correct!");
	return false;
}


}

function GetRadioValue(RadioName){
    var obj;    
    obj=document.getElementsByName(RadioName);
    if(obj!=null){
        var i;
        for(i=0;i<obj.length;i++){
            if(obj[i].checked){
                return obj[i].value;            
            }
        }
    }
    return null;
}

function step3js()
{
	
var RValue;
RValue=GetRadioValue("r1");

if (RValue=="1")
{
	
if(checkspace(document.reginfo.CARDNUM.value)) {
	document.reginfo.CARDNUM.focus();
    alert("Sorry Please Confirm your Credit Card Number is correct!");
	return false;
}

if(checkspace(document.reginfo.NAME.value)) {
	document.reginfo.NAME.focus();
    alert("Sorry Please Confirm your Cardhloder'name is correct!");
	return false;
}

if(checkspace(document.reginfo.CVV.value)) {
	document.reginfo.CVV.focus();
    alert("Sorry Please Confirm your Security Number is correct!");
	return false;
}

if(checkspace(document.reginfo.EXPMM.value)) {
	document.reginfo.EXPMM.focus();
    alert("Sorry Please Confirm your Expiration Date is correct!");
	return false;
}



if(checkspace(document.reginfo.EXPYY.value)) {
	document.reginfo.EXPYY.focus();
    alert("Sorry Please Confirm your Expiration Date is correct!");
	return false;
}


}

}



function infojs1()
{
	
  
    if(checkspace(document.info1.email.value) || checkspace(document.info1.email1.value)) {
	document.info1.email.focus();
    alert("Sorry Please Confirm your E-mail is correct!");
	return false;
  }
    if(document.info1.email.value != document.info1.email1.value) {
	document.info1.email.focus();
	document.info1.email.value = '';
	document.info1.email1.value = '';
    alert("Sorry Please Confirm your E-mail is correct!");
	return false;
  }



}



function infojs2()
{
    if(checkspace(document.reginfo.password.value) || document.reginfo.password.value.length < 6) {
	document.reginfo.password.focus();
    alert("Sorry Please Confirm your Password is correct!");
	return false;
  }
    if(document.reginfo.password.value != document.reginfo.password1.value) {
	document.reginfo.password.focus();
	document.reginfo.password.value = '';
	document.reginfo.password1.value = '';
    alert("Sorry Please Confirm your Password is correct!");
	return false;
  }


}

function shippingaddressjs()
{
	if(document.reginfo.shipping_title.value == "")
	 {
		 alert("Please select your title.");      
			
		 document.reginfo.shipping_title.focus();   
			
		 return false; 
	 }
	 if(checkspace(document.reginfo.shipping_firstname.value)) {
			document.reginfo.shipping_firstname.focus();
		    alert("Sorry Please Confirm your Shopping First Name is correct!");
			return false;
		}

		if(checkspace(document.reginfo.shipping_lastname.value)) {
			document.reginfo.shipping_lastname.focus();
		    alert("Sorry Please Confirm your Shopping Last Name is correct!");
			return false;
		}

		if(checkspace(document.reginfo.shipping_address.value)) {
			document.reginfo.shipping_address.focus();
		    alert("Sorry Please Confirm your Address Line1 is correct!");
			return false;
		}

		if(checkspace(document.reginfo.shipping_city.value)) {
			document.reginfo.shipping_city.focus();
		    alert("Sorry Please Confirm your City is correct!");
			return false;
		}

		if(checkspace(document.reginfo.shipping_state.value)) {
			document.reginfo.shipping_state.focus();
		    alert("Sorry Please Confirm your State/Province/Region is correct!");
			return false;
		}

		if(checkspace(document.reginfo.shipping_postcode.value)) {
			document.reginfo.shipping_postcode.focus();
		    alert("Sorry Please Confirm your Zip/Postal Code is correct!");
			return false;
		}
		if(document.reginfo.shipping_country.value == "")
		 {
			 alert("Please select your country.");      
				
			 document.reginfo.shipping_country.focus();   
				
			 return false; 
		 }
		if(checkspace(document.reginfo.shipping_phone.value)) {
			document.reginfo.shipping_phone.focus();
		    alert("Sorry Please Confirm your daytime phone number is correct!");
			return false;
		}
}

function addressjs()
{
	
if(checkspace(document.reginfo.FIRSTNAME.value)) {
	document.reginfo.FIRSTNAME.focus();
    alert("Sorry Please Confirm your firstname is correct!");
	return false;
  }
  
  if(checkspace(document.reginfo.LASTNAME.value)) {
	document.reginfo.LASTNAME.focus();
    alert("Sorry Please Confirm your lastname is correct!");
	return false;
  }

  if(checkspace(document.reginfo.ADDRESS1.value)) {
	document.reginfo.ADDRESS1.focus();
    alert("Sorry Please Confirm your Address is correct!");
	return false;
  }

  if(checkspace(document.reginfo.CITY.value)) {
	document.reginfo.CITY.focus();
    alert("Sorry Please Confirm your City is correct!");
	return false;
  }

  if(checkspace(document.reginfo.SATE.value)) {
	document.reginfo.SATE.focus();
    alert("Sorry Please Confirm your State/Province/Region is correct!");
	return false;
  }
  
  if(checkspace(document.reginfo.ZIPCODE.value)) {
	document.reginfo.ZIPCODE.focus();
    alert("Sorry Please Confirm your Zip Code is correct!");
	return false;
  }
  

  
  if(checkspace(document.reginfo.PHONE.value)) {
	document.reginfo.PHONE.focus();
    alert("Sorry Please Confirm your Phone is correct!");
	return false;
  }
}
//modify by linken 2009-07-21
function feedbackjs(obj) {
	if(obj) {
		 var formObj=obj;
	} else {
		var formObj=document.getElementById("finfo");
	}
	var firstname=formObj.firstname.value;
	var lastname=formObj.lastname.value;
	var email=formObj.email.value;
	var phone=formObj.phone.value;
	var topic=formObj.topic.value;
	var content=formObj.content.value;
	if(!firstname) {
	    alert("Sorry Please Confirm your First Name is correct!");
	    formObj.firstname.focus();
		return false;
	}
	if(!lastname) {
	    alert("Sorry Please Confirm your Lastname Name is correct!");
	    formObj.lastname.focus();
		return false;
	}
	if(!email) {
	    alert("Sorry Please Confirm your Email is not empty!");
	    formObj.email.focus();
		return false;
	}
	if(!isEmail(email)) {
		alert("Sorry Please Confirm your Email is correct!");
	    formObj.email.focus();
		return false;
	}
	if(!phone) {
	    alert("Sorry Please Confirm your Phone is correct!");
	    formObj.phone.focus();
		return false;
	}
	if(!topic) {
	    alert("Sorry Please Confirm your Topic is correct!");
	    formObj.topic.focus();
		return false;
	}
	if(!content || content.length>2000) {
	    alert("Sorry Please Confirm your Content is correct!\n\rYour content is empty or the character exceed 2000!");
	    formObj.content.focus();
		return false;
	}
   return true;
}

function stepjs()
{
if(checkspace(document.stepinfo.firstname.value)) {
	document.stepinfo.firstname.focus();
    alert("Sorry Please Confirm your firstname is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.lastname.value)) {
	document.stepinfo.lastname.focus();
    alert("Sorry Please Confirm your lastname is correct!");
	return false;
  }

if(document.stepinfo.email.value.length!=0)
  {
    if (document.stepinfo.email.value.charAt(0)=="." ||        
         document.stepinfo.email.value.charAt(0)=="@"||       
         document.stepinfo.email.value.indexOf('@', 0) == -1 || 
         document.stepinfo.email.value.indexOf('.', 0) == -1 || 
         document.stepinfo.email.value.lastIndexOf("@")==document.stepinfo.email.value.length-1 || 
         document.stepinfo.email.value.lastIndexOf(".")==document.stepinfo.email.value.length-1)
     {
      alert("Sorry Please Confirm your Email is correct!");
      document.stepinfo.email.focus();
      return false;
      }
   }
 else
  {
   alert("Sorry Please Confirm your Email is correct!");
   document.stepinfo.email.focus();
   return false;
   }

if(checkspace(document.stepinfo.call.value)) {
	document.stepinfo.call.focus();
    alert("Sorry Please Confirm your call is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.contact.value)) {
	document.stepinfo.contact.focus();
    alert("Sorry Please Confirm your contact is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.country.value)) {
	document.stepinfo.country.focus();
    alert("Sorry Please Confirm your country is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.province.value)) {
	document.stepinfo.province.focus();
    alert("Sorry Please Confirm your province is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.city.value)) {
	document.stepinfo.city.focus();
    alert("Sorry Please Confirm your city is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.address.value)) {
	document.stepinfo.address.focus();
    alert("Sorry Please Confirm your address is correct!");
	return false;
  }
  if(checkspace(document.stepinfo.postcode.value)) {
	document.stepinfo.postcode.focus();
    alert("Sorry Please Confirm your postcode is correct!");
	return false;
  }
    if(document.stepinfo.remarks.value.length > 200 ) {
	document.stepinfo.remarks.focus();
    alert("Not more than 200 characters!");
	return false;
  }

}

function formpassjs()
{
    if(document.formpass.password.value != document.formpass.password1.value) {
	document.formpass.password.focus();
	document.formpass.password.value = '';
	document.formpass.password1.value = '';
    alert("Sorry Please Confirm your Password is correct!");
	return false;
  }
}

function forminfojs()
{
if(checkspace(document.forminfo.firstname.value)) {
	document.forminfo.firstname.focus();
    alert("Sorry Please Confirm your firstname is correct!");
	return false;
  }
  if(checkspace(document.forminfo.lastname.value)) {
	document.forminfo.lastname.focus();
    alert("Sorry Please Confirm your lastname is correct!");
	return false;
  }

if(document.forminfo.email.value.length!=0)
  {
    if (document.forminfo.email.value.charAt(0)=="." ||        
         document.forminfo.email.value.charAt(0)=="@"||       
         document.forminfo.email.value.indexOf('@', 0) == -1 || 
         document.forminfo.email.value.indexOf('.', 0) == -1 || 
         document.forminfo.email.value.lastIndexOf("@")==document.forminfo.email.value.length-1 || 
         document.forminfo.email.value.lastIndexOf(".")==document.forminfo.email.value.length-1)
     {
      alert("Sorry Please Confirm your Email is correct!");
      document.forminfo.email.focus();
      return false;
      }
   }
 else
  {
   alert("Sorry Please Confirm your Email is correct!");
   document.forminfo.email.focus();
   return false;
   }
  
}

function messageaddjs()
{
   if(checkspace(document.messageadd.title.value)) {
	document.messageadd.title.focus();
    alert("Sorry Please Confirm your title is correct!");
	return false;
  }

   if(document.messageadd.content.value.length > 400 ) {
	document.messageadd.content.focus();
    alert("Not more than 400 characters!");
	return false;
  }
}

function getpassjs1()
{
	if(checkspace(document.formgetpass1.userid.value)) {
	document.formgetpass1.userid.focus();
    alert("Sorry Please Confirm your userid is correct!");
	return false;
  }

}
function getpassjs2()
{
	if(checkspace(document.formgetpass2.Answer.value)) {
	document.formgetpass2.Answer.focus();
    alert("Sorry Please Confirm your Answer is correct!");
	return false;
  }

}
function getpassjs3()
{
	if(checkspace(document.formgetpass3.password.value)) {
	document.formgetpass3.password.focus();
    alert("Sorry Please Confirm your password is correct!");
	return false;
  }
    if(document.formgetpass3.password.value != document.formgetpass3.password1.value) {
	document.formgetpass3.password.focus();
	document.formgetpass3.password.value = '';
	document.formgetpass3.password1.value = '';
    alert("Sorry Please Confirm your Password is correct!");
	return false;
  }

}

function addmailjs()
{
if(document.addmailinfo.email.value.length!=0)
  {
    if (document.addmailinfo.email.value.charAt(0)=="." ||        
         document.addmailinfo.email.value.charAt(0)=="@"||       
         document.addmailinfo.email.value.indexOf('@', 0) == -1 || 
         document.addmailinfo.email.value.indexOf('.', 0) == -1 || 
         document.addmailinfo.email.value.lastIndexOf("@")==document.addmailinfo.email.value.length-1 || 
         document.addmailinfo.email.value.lastIndexOf(".")==document.addmailinfo.email.value.length-1)
     {
      alert("Sorry Please Confirm your Email is correct!");
      document.addmailinfo.email.focus();
      return false;
      }
   }
 else
  {
   alert("Sorry Please Confirm your Email is correct!");
   document.addmailinfo.email.focus();
   return false;
   }
}

function DrawImage(ImgD,FitWidth,FitHeight){
	var image=new Image();     
	image.src=ImgD.src;     
	if(image.width>0 && image.height>0){
		if(image.width/image.height>= FitWidth/FitHeight){             
  			if(image.width>FitWidth){                 
  				ImgD.width=FitWidth;                 
  				ImgD.height=(image.height*FitWidth)/image.width;             
  			}
  			else
  			{                 
  				ImgD.width=image.width;                 
  				ImgD.height=image.height;             
  			}         
  		} 
  		else
  		{             
  			if(image.height>FitHeight)
  			{                 
  				ImgD.height=FitHeight;                 
  				ImgD.width=(image.width*FitHeight)/image.height;             
  			}
  			else
  			{                 
  				ImgD.width=image.width;                 
  				ImgD.height=image.height;             
  			}         
  		}     
	} 
}

function onewh(ow)
{
a=eval("wh"+ow)
if(a.style.display=="none")
{
eval ( "wh" + ow +".style.display=\"\";")
}
else
{
eval("wh" + ow +".style.display=\"none\" ;")
}

}

function trshow(obj){
if (obj.style.display=='none')
 {obj.style.display='';}
else
 {obj.style.display='none';}
}

function time()
{
var mydate=new Date()
var year=mydate.getYear()
var month=mydate.getMonth()+1
var date=mydate.getDate()
var day=mydate.getDay()
var hours=mydate.getHours()
var minute=mydate.getMinutes()
var second=mydate.getSeconds()
var str=month+" "+date+" "+year+" "+((hours<10)? "0":"")+hours+((minute<10)? ":0":":")+minute+((second<10)? ":0":":")+second
dd.innerHTML=str
setTimeout("time()",1000)
}


function getck(sname,acookie)
{
	for(var i=0;i<acookie.length;i++){
		var arr=acookie[i].split("=");
		if(sname==arr[0]){
			if(arr.length>1)
			return unescape(arr[1]);
		else
			return "no login";
		}
	}
	return "no login";
}


function isemail(username)
{
alert(username);
return false;

if(document.form1.username.value.length!=0)
  {
    if (document.form1.username.value.charAt(0)=="." ||        
         document.form1.username.value.charAt(0)=="@"||       
         document.form1.username.value.indexOf('@', 0) == -1 || 
         document.form1.username.value.indexOf('.', 0) == -1 || 
         document.form1.username.value.lastIndexOf("@")==document.form1.username.value.length-1 || 
         document.form1.username.value.lastIndexOf(".")==document.form1.username.value.length-1)
     {
      alert("Sorry Please Confirm your Email is correct!");
      document.form1.username.focus();
      return false;
      }
   }
 else
  {
   alert("Sorry Please Confirm your Email is correct!");
   document.form1.username.focus();
   return false;
   }
}

function chkRegData()
{
	if(checkspace(document.reginfo.firstname.value)) 
	{
		document.reginfo.firstname.focus();
	    alert("Sorry Please Confirm your First Name is correct!");
		return false;
	}

	if(checkspace(document.reginfo.lastname.value)) {
		document.reginfo.lastname.focus();
	    alert("Sorry Please Confirm your Last Name is correct!");
		return false;
	}
	
	if (document.reginfo.username.value.length < 4 || !document.reginfo.username.value.match( /^.+@.+$/ ) ) 
	{      
		alert("Invalid email address, please type again.");      
		
		document.reginfo.username.focus();   
		
		return false; 
	}
	
	if(document.reginfo.username1.value != document.reginfo.username.value)
	{
		alert("Confirm email address not match email address, please type again.");      
		
		document.reginfo.username1.focus();   
		
		return false; 
	}
	
	if(checkspace(document.reginfo.password.value) || document.reginfo.password.value.length < 6 || document.reginfo.password.value.length > 16) 
	{
		document.reginfo.password.focus();
		
	    alert("Sorry Please Confirm your Password is correct!");
	    
		return false;
	 }
	 if(document.reginfo.password.value != document.reginfo.password1.value) 
	 {
		document.reginfo.password1.focus();
		
		document.reginfo.password1.value = '';
		
	    alert("Sorry Please Confirm your Confirm Password match your password!");
	    
		return false;
	 }
	 if(document.reginfo.sex.value == "")
	 {
		 alert("Please select your gender.");      
			
		 document.reginfo.sex.focus();   
			
		 return false; 
	 }
	 if(document.reginfo.title.value == "")
	 {
		 alert("Please select your title.");      
			
		 document.reginfo.title.focus();   
			
		 return false; 
	 }
	 if(checkspace(document.reginfo.shipping_firstname.value)) {
			document.reginfo.shipping_firstname.focus();
		    alert("Sorry Please Confirm your Shopping First Name is correct!");
			return false;
		}

		if(checkspace(document.reginfo.shipping_lastname.value)) {
			document.reginfo.shipping_lastname.focus();
		    alert("Sorry Please Confirm your Shopping Last Name is correct!");
			return false;
		}

		if(checkspace(document.reginfo.address.value)) {
			document.reginfo.address.focus();
		    alert("Sorry Please Confirm your Address Line1 is correct!");
			return false;
		}

		if(checkspace(document.reginfo.city.value)) {
			document.reginfo.city.focus();
		    alert("Sorry Please Confirm your City is correct!");
			return false;
		}

		if(checkspace(document.reginfo.state.value)) {
			document.reginfo.state.focus();
		    alert("Sorry Please Confirm your State/Province/Region is correct!");
			return false;
		}

		if(checkspace(document.reginfo.postcode.value)) {
			document.reginfo.postcode.focus();
		    alert("Sorry Please Confirm your Zip/Postal Code is correct!");
			return false;
		}
		if(document.reginfo.country.value == "")
		 {
			 alert("Please select your country.");      
				
			 document.reginfo.country.focus();   
				
			 return false; 
		 }
		if(checkspace(document.reginfo.phone.value)) {
			document.reginfo.phone.focus();
		    alert("Sorry Please Confirm your daytime phone number is correct!");
			return false;
		}
}
function step() 
{
	form2 = document.getElementById("form1");
	
	form2.action="/step.php?action=add";
	
	form2.submit();  
}
/*page nav */
function goUrl(curSelect)
{
	window.location = "/products.php?" + curSelect.value;
}
/*check is email*/
function isEmail(email) {
	var email_pattern = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
	if(!email_pattern.test(email)) {
		return false;
	}
	return true;
}
/*check is email*/
var XMLHttp;
function checkExitsUser(){
	var username = document.getElementById("username").value;
if(isEmail(username)) {

	} else {
		alert("Please confrim your email is correct!");
		document.getElementById("username").focus();
		return false;
	}	
 
xmlHttp = GetXmlHttpObject();
if(xmlHttp==null){

alert("Browser does not support HTTP Request!");
return;

}

var url = "checkuser.php";
url = url + "?username=" +username;
url = url + "&rand=" + Math.random();
xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);

}

function stateChanged(){

if(xmlHttp.readyState==4||xmlHttp.readyState=="complete"){

document.getElementById("txtHint").innerHTML = xmlHttp.responseText;

}

}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}

function confrimUserName() {
	var username=$("#username").val();
	var username1=$("#username1").val();
	if(username!=username1) {
		alert("Please confrim your the seconde email is the same as the firstemail!");
		$("#username1").focus();
		return false;
	}
}

function recommandProduct(pid) {
	$("#mailbox").toggle();
	/*
	URL="/recommand_product.php?pid="+pid;
	myleft=(screen.availWidth-500)/2;
	mytop=150
	mywidth=400;
	myheight=200;
 	window.open(URL,"track","height="+myheight+",width="+mywidth+",status=1,toolbar=no,menubar=no,location=no,scrollbars=yes,scroll=yes,top="+mytop+",left="+myleft+",resizable=yes");
	*/
}
function ajaxSendMail(proid) {
	var mail=$("#mail").val();
	var mail1=$("#mail1").val();
	var mail2=$("#mail2").val();
	var mail3=$("#mail3").val();
	var mail4=$("#mail4").val();
	var mail5=$("#mail5").val();
	var mail_content=$("#mail_content").val();
	if(!mail) {
		alert("E-mail Address can't be empty!");
		$("#mail").focus();
		return false;
	}
	if(!isEmail(mail)) {
			alert("E-mail Address is not correct!");
			$("#mail").focus();
			return false;
	}
	if(mail1) {
		if(!isEmail(mail1)) {
				alert("E-mail Address is not correct!");
				$("#mail1").focus();
				return false;
		}
	}
	if(mail2) {
		if(!isEmail(mail2)) {
				alert("E-mail Address is not correct!");
				$("#mail2").focus();
				return false;
		}
	}
	if(mail3) {
		if(!isEmail(mail3)) {
				alert("E-mail Address is not correct!");
				$("#mail3").focus();
				return false;
		}
	}
	if(mail4) {
		if(!isEmail(mail4)) {
				alert("E-mail Address is not correct!");
				$("#mail4").focus();
				return false;
		}
	}
	if(mail5) {
		if(!isEmail(mail5)) {
				alert("E-mail Address is not correct!");
				$("#mail5").focus();
				return false;
		}
	}


xmlHttp = GetXmlHttpObject();
if(xmlHttp==null){

alert("Browser does not support HTTP Request!");
return;

}

var url = "ajax_sendmail.php";
url = url + "?proid="+proid+"&mail="+mail+"&mail1="+mail1+"&mail2="+mail2+"&mail3="+mail3+"&mail4="+mail4+"&mail5="+mail5+"&mail_content="+mail_content;
url = url + "&rand=" + Math.random();
xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);

}

function stateChanged(){

if(xmlHttp.readyState==4||xmlHttp.readyState=="complete"){

 alert( "Send E-mail successfully!!");

}


 
}
function setCookie (name, value) {
	   var Days = 30; //此 cookie 将被保存 30 天
       var exp = new Date();
	   exp.setTime(exp.getTime() + 1000);
	   if(value==""||value=="null"||value=="null"||value==" "){}else{
       document.cookie = name + "="+ escape(value) +";expires=Sun, 17-Jan-2038 19:14:07 GMT";
	   }
}
function getCookie(sName){
    var aCookie = document.cookie.split("; ");
    for (var i=0; i < aCookie.length; i++)
    {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0])
        {
            return aCrumb[1];
        }
    }
    return null;
}
function $get(id)
{
	return	document.getElementById(id);
}

 
 
 var temp, temp2, cookieArray, cookieArray2, cookieCount;

function initiate(){

  cookieCount=0;

  if(document.cookie){

    cookieArray=document.cookie.split(";");
    cookieArray2=new Array();

    for(i in cookieArray){
      cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,"");
    }

  }

  cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array();

  temp=document.getElementById("containerul");

  for(var o=0;o<temp.getElementsByTagName("li").length;o++){

    if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){

      temp2				= document.createElement("span");
      temp2.className			= "symbols";
      temp2.style.backgroundImage	= (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(/images/minus.jpg)":"url(/images/plus.jpg)"):"url(/images/plus.jpg)";
      temp2.onclick=function(){
        showhide(this.parentNode);
        writeCookie();
      }

      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)

      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";

      if(cookieArray[cookieCount]=="true"){
        showhide(temp.getElementsByTagName("li")[o]);
      }

      cookieCount++;

    }
    else{

      temp2				= document.createElement("span");
      temp2.className			= "symbols";
      temp2.style.backgroundImage	= "url(/images/page.jpg)";

      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);

    }

  }

}



function showhide(el){

  el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";

  el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(/images/minus.jpg)":"url(/images/plus.jpg)";

}



function writeCookie(){		// Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.

  cookieArray=new Array()

  for(var q=0;q<temp.getElementsByTagName("li").length;q++){

    if(temp.getElementsByTagName("li")[q].childNodes.length>0){
      if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){

        cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");

      }
    }

  }

  document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString();

}
