// JavaScript Document
var IPRODUCTID;
function addToWishList(iProductId)
{
	IPRODUCTID	=	iProductId;
	var url = "ajax_wishlist.php?iPId=" + iProductId;
	var isWorking = false;
	if (!isWorking)
	{
		http.open("GET", url, true);
		isWorking = true;
		http.onreadystatechange = handleHttpResponse;
	  http.send(null);
  }
 return false;
}
function getHTTPObject()
{
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
  	{
  		xmlhttp=new XMLHttpRequest()
  	}
// code for IE
	else if (window.ActiveXObject)
  	{
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  	}
	return xmlhttp;
}
var http = getHTTPObject();

function handleHttpResponse()
{
	if (http.readyState == 4)
	{
    isWorking = false;
    var ResTxt = http.responseText;
    if(ResTxt == "LOGIN") {
    	window.location = "index.php?file=m-login&wish=1&iPId="+IPRODUCTID;
    	//alert("Sorry!!! Login is required for adding item into wishlist");
    }else if(ResTxt == "DUPLICATE") {
    	alert("Product already added in your wishlist");
    }else if(ResTxt == "TRY_TO_HACK") {
    	alert("Someone trying to hack your wishlist");
    }else if(ResTxt == "SUCCESS") {
    	window.location = "index.php?file=m-wishlist";
    }
  }
}

