function addClickFunction(id) {{
    var b = document.getElementById(id);
    if (b && typeof(b.click) == 'undefined') b.click = function() {{
        var result = true; if (b.onclick) result = b.onclick();
        if (typeof(result) == 'undefined' || result) {{ eval(b.getAttribute('href')); }}
    }}}};
    

    function ToggleCartList() {
        var url = "/handlers/CartToggleHandler.ashx";

        InitXmlHttp();
        xmlhttp.open("GET", url, true);
        xmlhttp.send(null);
    }

    function InitXmlHttp() {
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {

            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (E) {
                xmlhttp = false;
            }
        }

        if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
            xmlhttp = new XMLHttpRequest();

        xmlhttp.onreadystatechange = XMLHttpRequestCompleted;
    }


    function XMLHttpRequestCompleted() {
        if (xmlhttp.readyState == 4 || xmlhttp.readyState == "complete") {
            try {
                var _returnValue = xmlhttp.responseText;
            }
            catch (e) {
            }
        }
    }

    function onUpdating(loadingImg, controlsToHide) {
        // get the update progress div
        var updateProgressDiv = document.getElementById(loadingImg);
        // make it visible
        updateProgressDiv.style.display = '';

        var type = typeof (myArray);
        // fetch invisible controls
        for (var i = 0; i < controlsToHide.length; i++)
        {
            var hideControl = document.getElementById(controlsToHide[i]);
            // hide
            hideControl.style.display = 'none';
        }

        // set timer
        //setTimeout("onUpdateTimeout(\'"+loadingImg+"\', \'"+hideControl1Name+"\', \'"+hideControl2Name+"\', \'"+hideControl3Name+"\')", 10000);
    }

//    function onUpdateTimeout(loadingImg, hideControl1Name, hideControl2Name, hideControl3Name) {
//        // get the update progress div
//        var updateProgressDiv = document.getElementById(loadingImg);
//        var hideControl1 = document.getElementById(hideControl1Name);
//        var hideControl2 = document.getElementById(hideControl2Name);
//        var hideControl3 = document.getElementById(hideControl3Name);
//        
//        // hide it
//        updateProgressDiv.style.display = 'none';
//        
//        // show the controls
//        hideControl1.style.display = '';
//        hideControl2.style.display = '';
//        hideControl3.style.display = '';
//    }
    
//    var prm = Sys.WebForms.PageRequestManager.getInstance();
//    //prm.add_initializeRequest(initializeRequest);
//    prm.add_endRequest(endRequest);

//    function initializeRequest(sender, args)
//    {
//        //args.set_cancel(!confirm('Are you sure?'));
//    }

//    function endRequest(sender, args) {
//        var error = args.get_error();
//        if (error != null) {
//            var errorName = error.name;
//            if (errorName.length > 0) {
//                args.set_errorHandled(true);
//                alert(error.name);
//                //ToggleAlertDiv('visible');
//                //$get(messageElem).innerHTML = 'The panel did not update successfully.';
//            }
//        }
//    }