﻿function setCollectionMenu(id) 
{
    xmlHttp = GetXmlHttpObject()
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!")
        return
    }
    var url = "/MenuState.aspx?CollectionMenu="+ id +"&uid=" + Math.random();
    xmlHttp.onreadystatechange = stateChanged
    xmlHttp.open("GET", url, true)
    xmlHttp.send(null)
}

function setMembersMenu(id) {
    xmlHttp = GetXmlHttpObject()
    if (xmlHttp == null) {
        alert("Your browser does not support AJAX!")
        return
    }
    var url = "/MenuState.aspx?MembersMenu=" + id + "&uid=" + Math.random();
    xmlHttp.onreadystatechange = stateChanged
    xmlHttp.open("GET", url, true)
    xmlHttp.send(null)
}

function stateChanged() {
    if (xmlHttp != null) {
        if (xmlHttp.readyState == 0) {
            //alert("0");
        }
        if (xmlHttp.readyState == 1) {
            //alert("1");
        }
        if (xmlHttp.readyState == 2) {
            //alert("2");
        }
        if (xmlHttp.readyState == 3) {
            //alert("3");
        }
        if (xmlHttp.readyState == 4) {
            // continue only if HTTP status is "OK"
            if (xmlHttp.status == 200) {
                try {
                    // retrieve the response
                   // alert("success");
                }
                catch (e) {
                    // display error message
                    //alert("Error reading the response: " +xmlHttp.responseText);
                }
            }
            else {
                // display status message
              //  alert("There was a problem retrieving the data:\n" + xmlHttp.statusText);
            }
        }
    }
} 


function GetXmlHttpObject() {
    var objXMLHttp = null
    if (window.XMLHttpRequest) {
        try {
            objXMLHttp = new XMLHttpRequest();
        }
        catch (e) {

        }
    }
    else if (window.ActiveXObject) {
        try {
            objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e1) {
            try {
                objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e2) {
            }
        }
    } else {

    }
    return objXMLHttp
} 

