var 	xmlHttp;
function createXMLHttpRequest(){
		if(window.ActiveXObject){
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}else if(window.XMLHttpRequest){
				xmlHttp=new XMLHttpRequest();
		}
}

function check_user_en(){
		createXMLHttpRequest();
		var var_user = document.getElementById("u").value;
		xmlHttp.onreadystatechange=handleStateChange;
		xmlHttp.open("GET","check_user.php?e=" + var_user,true);
		xmlHttp.send(null);
}

function handleStateChange(){
		if(xmlHttp.readyState==4){
			if(xmlHttp.status==200){
				var re;
				re=xmlHttp.responseText.split(":");
				if(re[0]=='Y'){
						alert("You can use this user "+re[1]+".");
						location="?step=3&u="+re[1];
				}else if(re[0]=='E'){
						alert("Please select a new user who may then use this user and not empty, user. Must contain 0-9, az, AZ.");
				}else if(re[0]=='N'){
						alert("User "+re[1]+" has been used already.");
				}
			}
		}
}
//===================================================
function Count_download(){
		createXMLHttpRequest();
		var code = document.getElementById("H_code").value;
		xmlHttp.onreadystatechange=handleCountDownload;
		xmlHttp.open("GET","c.php?code="+code,true);
		xmlHttp.send(null);
}

function handleCountDownload(){
		if(xmlHttp.readyState==4){
			if(xmlHttp.status==200){
			}
		}
}
//=============================================
function check_user(){
			createXMLHttpRequest();
		var var_user = document.getElementById("u").value;
		xmlHttp.onreadystatechange=handleCheckBlog;
		xmlHttp.open("GET","check_user.php?e=" + var_user,true);
		xmlHttp.send(null);
}

function handleCheckBlog(){
		if(xmlHttp.readyState==4){
			if(xmlHttp.status==200){
				var re;
				re=xmlHttp.responseText.split(":");
								if(re[0]=='N'){
									alert("คุณ ไม่สามารถใช้  "+re[1]+" ได้ กรุณาเลือกใหม่");
									document.getElementById("u").value="";
									document.getElementById("u").focus();
							}else if(re[0]=='E'){
									alert("กรุณาเลือก user ใหม่ อาจมีคนใช้งาน user นี้ไปแล้ว และ  ห้ามเว้นว่าง,user ต้องประกอบด้วย 0-9,a-z,A-Z.");
							}else{
									alert("คุณ สามารถใช้  "+re[1]+" ได้");
									location="?step=3&u="+re[1];
							}
			}
		}
}
//====================================================================
