var req;
var action;
function add_products(act, id, oscid, page) {
	var attrib = '&';
  if(oscid){
	 oscid = '&osCsid='+oscid;
  }

if(page == 'prodinfo'){
	len = document.cart_quantity.elements.length;
	for(l=0; l<len; l++){
		name = document.cart_quantity.elements[l].name;
		aid = (name.substr(0,2));
		if(aid == 'id'){
			value = document.getElementById(name).value;
			naid = (name.substr(3,32));
			attrib = attrib + '|'+naid+'~'+value;
		}
	}
}
  action = act;
   var url="add.php?&act="+act+"&id="+id+oscid+attrib;

   // Internet Explorer
   try { req = new ActiveXObject("Msxml2.XMLHTTP"); } 
   catch(e) { 
      try { req = new ActiveXObject("Microsoft.XMLHTTP"); } 
      catch(oc) { req = null; } 
   } 

   // Mozailla/Safari 
   if (!req && typeof XMLHttpRequest != "undefined") { req = new XMLHttpRequest(); } 

   // Call the processChange() function when the page has loaded 
   if (req != null) {
	  document.getElementById('ajaxanimat').style.display = "";
      req.onreadystatechange = processChange; 
      req.open("GET", url, true); 
      req.send(null); 
   } 
}

function processChange() { 
   // The page has loaded and the HTTP status code is 200 OK 
   if (req.readyState == 4 && req.status == 200) { 
      // Write the contents of this URL to the searchResult layer 
      getObject("lishshow").innerHTML = req.responseText;
	  if(action == 'addwishlist'){
		   document.getElementById('ajaxanimat').style.display = "none";
		  document.getElementById('cartadded').style.display = "";
	  }else if(action == 'addproduct'){
		  //alert('Product added in your Cart.');
		  document.getElementById('ajaxanimat').style.display = "none";
		  document.getElementById('cartadded').style.display = "";
	  }else if(action == 'shipest'){
	  }else{
		 // alert('Sorry!');
	  }
   } 
}
var position;
function add_x_sell(act, id, oscid, pos) {
  if(oscid){
	 oscid = '&osCsid='+oscid;
  }

  action = act;
  position = pos;
   var url="add.php?&act="+act+"&id="+id+oscid;

   // Internet Explorer
   try { req = new ActiveXObject("Msxml2.XMLHTTP"); } 
   catch(e) { 
      try { req = new ActiveXObject("Microsoft.XMLHTTP"); } 
      catch(oc) { req = null; } 
   } 

   // Mozailla/Safari 
   if (!req && typeof XMLHttpRequest != "undefined") { req = new XMLHttpRequest(); } 

   // Call the processChange() function when the page has loaded 
   if (req != null) {
	  document.getElementById('xajaxanimat'+pos).style.display = "";
      req.onreadystatechange = processChangeXSell; 
      req.open("GET", url, true); 
      req.send(null); 
   } 
}

function processChangeXSell() { 
   // The page has loaded and the HTTP status code is 200 OK 
   if (req.readyState == 4 && req.status == 200) { 
      // Write the contents of this URL to the searchResult layer 
      getObject("lishshow").innerHTML = req.responseText;
		  document.getElementById('xajaxanimat'+position).style.display = "none";
		  document.getElementById('xcartadded'+position).style.display = "";
   } 
}

function getObject(name) { 
   var ns4 = (document.layers) ? true : false; 
   var w3c = (document.getElementById) ? true : false; 
   var ie4 = (document.all) ? true : false; 

   if (ns4) return eval('document.' + name); 
   if (w3c) return document.getElementById(name); 
   if (ie4) return eval('document.all.' + name); 
   return false; 
}

function shipping_calculation(state, oscid) {
  if(oscid){
	 oscid = '&osCsid='+oscid;
  }
  var url="ship.php?stlist="+state+oscid;

   // Internet Explorer
   try { req = new ActiveXObject("Msxml2.XMLHTTP"); } 
   catch(e) { 
      try { req = new ActiveXObject("Microsoft.XMLHTTP"); } 
      catch(oc) { req = null; } 
   } 

   // Mozailla/Safari 
   if (!req && typeof XMLHttpRequest != "undefined") { req = new XMLHttpRequest(); } 

   // Call the processChange() function when the page has loaded 
   if (req != null) {
      req.onreadystatechange = processChangeShip; 
      req.open("GET", url, true); 
      req.send(null); 
   } 
}

function processChangeShip() { 
   // The page has loaded and the HTTP status code is 200 OK 
   if (req.readyState == 4 && req.status == 200) { 
      // Write the contents of this URL to the searchResult layer 
      getObject("ship").innerHTML = req.responseText;
   }
}