var ErrMsg_Login = "Invalid Username/Password.";
// JavaScript Document
function postQuery( id ){

document.getElementById('pid').value= id;
document.getElementById('productfrm').action = "Post/Query/add";
document.productfrm.submit();

}
function showProduct( name){
alert(name);
}
/* 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
}


/* The variable http will hold our new XMLHttpRequest object. */
var httpcatalog = createRequestObject(); //create the object here


// update the number of product viewed

function callViewProductFD(id){
     
   httpcatalog.open('get', 'request.php?mode=viewproduct&vid='+id);
	httpcatalog.onreadystatechange = fillViewProductconfirm; 
	httpcatalog.send(null);
	
}


function fillViewProductconfirm() {
	if(httpcatalog.readyState == 4) { 
  	  var response = httpcatalog.responseText;
     
	}
}


/* 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
}

/* The variable http will hold our new XMLHttpRequest object. */
var httpcust = createRequestObject(); //create the object here
/// Check Login Details

function callCustomerLogFn(){
document.getElementById('loginmsglog').innerHTML = "Please wait...";
	httpcust.open('get', 'catalog/internal_request.php?mode=user&pass='+ document.getElementById("pwd").value +'&username='+ document.getElementById("txtLogin").value);
	
	httpcust.onreadystatechange = handlecustomerLog; 
	httpcust.send(null);
}
function handlecustomerLog()
{
	if(httpcust.readyState == 4){ 
	   var response = httpcust.responseText;
      // alert(response);
	     if(response == 1 ){

     	  document.getElementById('loginmsglog').innerHTML = ""; 
		   if(document.getElementById('path').value == ""){
		    location.href='products.html'
		   }else{
		   		  location.href=document.getElementById('path').value;
		          document.getElementById('path').value = ''; 
		    }
		 }else{
		      document.getElementById('loginmsglog').innerHTML = ErrMsg_Login;
		 }
		 


	}
}

function callCustomerFn() {
    
	
	document.getElementById('loginmsg').innerHTML = "Please wait...";
	httpcust.open('get', 'catalog/internal_request.php?mode=user&pass='+ document.getElementById("txtPassword").value +'&username='+ document.getElementById("txtLoginID").value);
	
	httpcust.onreadystatechange = handlecustomer; 
	httpcust.send(null);
   
}
function handlecustomer()
{
	if(httpcust.readyState == 4){ 
	   var response = httpcust.responseText;
      // alert(response);
	     if(response == 1 ){

     	  document.getElementById('loginmsg').innerHTML = ""; 
		   if(document.getElementById('path').value == ""){
		    location.href='products.html'
		   }else{
		   		  location.href=document.getElementById('path').value;
		          document.getElementById('path').value = ''; 
		    }
		 }else{
		      document.getElementById('loginmsg').innerHTML = ErrMsg_Login;
		 }
		 


	}
}


