// JavaScript Document



var xmlHttp;

function addCart(id, name, qty, task, prodid, price)
{

xmlHttp=GetXmlHttpObject();



if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="Ajax_shoppingcart.php";
url=url+"?id="+id;
url=url+"&qty="+qty;
url=url+"&task="+task;
url=url+"&sid="+Math.random();

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);


	if(task == 'add') {

		
		document.getElementById("POPName").innerHTML = name;
		document.getElementById("POPItem").innerHTML = id;
		document.getElementById("POPQty").innerHTML = qty;
		if(price) {
			if(id == 'RCP402S-R'){
			document.getElementById("POPPrice").innerHTML = '$'+price+ ' Free Shipping';
			} else {
					document.getElementById("POPPrice").innerHTML = '$'+price;
			}
		} else {
			document.getElementById("POPPrice").innerHTML = '';
		}
		document.getElementById("POPCartImg").innerHTML = '<img src="support/product_images/part_num_med/'+ id +'.jpg" />';
		if(prodid == '1010'){
		document.getElementById("POPMESSAGE").innerHTML = '<strong>Note:</strong> A thermostat is required for all baseboards.';
		}else if(prodid == '1004'){
		document.getElementById("POPMESSAGE").innerHTML = '<strong>Note:</strong> A thermostat is required for all baseboards.';
		}else if(prodid == '1012'){
		document.getElementById("POPMESSAGE").innerHTML = '<strong>Note:</strong> A 240 outlet is required.';
		}else if(prodid >= '1016' && prodid <='1020' ){
		document.getElementById("POPMESSAGE").innerHTML = '';
		} else if(prodid >= '1022' && prodid <='1033' ){
		document.getElementById("POPMESSAGE").innerHTML = '';
		} else if(prodid = '9999'){
		document.getElementById("POPMESSAGE").innerHTML = '';
		}else {
		document.getElementById("POPMESSAGE").innerHTML = '<strong>Note:</strong> For new installation, a wall can, grill, and thermostat are required.';
		}
		
	popup_show('popup', 'popup_drag', 'popup_exit', 'screen-center', 550,  0,   0);
	}
} 


function stateChanged()
{ var myArray1;
if (xmlHttp.readyState==4)
  {// 4 = "loaded"
  if (xmlHttp.status==200)
    {// 200 = OK
   var myArray = xmlHttp.responseText;
   if(myArray.split("|" , 2)){
   myArray1 = myArray.split("|" , 2);
   } else {
	    myArray1 = '';
   }
 	if(!myArray1[1])
	{
		myArray1[1] = myArray1[0];
		myArray1[0] = '';
		document.getElementById("col_cart").style.height = 270 + "px";
	}
	else
	{
	document.getElementById("col_cart").style.height = 270 + "px";
	}
	
	document.getElementById("TestCart").innerHTML = myArray1[1];
	document.getElementById("POPKART").innerHTML = myArray1[0];
	
  }
  else
    {
    alert("Problem retrieving XML data");
    }
  }
}







