﻿/* RESIZE PANEL */
function resizePanel(PanelName, hasMenu, redoOnResize) {
    var clientHeight = jQuery(window).height();
    var clientWidth = jQuery(window).width();

    //window.status = 'resizePanel() hasMenu=' + hasMenu + ' ' + clientWidth + 'x' + clientHeight;
    resizePanelTo(PanelName, hasMenu, clientWidth - 12, clientHeight);
    /*
    if (top.document.location == document.location) {
    resizePanelTo(PanelName, hasMenu, clientWidth - 12, clientHeight - 20);		
    } else {
    resizePanelTo(PanelName, hasMenu, clientWidth, clientHeight);
    }
    */
    if (redoOnResize) {
        jQuery(window).resize(function() {
            resizePanel(PanelName, hasMenu, false);
        });
    } 
}

function resizePanelTo(PanelName, hasMenu, pWidth, pHeight) {
    var panel = jQuery("#" + PanelName);
    var panelContent = jQuery("#" + PanelName + "_content");

    panelWidth = pWidth;
    contentHeight = pHeight - 46;

    if (hasMenu) contentHeight = contentHeight - 34;

    panel.width(panelWidth);

    if (pHeight > 0)
        panel.height(pHeight);

    if (panelContent != null) {
        if (panelWidth > 0)
            panelContent.width(panelWidth - 6);
        if (contentHeight > 0)
            panelContent.height(contentHeight);
    }

    if (hasMenu && panelWidth > 0) {
        var scrollwidth = panelWidth - 35;
        jQuery("#" + PanelName + "_menu").width(scrollwidth);
        jQuery("#" + PanelName + "_menu_slh").width(scrollwidth);
        jQuery("#" + PanelName + "_menubackground").width(panelWidth - 2);
    }
    //_panel_resized++;
    //alert(_panel_resized + " resizePanelTo(" + PanelName + ") " + pWidth + "x" + pHeight + "");
}

jQuery(document).ready(function() {
    jQuery(window).load(function() {
        resizePanel('ctl00_body_Panel1', false, true);
    }) 
});
jQuery(window).resize(function() {
    resizePanel('ctl00_body_Panel1', false, true); 
});

//var _panel_resized = 0;
