function ajax(process,divname,value1,value2){
  
		 if(process=="check_userid_avail"){
		 
		  value      =document.getElementById(value1).value;	
	    
		  qstr = 'p=' + escape(process) + '&userid=' + escape(value);  // NOTE: no '?' before querystring
		  
		  document.getElementById(divname).innerHTML="<img src=ajax/ajax-loader.gif>&nbsp;<span class='required'>Please wait, Loading...</span>"; 
		  
		  xmlhttpPost('ajax.php',divname,qstr); 
	    
	} 
	
	
	if(process == "quantity_updation"){
	    
		 quantity = document.getElementById(value1).value;
		 
		 cart_id = value2;
	    
	     qstr = 'p=' + escape(process) + '&quantity=' + escape(quantity) + '&cart_id=' + escape(cart_id);  // NOTE: no '?' before querystring
		  
		  document.getElementById(divname).innerHTML="<img src=ajax/ajax-loader.gif>&nbsp;<span class='required'>Please wait, Loading...</span>"; 
		  
		  xmlhttpPost('ajax.php',divname,qstr);  
		  
		 // document.forms[0].submit();
			
	}
	
	//Clearing cart
	
	if(process == "clear_cart"){
	  
			php_session_id = value1;
			
			 qstr = 'p=' + escape(process) + '&php_session_id=' + escape(php_session_id);  // NOTE: no '?' before querystring
		  
		  document.getElementById(divname).innerHTML="<img src=ajax/ajax-loader.gif>&nbsp;<span class='required'>Please wait, Loading...</span>"; 
		  
		  xmlhttpPost('ajax.php',divname,qstr);  
			
	}
	
	if(process=="update_billing_amount"){
		
		php_session_id = value1;
		 
	   qstr = 'p=' + escape(process) + '&php_session_id=' + escape(php_session_id);  // NOTE: no '?' before querystring
		  
	document.getElementById(divname).innerHTML="<img src=ajax/ajax-loader.gif>&nbsp;<span class='required'>Please wait, Loading...</span>"; 
		  
		  xmlhttpPost('ajax.php',divname,qstr);  
	 	 
	}
	if(process=="remove_cart_item"){
		
		php_session_id = value1;
		
		cart_item_id    = value2;
		
	 qstr = 'p=' + escape(process) + '&php_session_id=' + escape(php_session_id) + '&cart_item_id=' + escape(cart_item_id);  // NOTE: no '?' before querystring
		  
	document.getElementById(divname).innerHTML="<img src=ajax/ajax-loader.gif>&nbsp;<span class='required'>Please wait, Loading...</span>"; 
		  
		  xmlhttpPost('ajax.php',divname,qstr);  
		
		
	}
	
}
function xmlhttpPost(strURL,divname,qstr)
 {
   
	
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText,divname);
        }
    }
    self.xmlHttpReq.send(qstr);
	 
}



function updatepage(a,divname)
{ 
  if(divname=="cart_item_grid"){
	   	document.forms[0].submit();
   }
  
  
	if(divname){
		document.getElementById(divname).innerHTML="";
		document.getElementById(divname).innerHTML=a;
	}
}
