﻿        var xmlhttp;
        function ReloadData(url)
        {       
            this.xmlhttp=null;
            if (window.XMLHttpRequest)
            {// code for all new browsers
                this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");//XMLHttpRequest();
            }
            else if (window.ActiveXObject)
            {// code for IE5 and IE6
                this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            if (this.xmlhttp!=null)
            {
                this.xmlhttp.onreadystatechange=state_Change;
                this.xmlhttp.open("GET",url,true);
                this.xmlhttp.send(null);
            }
            else
            {
                alert("Your browser does not support XMLHTTP.");
            }
             animatedcollapse.toggle('eventstartdate');
        } 
        
        function state_Change()
        {
            if (this.xmlhttp.readyState==4)
            {// 4 = "loaded"
            if (this.xmlhttp.status==200)
            {// 200 = OK
           
               ParseXML(this.xmlhttp.responseXML.documentElement);
            }
            else
            {
                alert("Problem retrieving XML data");
            }
          }
        }
 function ParseXML(xml)
{
    if (xml!=null)
    {
       var Error = xml.getElementsByTagName('ERROR')[0];
       
       if (Error == null || GetNodeData(Error) == "False")
       {
            var Grid = xml.getElementsByTagName('GRID')[0];

            if (Grid != null)
            {
                //alert(GetNodeData(Grid));
                document.getElementById ("ctl00_contentplaceholderMain_dvContent").innerHTML = GetNodeData(Grid);

            }
        xml = null;
     }
     else
     {
       document.getElementById ("lblError").innerText = GetNodeData(Error);
     }
    }
}
        function GetNodeData(node)
        {
            return (node.textContent || node.innerText || node.text) ;
        }

function PrepareRequest()
{
    var productdetailid = document.getElementById("productdetailid").value;
    var productid = document.getElementById("productid").value;
    
    if(productdetailid != null && productdetailid != "")
    {
        var url = "AddToCart.aspx?ProductDetailID="+ productdetailid + "&ProductID="+productid;
        ReloadData(url);
    }
}


