var xmlHttp2;

function UpdateBundle(pageElement,callMessage)
{ 

document.getElementById(pageElement).innerHTML = callMessage; 
xmlHttp2=GetXmlHttpObject2();
if (xmlHttp2==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
alert("Get Product Id");
for( i = 0; i < bundle_set.add_recommended.length; i++ ){
	if( bundle_set["add_recommended"][i].checked )
		val = bundle_set["add_recommended"][i].value;
}

//alert( "val = " + val );

var url2="ajax/updatebundle.php";
url2 = url2+"?p_id=".val
xmlHttp2.onreadystatechange=stateChanged2;
xmlHttp2.open("GET",url2,true);
xmlHttp2.send(null);
}

function stateChanged2() 
{ 
if (xmlHttp2.readyState==4)
{ 
document.getElementById("bundle_offer").innerHTML=xmlHttp2.responseText;
}
}

function GetXmlHttpObject2()
{
var xmlHttp2=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp2=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp2;
}

var http_request = false;
function makeRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) { // IE
	 try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!http_request) {
	 alert('Cannot create XMLHTTP instance');
	 return false;
  }
  http_request.onreadystatechange = alertContents;
  http_request.open('GET', url + parameters, true);
  http_request.send(null);
}

function alertContents() {
  if (http_request.readyState == 4) {
	 if (http_request.status == 200) {
		//alert(http_request.responseText);
		result = http_request.responseText;
		document.getElementById('bundle_offer').innerHTML = result;            
	 } else {
		alert('There was a problem with the request.');
	 }
  }
}
   

function get(obj,product_id,product_name,bundle) {

      //var getstr = "?";
	  var proid;
      for (i=0; i<obj.childNodes.length; i++) {
         if (obj.childNodes[i].tagName == "INPUT") {
            if (obj.childNodes[i].type == "hidden") {
               //getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
			   proid=obj.childNodes[i].value;
            }
         }        
      }
	  //getstr += "customer_id=" +customer_id;
	  add_cart(proid,bundle);
	  /*//alert(getstr);
      makeRequest('updatebundle.php', getstr);
	  //alert('update');
	  */document.getElementById('des_bun').innerHTML = "You have added "+product_name+" to cart."; 
	  /*document.getElementById('bundle_offer').innerHTML = '<center><img src=images/loading.gif></center>'; 
	  document.getElementById('item_box').innerHTML = '<center><img src=images/loading.gif></center>'; 
	  showBundle(bundle_id,p_set,'bundle_offer','<center><img src=images/loading.gif></center>',customer_id,product_id);
	  //window.setTimeout("showBundle("+bundle_id+","+p_set+",'bundle_offer','<center><img src=images/loading.gif></center>',"+customer_id+","+product_id+")",1000);
	  //window.setTimeout("showShopCart('item_box','<center><img src=images/loading.gif></center>',"+customer_id+")",3000);
	  showShopCart('item_box','<center><img src=images/loading.gif></center>',customer_id);*/
}