// JavaScript Document
var ErrMsg_Login = "Invalid Username/Password.";

// For Add cart without quantity

function addCart( id ){

document.getElementById('pid').value= id;
document.getElementById('productfrm').action = "checkout/cart/";
document.productfrm.submit();

}

// For Add cart with quantity
function addQCart( id ){

document.getElementById('pid').value= id;
document.getElementById('qty').value= document.getElementById('quantity').value;
document.getElementById('productfrm').action = "checkout/cart/";
document.productfrm.submit();

}
////////////////////////////////     Customer Login ///////////////////////////////////////////////


/* 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 http = createRequestObject(); //create the object here
function callvendorFn() {
    
	
	document.getElementById('loginmsg').innerHTML = "Please wait...";
	http.open('get', 'internal_request.php?mode=cust&pass='+ document.getElementById("txtPassword").value +'&username='+ document.getElementById("txtEmail").value);
	
	http.onreadystatechange = handlevendor; 
	http.send(null);
   
}
function handlevendor()
{
	//alert(http.readyState);
	if(http.readyState == 4){ 
	   var response = http.responseText;
       alert(response);
	     if(response == 1 ){

     	  document.getElementById('loginmsg').innerHTML = ""; 
		  location.href='vendor/product.php';
		  
		 }if(response == 0 ){
		      document.getElementById('loginmsg').innerHTML = ErrMsg_Login;
		 }
		 


	}
}

function addCartMulti( ){

  var k=0;
  var str = 0;
  for (i = 0; i < document.getElementById('productfrm').multipad.length; i++){
	
	if(document.getElementById('productfrm').multipad[i].checked == true){
        k = k + 1 ;
		str = str+'@'+document.getElementById('productfrm').multipad[i].value; 
		
	}
   }
	if(str != '' ){
	document.getElementById('pmid').value= document.getElementById('pmid').value + str.substr(2);
    document.getElementById('productfrm').action = "vendor/order.php";
	document.productfrm.submit();
	}else{
	alert("Please select the product to order.");
	}



}

