function ShowHideUserPanel() {
    //hide panels
    var display = document.getElementById("userPanel").style.display;
    if (display == "none") {
        //show panel
        document.getElementById("userPanel").style.display = "";
        TooglePanel("1");

        //change images
        document.getElementById("imdHeader1").src = "style/images/left_nav_login.jpg";
        document.getElementById("imdHeader2").src = "style/images/right_nav_login.jpg";
    }
    else {
        //hide panel
        document.getElementById("userPanel").style.display = "none";

        //change images
        document.getElementById("imdHeader1").src = "style/images/left_nav.jpg";
        document.getElementById("imdHeader2").src = "style/images/right_nav.jpg";
        TooglePanel("0");
    }
    return false;
}

function ShowHideUserPanel2(imgUrl) {
    //hide panels
    var display = document.getElementById("userPanel").style.display;
    if (display == "none") {
        //show panel
        document.getElementById("userPanel").style.display = "";
        TooglePanel("1");

        //change images
        document.getElementById("imdHeader1").src = imgUrl + "left_nav_login.jpg";
        document.getElementById("imdHeader2").src = imgUrl + "right_nav_login.jpg";
    }
    else {
        //hide panel
        document.getElementById("userPanel").style.display = "none";

        //change images
        TooglePanel("0");

        //change images
        document.getElementById("imdHeader1").src = imgUrl + "left_nav.jpg";
        document.getElementById("imdHeader2").src = imgUrl + "right_nav.jpg";
    }
    return false;
}

function SetTbxState(comboId, txtId, value) {
    var cboVal = document.getElementById(comboId);
    document.getElementById(txtId).disabled = cboVal.options[cboVal.selectedIndex].value != value;
}

function DoClick(objId, allId) {
    var chkObj = document.getElementById(objId);
    var allObj = document.getElementById(allId);
    var currentObj;
    var chkList = document.getElementById("chkList");
    var inputList = chkList.getElementsByTagName("INPUT");
    if (objId == allId) {
        for (var i = 0; i < inputList.length; i++) {
            currentObj = inputList[i];
            if (currentObj.type == "checkbox" && currentObj.id != allId) {
                currentObj.checked = allObj.checked;
            }
        }
        return;
    }
    else {
        var selected = true;
        for (var i = 0; i < inputList.length; i++) {
            currentObj = inputList[i];
            if (currentObj.type == "checkbox" && currentObj.id != allId) {
                selected = selected && currentObj.checked;
            }
        }
        allObj.checked = selected;
    }
}

function ShowHideContent(chaptersContent, contentState) {

    var contentStateSpan = document.getElementById(contentState);
    var showHideDiv = document.getElementById(chaptersContent);
    var display = showHideDiv.style.display;

    if (display == "none") {

        showHideDiv.style.display = "";
        contentStateSpan.innerHTML = _hide;


    }
    else {

        showHideDiv.style.display = "none";
        contentStateSpan.innerHTML = _show;

    }

}
function ShowHide(objectId) {
    var obj = document.getElementById(objectId);
    var display = obj.style.display;

    if (display == "none") {
        obj.style.display = "";
    }
    else {

        obj.style.display = "none";
    }

}

function OnKeyDown() {
    if (window.event.keyCode == 13) {
        event.returnValue = false;
        event.cancel = true;
    }
}
function setFocusFunction(ctrl_client_Id, aEvent) {

    var myEvent = aEvent ? aEvent : window.event; 
    if (myEvent.keyCode == 13) {
        var ctrl = null;
        ctrl = document.getElementById(ctrl_client_Id);
        ctrl.focus();
        ctrl.click();
    }
}
function canSearch(aEvent) {
    var myEvent = aEvent ? aEvent : window.event;
    if (myEvent.keyCode == 13) {
        return true;
    }
    return false;
}

function enlargeImage(Url, width, height) {
    var prevW = window.open("", null, "width=" + width + ",height=" + height + ",top=140,left=200,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
    prevW.document.write('<html><body onclick="window.close()"><a style="cursor:pointer"><img style="border: 0px; padding: 0px;" src="' + Url + '" width="' + width + '" height="' + height + '" /></a></body></html>');
    prevW.document.close()
}

function enlargeImage2(Url) {
    var attributeName = '';
    var myWidth = 0, myHeight = 0;
    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        attributeName = 'window.innerWidth';
        attributeName = 'window.innerHeight';
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        attributeName = 'document.documentElement.clientWidth';
        attributeName = 'document.documentElement.clientHeight';
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        attributeName = 'document.body.clientWidth';
        attributeName = 'document.body.clientHeight';
    }

    var prevW = window.open("", null, "width=200,height=200, top=10,left=10,toolbar=no,location=0,directories=0,status=0,menubar=no,scrollbars=no,resizable=1");
    prevW.document.write('<html><head><script type="text/javascript">');
    prevW.document.write('function ResizeWindow(img){ window.resizable = true; window.resizeTo(img.width, img.height + 10); }');
    prevW.document.write('</script></head><body style="margin:0px;padding:0px;" onclick="window.close();"><a style="cursor:pointer"><img onload="ResizeWindow(this)" style="border: 0px; padding: 0px;" src="' + Url + '" /></a></body></html>');
    //prevW.document.write('<html><body onclick="window.close()"><a style="cursor:pointer"><img id="img_small" style="border: 0px; padding: 0px;" src="' + Url + '" /></a></body></html>');
    prevW.document.close()

    //alert(window.height);
}