
/*

The stateChanged() and GetXmlHttpObject functions are the same as in the PHP AJAX Suggest chapter, you can go to there for an explanation of those.

The showUser() Function

When a person in the drop-down box is selected, the showUser() function executes the following:

   1. Calls the GetXmlHttpObject() function to create an XMLHTTP object
   2. Defines an URL (filename) to send to the server
   3. Adds a parameter (q) to the URL with the content of the drop-down box
   4. Adds a random number to prevent the server from using a cached file
   5. Each time the readyState property changes, the stateChanged() function will be executed
   6. Opens the XMLHTTP object with the given URL
   7. Sends an HTTP request to the server

*/
var xmlhttp;

function checkLogin()
{
			var name = document.lgnfrm.uname.value;
			var password = document.lgnfrm.upassword.value;
		 //alert("nn"+name);
		 
			if(name == ''){
				alert('Required field !');
				document.lgnfrm.uname.focus();
				return false;
			}
			else if(password == ''){
				alert('Required field !');
				document.lgnfrm.upassword.focus();
				return false;
			}
			else{
					//alert("123");
				if(name == "admin" && password == "admin"){					
					window.location='ManageID.php';
//					return true;
				}
				else{
					return false;	
				}
			}
			
	
		/*var str = 'hello';
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
		  {
		  alert ("Browser does not support HTTP Request");
		  return;
		  }
		var url="Checkuser.php";
		url=url+"?q="+str;
		url=url+"&sid="+Math.random(); //Adds a random number to prevent the server from using a cached file
		xmlhttp.onreadystatechange=stateChanged;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null); */
}

	function stateChanged()
	{
			if (xmlhttp.readyState==4)
			{
				alert("result :"+xmlhttp.responseText);
				document.getElementById("chkUser").innerHTML=xmlhttp.responseText;
			}
	}

	function GetXmlHttpObject()
	{
			
			if (window.XMLHttpRequest)
			  {
			  // code for IE7+, Firefox, Chrome, Opera, Safari
			  return new XMLHttpRequest();
			  }
			if (window.ActiveXObject)
			  {
			  // code for IE6, IE5
			  return new ActiveXObject("Microsoft.XMLHTTP");
			  }
			return null;
	}