function getHTTPObject() 
{
    var xmlhttp;

    if(window.XMLHttpRequest)
        xmlhttp = new XMLHttpRequest();
    else if (window.ActiveXObject)
    {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        if (!xmlhttp)
            xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    return xmlhttp; 
}

var http = getHTTPObject(); // We create the HTTP Object

jQuery(function()  
{ 
  jQuery('.addtocartmessage').click(function(e)
  {
    //getting height and width of the message box
    var height = jQuery('#popup_div').height();
    var width = jQuery('#popup_div').width();
    //calculating offset for displaying popup message
    leftVal=e.pageX-((width/2)+(100))+"px";
    topVal=e.pageY-(height/2)+"px"; 
    //show the popup message and hide with fading effect
    jQuery('#popup_div').css({left:leftVal,top:topVal}).show();

	setTimeout(function(){
		jQuery('#popup_div').fadeOut(1500);
			},2000);
    });    
}); 

function addToCart(PID, CID)
{
    var q=document.getElementById('q_' + PID).value;
    var params = 'o=a&p=' + PID + '&c=' + CID + '&q=' + q;
    
    http.open("POST", 'http://www.mypartyfavors.com/product.asp', true);

    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");

    http.onreadystatechange = function()
    {
	    if(http.readyState == 4 && http.status == 200)
	    {
	    }
    }
    http.send(params);
    return false;
}
