function postRequest(strURL){
          var xmlHttp;
            if(window.XMLHttpRequest){ // For Mozilla, Safari, ...
             xmlHttp = new XMLHttpRequest();
               }
              else if(window.ActiveXObject){ // For Internet Explorer
                 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }
                    xmlHttp.open('POST', strURL, true);
                    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    xmlHttp.onreadystatechange = function(){
                       if (xmlHttp.readyState == 4){
                           updatepage(xmlHttp.responseText);
                        }
                    }
                    xmlHttp.send(strURL);
               }
               
function updatepage(str){	
	//document.getElementById('result').value = str;
	if(str!='error'){
		document.getElementById("mydiv").className="mydiv";
		document.getElementById("message").className="messageloading";
		document.getElementById("cartqty").innerHTML=str+" items";
		setTimeout("stopmessage()",1000);					
	} else {
		document.getElementById("mydiv").className="mydiv";
		alert("Error..");
	}	
}
               
 function addtocart(id,email,affid,e) {
	var u="";
	if(email=="") {
		alert("You must login..");
		if(affid!=""){
			u="affiliate="+affid;	
			
		}
		document.location.href='Skin1UserLogin.php?'+u;
		return;
	}
// **************************************getting mouse postion*************************************************
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
// *************************************************** end ***************************************************************			
	if(posy==""){ posy=500;}
	document.getElementById("Layer1").style.display = '';
	document.getElementById('Layer1').style.left=450+"px";
	document.getElementById('Layer1').style.top=posy-100+"px";
	document.getElementById("mydiv").className = "mydivloading";
	var p_id =id; 
	var u_email=email;
	var url = "index.php?cart&prd_id=" + p_id + "&user_email=" + u_email + "&affiliate="+affid+" ";
	postRequest(url);
	//document.getElementById("Layer1").style.display = 'none';
}
	  
function stopmessage() {
	document.getElementById("message").className="message";   
}
function buyProduct(pid,affurl,username){
	var args=pid+affurl;
	if(username==""){
		alert("You must login");
		document.location.href="Skin1UserLogin.php?"+affurl+"";
	}else{
		document.location.href='index.php?buy&prd_id='+args+'';
	}
	
}
			   