// Global Variable //
var xmlHttp = null;
//--------------------------------------//
//Start Ajax Cod .
//--------------------------------------//

function Create()
{
   if (window.ActiveXObject)
   {
      xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');//Internet Explorer 6 And Previous versions.
   }
   else
   {
      xmlHttp=new XMLHttpRequest();//All Of Browser Except Internet Explorer 6 And Previous versions.
   }     
   return xmlHttp;
}
	
function AjaxSendFunc(info,ac,pr_id)//Main Function.
{	
    Create();
    xmlHttp.open('GET',"ajaxResponse.php"+info,true);
    xmlHttp.onreadystatechange= function()//is Not == "update" In the Top sentence!
    {
		if(xmlHttp.readyState==4)
    	{
    		if(xmlHttp.status==200)
    		{
    			var result = xmlHttp.responseText;
				if(result != "No")
				{	   
					if(ac=="add_to_cart")
					{	
						//alert("come in here");
	           			$("#cart_info").html("( سبد خرید ("+ result +" مورد ");
	           			$("#add_to_cart"+pr_id).hide();
	           			$("#in-cart-now"+pr_id).show();
	           			
					}			
				}
				else
				{
					alert("در حال حاضر به علت وجودی مشکلی در سرور قادر به پاسخ گویی نیستیم.");
				}
			}			
			else
			{
	    		alert('هیچ پاسخی از سمت سرور دریافت نشد.');
			}
		}
	}
xmlHttp.send(null);
}

function add_p_to_cart(id)
{
	AjaxSendFunc("?req_id=1&pr_id="+id,"add_to_cart", id);
}


//--------------------------------------//
//End Ajax Code .
//--------------------------------------//
