﻿function loader(id){
   document.getElementById(id).style.display = "";
   return true;
}
function delete1(msg,id){
    if(confirm(msg)==true){
        document.getElementById(id).style.display = "";
        return true;  
    }
    return false;
}
var xmlHttp
var indiCatorId="";
var lblId ="";
var prName="";
function addToCart(id,Product_ID,Page,lbl,pName,catID){
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null){
        alert ("Browser does not support HTTP Request")
        return
     }
     if (lbl!=''){
        lblId=lbl;
        document.getElementById(lblId).innerHTML="";
     }
     prName=pName;
    indiCatorId=id;
    document.getElementById(id).style.display="";            
    var url=Page;
    url=url+"?PrdID="+Product_ID;
    url=url+"&CtgID="+catID;
    url=url+"&mid="+Math.random();
    xmlHttp.onreadystatechange=cartAdded;
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}
function cartAdded(){ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    document.getElementById(indiCatorId).style.display="none";
    var res = "";
    res= xmlHttp.ResponseText;
    if (res=="0"){
        if(lblId!=''){
           document.getElementById(lblId).innerHTML=""; 
        }
      alert("There is no more quantity available for the product ")  
    }else{
        if(lblId!=''){
            document.getElementById(lblId).innerHTML=prName.replace("~","'")+ " has been added to cart"; 
        }
    }
 } 
}


/*************************************sponsor clicks********************************************************/
function addToSponsors(id,Page,uri){
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null){
        alert ("Browser does not support HTTP Request")
        return
     }
     var url=Page;
    url=url+"?id="+id;
    url=url+"&uri="+uri;
    url=url+"&type=0";
    url=url+"&mid="+Math.random();
    xmlHttp.onreadystatechange=clickAdded;
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}
function clickAdded(){ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
   
 } 
}
/*************************************sponsor clicks********************************************************/
/*************************************banner clicks********************************************************/
function addToBannerClicks(id,Page,uri,bannerType){
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null){
        alert ("Browser does not support HTTP Request")
        return
     }
     var url=Page;
    url=url+"?id="+id;
    url=url+"&uri="+uri;
    url=url+"&type="+bannerType;
    url=url+"&mid="+Math.random();
    xmlHttp.onreadystatechange=clicksAdded;
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}
function clicksAdded(){ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
   
 } 
}
/*************************************banner clicks********************************************************/

/*************************************Promotion clicks*****************************************************/
function addToPromotionClicks(id,Page,uri){
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null){
        alert ("Browser does not support HTTP Request")
        return
     }
     var url=Page;
    url=url+"?id="+id;
    url=url+"&uri="+uri;
    url=url+"&P=Promotion";
    url=url+"&mid="+Math.random();
    xmlHttp.onreadystatechange=clicksAddeds;
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
}
function clicksAddeds(){ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
   
 } 
}
/****************************************Promotion clicks****************************************************/





function GetXmlHttpObject(){
    var xmlHttp=null;
    try{
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }catch (e){
         //Internet Explorer
         try{
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }catch (e){
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
        return xmlHttp;
}
