 var ajaxchk=null;
var ajaxstr=null;
  function checkUserName()
  {
 	var obj=document.getElementById("emailmsg");
	var str=document.getElementById("getemail").value;
	var chk=true;
	if (str==''|| !str.match(/^[\w\.\-]+@([\w\-]+\.)+[a-z]{2,4}$/ig)){chk=false}
	if (chk){
	 
	}else{
		 alert("Please check your email address. Your email address should looks like myname@gmail.com.")
		return chk;
	}
	
	objHttp = getHttpRequest(); 
	var url="/checkemail.asp?stremail="+str; 
	var btype=getOs(); 
	objHttp.onreadystatechange=(btype=="Firefox")?getCommodity():getCommodity; 
	objHttp.open("GET",url,false); 
	objHttp.send(null); 
	objHttp.onreadystatechange=(btype=="Firefox")?getCommodity():getCommodity; 


	if (ajaxchk=='ok'){
	  	alert(ajaxstr);
		 document.getElementById("getemail").value=''
	 }else{
		  alert(ajaxstr);
		  document.getElementById("getemail").value=''
	 }
   }
  

function getHttpRequest(){ 
	var httpRequest; 
	if (window.XMLHttpRequest){ 
	httpRequest = new XMLHttpRequest(); 
	if (httpRequest.overrideMimeType){ 
	httpRequest.overrideMimeType('text/xml'); 
	} 
	}else if (window.ActiveXObject){ 
	try{ 
	httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); 
	}catch(e){ 
	try { 
	httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
	}catch(e){} 
	} 
	} 
	return httpRequest; 
} 


function getCommodity(){ 
if(objHttp.readyState==4) 
{ 
if(objHttp.status==200) 
{ 
   var s=objHttp.responseText;
   ajaxchk=s.split('|')[0];
   ajaxstr=s.split('|')[1];
} 
} 
} 



  
  
function getOs() 
{ 
var OsObject = ""; 
if(navigator.userAgent.indexOf("MSIE")>0) { 
return "MSIE"; //IE浏览器 
} 
if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ 
return "Firefox"; //Firefox浏览器 
} 
if(isSafari=navigator.userAgent.indexOf("Safari")>0) { 
return "Safari"; //Safan浏览器 
} 
if(isCamino=navigator.userAgent.indexOf("Camino")>0){ 
return "Camino"; //Camino浏览器 
} 
if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){ 
return "Gecko"; //Gecko浏览器 
} 
} 

