var xmlHttp;
var root = "http://www.latinmusicpub.com/ajax/";

function show_cart(productId) 
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	var url = root+"ajax.php?action=add_to_cart&product_id="+productId;
	xmlHttp.onreadystatechange = function() 
	{
		if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") { 
			if (xmlHttp.responseText != "fail") {
				document.getElementById("cart_content").innerHTML = xmlHttp.responseText;
				tb_show(null, "#TB_inline?height=400&width=500&inlineId=display_cart", false);
			} else {
				alert("Sorry! This feature is not currently available.");
				tb_remove();
			}
		} else {
			tb_show_loader();
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function update_cart() 
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null) {
  		alert ("Your browser does not support AJAX!");
  		return;
  	} 
	var url = root+"ajax.php?action=update_cart";
	xmlHttp.onreadystatechange = function() 
	{
		if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") { 
			if (xmlHttp.responseText != "fail") {
				document.getElementById("cart_content").innerHTML = xmlHttp.responseText;
				document.getElementById("cart_content").display = "block";
				document.getElementById("ajax_loading").display = "none";
			} else {
				alert("Sorry! This feature is not currently available.");
				document.getElementById("cart_content").display = "none";
				document.getElementById("ajax_loading").display = "block";
			}
		} else {
			document.getElementById("cart_content").display = "none";
			document.getElementById("ajax_loading").display = "block";
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}



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