// JavaScript Document
var xmlHttp_side

	
	function GetXmlHttpObject_side(handler)
	{ 
		var objXmlHttp=null
	
		if (navigator.userAgent.indexOf("Opera")>=0)
		{
			alert("This Doesn't work in Opera") 
			return 
		}
		
		if (navigator.userAgent.indexOf("MSIE")>=0)
		{ 
			var strName="Msxml2.XMLHTTP"
			if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
			{
				strName="Microsoft.XMLHTTP"
			} 
			try
			{ 
				objXmlHttp=new ActiveXObject(strName)
				objXmlHttp.onreadystatechange=handler 
				return objXmlHttp
			} 
			catch(e)
			{ 
				alert("Error. Scripting for ActiveX might be disabled") 
				return 
			} 
		} 
			if (navigator.userAgent.indexOf("Mozilla")>=0)
			{
				objXmlHttp=new XMLHttpRequest()
				objXmlHttp.onload=handler
				objXmlHttp.onerror=handler 
				return objXmlHttp
			}
	} 
	
	
	
	
function side_trimSpaces(stringValue) 
{
	   // Checks the first occurance of spaces and removes them
	   for(i = 0; i < stringValue.length; i++) 
	   {
		    if(stringValue.charAt(i) != " ") 
		     {			break;		}
	   }
	
	   if(i > 0) 
	   {		stringValue = stringValue.substring(i);	}
	
	   // Checks the last occurance of spaces and removes them
	   strLength = stringValue.length - 1;
	   for(i = strLength; i >= 0; i--) 
	   {
		   if(stringValue.charAt(i) != " ") 
		   {		break;		}
	   }
	
	   if(i < strLength) 
	   {		stringValue = stringValue.substring(0, i + 1);	}
	
	   // Returns the string after removing leading and trailing spaces.
	return stringValue;
}





function submit_login()
{
  login_chk();
  return false;
}



function login_chk()
	 { 	
	  	  
	   	if(side_trimSpaces(document.login_form.uid.value)=="")
  	 	{
     	 		logmes = ""+js_replace_array[71]+"";
     	 		document.getElementById('logindiv').innerHTML=logmes;    
     	 		document.login_form.uid.focus();
  	 	}
  	 	else
  	 	{  
  	 		 	var url="user/login_check.php?uname=" + document.login_form.uid.value +"&pwd="+ document.login_form.pwd.value; 	
  	 		  xmlHttp_side=GetXmlHttpObject_side(chkLogin)
  	   		xmlHttp_side.open("GET", url , true)
  	   		xmlHttp_side.send(null)
  	 	}		
	 } 


 
	
	function chkLogin() 
	{ 
		
   		if (xmlHttp_side.readyState==4 || xmlHttp_side.readyState=="complete")
   		{ 
      		if(xmlHttp_side.responseText == 1)
     			{     			   
       		  window.location="user/welcome.php"; 	 
     			}
     			else if(xmlHttp_side.responseText == 2)
     			{
     			 					window.location="user/welcome.php";										
     			}
     			else if(xmlHttp_side.responseText == 3)
     			{
     			   window.location="account_reactivation.php";        				 	     			 
     			}
     			else if(xmlHttp_side.responseText == 4)
     			{
     			   logmes =""+js_replace_array[72]+"";
     			   document.getElementById('logindiv').innerHTML=logmes;            				 	     			 
     			}
								else if(xmlHttp_side.responseText == 5)
     			{
     			   window.location="account_reactivate.php";		 	     			 
     			}
								
     			else
     			{
     			   logmes =""+js_replace_array[73]+"";
     			   document.getElementById('logindiv').innerHTML=logmes;     
     			}			
   		} 
	}
	
	

	function getPassword()
	{	    window.location="forgot_password.php";           	}

	
	
	
	
	function logOut()
	 { 		   
    var url="logout.php";
    xmlHttp_side=GetXmlHttpObject_side(chkLogOut)
  		xmlHttp_side.open("GET", url , true)
  		xmlHttp_side.send(null)	   	   
	 } 
	
 
 
 
 
 
	function chkLogOut() 
	{ 
  		if (xmlHttp_side.readyState==4 || xmlHttp_side.readyState=="complete")
  		{ 
     			if(xmlHttp_side.responseText > 0)
     			{	
     				 window.location="../";
     			}							
  		} 
	}
