var XML = 'XML';
var HTML = 'HTML';
function getXmlHttpRequestObject() {
	var xmlhttp;
	try {
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	}
	catch(e) {
		try {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(f) { 
			xmlhttp=null; 
		}
	}
	if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
		xmlhttp=new XMLHttpRequest();
	}
	return  xmlhttp;
}

function MakeRequest(pUrl,pParams,pOutput) {
	MakeRequestHTML(pUrl,pParams,pOutput);
}

function MakeRequest(pUrl,pParams,pType,pOutput) {
	if(XML = pOutput) {
		MakeRequestXML(pUrl,pParams,pOutput);
	} else {
		MakeRequestHTML(pUrl,pParams,pOutput);
	}
}

function MakeRequestXML(pUrl,pParams,pOutput) {
	
}

function MakeRequestHTML(pUrl,pParams,pOutput) {
	var rnd = Math.random();
	http = getXmlHttpRequestObject();
	//alert(pOutput);
	try {
		http.open('POST',  pUrl);
		http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		http.onreadystatechange = function() {
			vTargetDiv = pOutput;
			//handle response
			try {
				if((http.readyState == 4)&& (http.status == 200)){
    				responseText = http.responseText;
      				document.getElementById(vTargetDiv).innerHTML = responseText;
      				
      				if('cart_summary' == vTargetDiv) {
      					//alert('Cart Updated Successfully');
      					$('cart_updated').style.display = 'block';
      				}
				}
			}
			catch(ex) {
				alert('Error Retrieving AJAX response. [' + vTargetDiv + '] ' + ex.description);
			}
		};
		http.send(pParams + '&rnd='+rnd + '&request_type=ajax');
	}
	catch(e){
		alert('Error making AJAX request.');
	}	
}

function $(pId) {
	return document.getElementById(pId);
}