﻿function dockUndock(navigationPanel, dockHidden, contentPanel, dockHeaderRight, url) {
    var div = document.getElementById(navigationPanel);
    var hid = document.getElementById(dockHidden);
    var content = document.getElementById(contentPanel);
    var right = document.getElementById(dockHeaderRight);
    if (hid != null) {
        if (hid.value == 'open') {
            //era aperto quindi lo chido
            div.style.visibility = 'hidden';
            right.style.visibility = 'visible';
            content.style.margin = '0 0 0 40px';
            hid.value = "closed";
        }
        else if (hid.value == 'closed') {
            //era chiuso quindi lo apro
            div.style.visibility = 'visible';
            right.style.visibility = 'hidden';
            content.style.margin = '0 0 0 210px';
            hid.value = "open";
        }
        else {
            //invisibile (quando un'utente non è loggato)
            div.style.visibility = 'hidden';
            right.style.visibility = 'hidden';
            content.style.margin = '0 0 0 0px';
        }
        AjaxGetData(url + '?dockHidden=' + hid.value);  //div.style.visibility);
    }
    
    content.style.display = 'none';
    content.style.display = 'block';
}

function AjaxGetData(url) {
    if (window.XMLHttpRequest) {
        // browser has native support for XMLHttpRequest object 
        req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        // try XMLHTTP ActiveX (Internet Explorer) version 
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (req) {
//        req.onreadystatechange = responseHandler;
        req.open('GET', url, true);
        req.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        req.send('');
    }
    else {
        alert('Your browser does not seem to support XMLHttpRequest.');
    }
}
