function doajax(){

	  var url="getData/getMemberTimeOut.php";     
	  var  xmlHttp = Inint_AJAX();
	  xmlHttp.onreadystatechange = function () {
	  if(xmlHttp.readyState == 4) {
		     if(xmlHttp.status ==200) {
				 CList = xmlHttp.responseText;  
				
				if(trim(CList)=='Logout'){
				  window.location='member.php';
				}

			 }
		}
 	 }
	xmlHttp.open("GET", url, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=tis-620"); // set Header
	xmlHttp.setRequestHeader("Connection", "close"); // close connection
	xmlHttp.send(null); //Êè§¤èÒ
}
//---------------------------------------------
function stopLogin(chk){
	
	if(chk=='Error'){
	//document.getElementById("cmdLogin").disabled=false;
	document.getElementById("loginLoad").style.display='none';	
	//document.getElementById('fade').style.display='none';
	}

}
///------------------------------check login member--------------------------
function chkLogin(){

//document.getElementById('fade').style.display='block';	
document.getElementById("loginLoad").style.display='inline';	
document.getElementById("loginLoad").innerHTML='Loading...<img src="images/icon/icn_loading2.gif"/>';

	var loginEmail=document.getElementById("memEmail");
	var loginPass=document.getElementById("memPass");

	if(loginEmail.value=='' || loginEmail.value=='ชื่อผู้ใช้'){
		
		alert('กรุณากรอกอีเมล์');
		loginEmail.focus();
		stopLogin('Error');		
		return false;
		
	}else if(loginEmail.value.indexOf ('@',0) == -1 || loginEmail.value.indexOf ('.',0) == -1){
    
		alert('กรุณากรอกอีเมลล์ให้ถูกต้อง');	
		loginEmail.focus();
		stopLogin('Error');		
		return false;
	
   }else if(loginPass.value=='' || loginPass.value=='รหัสผ่าน'){
		
		alert('กรุณากรอกรหัสผ่าน');
		loginPass.focus();
		stopLogin('Error');		
		return false;
		
	}else{
		
	 
	 var url="getData/getMember.php?chkLogin=Login&txtEmail="+loginEmail.value+"&txtPass="+loginPass.value;
	 var  xmlHttp = Inint_AJAX();
	  xmlHttp.onreadystatechange = function () {
	  if(xmlHttp.readyState == 4) {
		   if(xmlHttp.status == 200) {
				 CList = xmlHttp.responseText;  
							// document.getElementById("loginAlert").innerHTML ='';
				 			
							 if(trim(CList)=='No Email'){
								
									 	alert('อีเมลล์นี้ไม่มีในระบบคะ');
										loginEmail.focus();
										stopLogin('Error');		
										return false;
										
							}else if(trim(CList)=='No Verify'){
								
										alert('คุณต้องทำการยืนยันการสมัครสมาชิกก่อนเข้าใช้ระบบคะ');
										stopLogin('Error');		
										return false;
									   	
							  }else if(trim(CList)=='No Pass'){
								
										alert('รหัสผ่านไม่ถูกต้องคะ');
										loginPass.focus();
										stopLogin('Error');		
										return false;
								
							  }else if(trim(CList)=='No Offline'){
								
										alert('สถานะการเข้าใช้ระบบของคุณถูกระงับการใช้ กรุณาติดต่อเจ้าหน้าที่สยามปาร์คซิตี้');
										loginPass.focus();
										stopLogin('Error');		
										return false;
								
							  }else if(trim(CList)=='Expire'){
								 
								        window.location="member_regis_message.php?chkVerify=Expire";
										
							  }else if(trim(CList)=='Member'){
								 
								        window.location="member_cart_select.php";
							 }
		       }
		}
 	 }
		
		xmlHttp.open("GET", url, true); 
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // set Header
		xmlHttp.setRequestHeader("Connection", "close"); // close connection
		xmlHttp.send(null); //Êè§¤èÒ
	}
}

//-------------------------------------------------------------
function EnterLogin(e,val){
	
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

	if (keyCode == 13) {
	chkLogin();
	return false;
	}
	else
	return true;
	}
///------------------------------check login member--------------------------
function stopLogin2(chk){
	
	if(chk=='Error'){
	//document.getElementById("cmdLogin").disabled=false;
	document.getElementById("loginLoad2").style.display='none';	
	document.getElementById('fade').style.display='none';
	}

}	
///------------------------------check login member--------------------------
function chkLogin2(strUrl){
	
document.getElementById('fade').style.display='block';
document.getElementById("loginLoad2").style.display='inline';	
document.getElementById("loginLoad2").innerHTML='Loading...<img src="images/icon/icn_loading.gif"/>';

	var loginEmail=document.getElementById("loginEmail");
	var loginPass=document.getElementById("loginPass");

	if(loginEmail.value=='' || loginEmail.value=='ชื่อผู้ใช้'){
		
		alert('กรุณากรอกอีเมล์');
		loginEmail.focus();
		stopLogin2('Error');		
		return false;
		
	}else if(loginEmail.value.indexOf ('@',0) == -1 || loginEmail.value.indexOf ('.',0) == -1){
    
		alert('กรุณากรอกอีเมลล์ให้ถูกต้อง');	
		loginEmail.focus();
		stopLogin2('Error');		
		return false;
	
   }else if(loginPass.value=='' || loginPass.value=='รหัสผ่าน'){
		
		alert('กรุณากรอกรหัสผ่าน');
		loginPass.focus();
		stopLogin2('Error');		
		return false;
		
	}else{
		
	 var url="getData/getMember.php?chkLogin=Login&txtEmail="+loginEmail.value+"&txtPass="+loginPass.value;
	 var  xmlHttp = Inint_AJAX();
	  xmlHttp.onreadystatechange = function () {
	  if(xmlHttp.readyState == 4) {
		   if(xmlHttp.status == 200) {
				 CList = xmlHttp.responseText;  
							// document.getElementById("loginAlert").innerHTML ='';
				 			 if(trim(CList)=='No Email'){
								
									 	alert('อีเมลล์นี้ไม่มีในระบบคะ');
										loginEmail.focus();
										stopLogin2('Error');		
										return false;
										
							}else if(trim(CList)=='No Verify'){
								
										alert('คุณต้องทำการยืนยันการสมัครสมาชิกก่อนเข้าใช้ระบบคะ');
										stopLogin2('Error');		
										return false;
									   	
							  }else if(trim(CList)=='No Pass'){
								
										alert('รหัสผ่านไม่ถูกต้องคะ');
										loginPass.focus();
										stopLogin2('Error');		
										return false;
								
							  }else if(trim(CList)=='No Offline'){
								
										alert('สถานะการเข้าใช้ระบบของคุณถูกระงับการใช้ กรุณาติดต่อเจ้าหน้าที่สยามปาร์คซิตี้');
										loginPass.focus();
										stopLogin2('Error');		
										return false;
								
							  }else if(trim(CList)=='Expire'){
								 
								        window.location="member_regis_message.php?chkVerify=Expire";
										
							  }else if(trim(CList)=='Member'){
								 
								         window.location=strUrl;
							 }
							 
		 }else{
				  alert("error in data login");
			  }
		}
 	 }
		
		xmlHttp.open("GET", url, true); 
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // set Header
		xmlHttp.setRequestHeader("Connection", "close"); // close connection
		xmlHttp.send(null); //Êè§¤èÒ
	}
}

//-------------------------------------------------------------
function EnterLogin2(e,val,strUrl){
	
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

	if (keyCode == 13) {
	chkLogin2(strUrl);
	return false;
	}
	else
	return true;
	}
//-------------------------------------------Forgot Pass-----------------------------------------------------------------
function stopForgot(chk){
	
	if(chk=='Error'){
		document.getElementById("showLoad").style.display='none';	
		document.getElementById('fade').style.display='none';
	}

}

function chkForgot(){
	
document.getElementById('fade').style.display='block';
document.getElementById("showLoad").style.display='inline';	
document.getElementById("showLoad").innerHTML='Loading...<img src="images/icon/icn_loading.gif"/>';

var	txtemail=document.getElementById("txtemail");
var  txtcode=document.getElementById("txtcode");
	            
if(trim(txtemail.value)==""){
	alert("กรุณาระบุอีเมลล์ให้ถูกต้องคะ");
	txtemail.focus();
	stopForgot('Error');	
}else if(txtemail.value.indexOf ('@',0) == -1 || txtemail.value.indexOf ('.',0) == -1){
	alert("กรุณาระบุอีเมลล์ให้ถูกต้องคะ");
	txtemail.focus();
	stopForgot('Error');	
}else if(trim(txtcode.value)==""){
	alert('รหัสยืนยันไม่ถูกต้องคะ');
	txtcode.focus();
	stopForgot('Error');	
}else{

				 document.getElementById('fade').style.display='block';
				 var url="getData/getMember_forgot.php?txtemail="+txtemail.value+"&txtcode="+txtcode.value+"";     
				 var  xmlHttp = Inint_AJAX();
				  xmlHttp.onreadystatechange = function () {
				  if(xmlHttp.readyState == 4) {
					   if(xmlHttp.status == 200) {
						
						CList = xmlHttp.responseText;  
						
						if(trim(CList)=='error code'){
							  alert('รหัสยืนยันไม่ถูกต้องคะ');
							  txtcode.focus();
							  stopForgot('Error');	
						}else if(trim(CList)=='error email'){
							 alert('อีเมลล์นี้ไม่มีในระบบคะ กรุณาติดต่อเจ้าหน้าที่สยามปาร์คซิตี้');
							  txtcode.focus();
							  stopForgot('Error');	
						}else if(trim(CList)=='error verify'){
							 alert('คุณต้องทำการยืนยันการสมัครสมาชิกก่อนเข้าใช้ระบบคะ');
							  txtcode.focus();
							  stopForgot('Error');	
						}else if(trim(CList)=='error offline'){
							  alert('สถานะการเข้าใช้ระบบของคุณถูกระงับการใช้ กรุณาติดต่อเจ้าหน้าที่สยามปาร์คซิตี้');
							  txtcode.focus();
							  stopForgot('Error');	
						}else if(trim(CList)=='send ok'){
							
								 stopForgot('Error');	
								document.getElementById("showForm").style.display='none';	
	document.getElementById("showThank").innerHTML='<table width="100%" border="0" cellspacing="0"><tr><td width="569" class="Message">ได้ทำการส่งข้อมูลการเข้าใช้ระบบ ไปยังอีเมลล์ของท่านเรียบร้อยแล้วคะ <br /> หากท่านไม่ได้รับอีเมล์ จากทางสยามพาร์คซิตี้  กรุณาตรวจสอบใน กล่องจดหมายขยะหรือติดต่อเจ้าหน้าที่สยามพาร์คซิตี้</td></tr></table>';

						}else if(trim(CList)=='send error'){
							 stopForgot('Error');	
							document.getElementById("showForm").style.display='none';	
							document.getElementById("showThank").innerHTML='ขออภัยค่ะ! ไม่สามารถส่งข้อมูลการสมัครของท่านได้ กรุณาตรวจสอบอีเมลล์ของท่านอีกครั้งคะ';
						}
					
		   }
		 }//end if
 	 }// end function
		xmlHttp.open("GET", url, true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // set Header
		xmlHttp.setRequestHeader("Connection", "close"); // close connection
		xmlHttp.send(null); //Êè§¤èÒ
    }
 }
 // end function
//-------------------------------------------------------------
function EnterForgot(e,val){
	
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

	if (keyCode == 13) {
	chkForgot();
	return false;
	}
	else
	return true;
	}
	
function chkForgotReset(){
	
document.getElementById("txtemail").value='';
document.getElementById("txtcode").value='';

}
//-----------------check email in database--------------------------
function chkEmail(){
 
var strEmail=document.getElementById("txtemail");

if(trim(strEmail.value)==""){
	alert('กรุณากรอกอีเมล์');
	strEmail.focus();
	return false;
}else if(strEmail.value.indexOf ('@',0) == -1 || strEmail.value.indexOf ('.',0) == -1){
	alert('กรุณากรอกอีเมลล์ให้ถูกต้อง');	
	strEmail.focus();
	return false;
}else{
	  
 document.getElementById("status_email").innerHTML='<img src="images/icon/icn_loading.gif"/>';
  
   var  xmlHttp = Inint_AJAX();
     xmlHttp.onreadystatechange = function () { 
          if (xmlHttp.readyState==4) {
               if (xmlHttp.status==200) {
                    var data=xmlHttp.responseText; 
					
				        if(trim(data)=='dup'){
							  alert("อีเมลล์นี้มีแล้วในระบบคะ กรุณากรอกใหม่อีกครั้ง");
							  document.getElementById("status_email").innerHTML='<img src="images/icon/icn_false.png" width="16" height="16" />';
							  strEmail.focus();
						}else if(trim(data)=='ok'){
                              document.getElementById("status_email").innerHTML='<img src="images/icon/icn_true.png" width="16" height="16" />';		
                     }
               } 
          } 
     }
     xmlHttp.open("GET", "getData/getMember.php?chkEmail=Email&txtEmail="+strEmail.value, true); 
     xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // set Header
	 xmlHttp.setRequestHeader("Connection", "close");
     xmlHttp.send(null); 
	
	}
}
//-----------------check alias in database--------------------------
function chkAlias(){
 
var strAlias=document.getElementById("txtalias");

if(trim(strAlias.value)==""){
	alert("กรุณากรอกชื่อนามแฝงคะ");
	strAlias.focus();
	return false;
}else{
	  
 document.getElementById("status_alias").innerHTML='<img src="images/icon/icn_loading.gif"/>';
  
   var  xmlHttp = Inint_AJAX();
     xmlHttp.onreadystatechange = function () { 
          if (xmlHttp.readyState==4) {
               if (xmlHttp.status==200) {
                    var data=xmlHttp.responseText; //ÃÑº¤èÒ¡ÅÑºÁÒ
				        if(trim(data)=='dup'){
							  alert("ชื่อนามแฝงนี้มีแล้วในระบบ กรุณากรอกใหม่อีกครั้ง");
							  document.getElementById("status_alias").innerHTML='<img src="images/icon/icn_false.png" width="16" height="16" />';
							  strAlias.focus();
						}else if(trim(data)=='ok'){
                              document.getElementById("status_alias").innerHTML='<img src="images/icon/icn_true.png" width="16" height="16" />';		
                     }
               } 
          } 
     }
     xmlHttp.open("GET", "getData/getMember.php?chkAlias=Alias&txtAlias="+strAlias.value, true); 
     xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // set Header
	 xmlHttp.setRequestHeader("Connection", "close");
     xmlHttp.send(null); 
	
	}
}

