/* The following function creates an XMLHttpRequest object... */

function createRequestObject(){
	var request_o; //declare the variable to hold the object.
	var browser = navigator.appName; //find the browser name
	if(browser == "Microsoft Internet Explorer"){
		/* Create the object using MSIE's method */
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		/* Create the object using other browser's method */
		request_o = new XMLHttpRequest();
	}
	return request_o; //return the object
}

/* You can get more specific with version information by using 
	parseInt(navigator.appVersion)
	Which will extract an integer value containing the version 
	of the browser being used.
*/
/* The variable http will hold our new XMLHttpRequest object. */
var http = createRequestObject(); 
var response;

/* Function called to login  */
function login(){
	/* Create the request. The first argument to the open function is the method (POST/GET),
		and the second argument is the url... 
	
	*/
	//alert ('parts/ajaxlogin.php?'+loginpara());
	http.open('post', 'parts/ajaxlogin.php?'+loginpara());
	/* Define a function to call once a response has been received. This will be our
		handleProductCategories function that we define below. */
	http.onreadystatechange = handleLogin; 
	/* Send the data. We use something other than null when we are sending using the POST
		method. */
	http.send(null);
	
}

/* Function called to handle the status of login that was returned from the ajaxlogin.php file.. */
function handleLogin(){
	/* Make sure that the transaction has finished. The XMLHttpRequest object 
		has a property called readyState with several states:
		0: Uninitialized
		1: Loading
		2: Loaded
		3: Interactive
		4: Finished */
	if(http.readyState == 1){
		
	// document.getElementById('load').style.visibility = "visible"
	    document.getElementById("login_error").innerHTML = "Login in progress ......";

	}
		
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		 response="";
	     response = http.responseText;
		eval(response);
		 if(status=="false"){
			 document.getElementById("login_error").innerHTML = "Invalid Login Name or Password. Please try again.";
		
			 
		 }
		 else{
		     document.getElementById("login_error").innerHTML = "Login Successfully.";
                     self.location='index.php?body=email&title1=Shopping+Checkout';
		 }
		
	}
}

