//function to relayout the page when resized
function findHeight(masterPageName) 
{
    var scrollHeight = 0;
    var hasRibbon = false; 
    var hasNavigation = false; 
    var hasToDo = false; 
    var contentDiv = 0; 
    var navigationDiv = 0; 
    var rightDiv = 0;
    var footerButtons = 50;
    switch (masterPageName.toLowerCase())
    {
        case "default":
            scrollHeight = 157;
            contentDiv = 42;
            navigationDiv = 20;
            rightDiv = 20;
            hasRibbon = true;
            hasNavigation = false;
            hasToDo = false;
            footerButtons = 250;
            break;
        case "forecasting":
            scrollHeight = 157;
            contentDiv = 42 + 0;
            navigationDiv = 20;
            rightDiv = 20;
            hasRibbon = false;
            hasNavigation = true;
            hasToDo = true;
            footerButtons = 250;
            break;
        case "fulllayout":
            scrollHeight = 157;
            contentDiv = 60 + 32;
            navigationDiv = 20;
            rightDiv = 20;
            hasRibbon = false;
            hasNavigation = false;
            hasToDo = false;
            footerButtons = 50;
            break;
        case "guestlayout":
            scrollHeight = 157;
            contentDiv = 50;
            navigationDiv = 20;
            hasRibbon = false;
            hasNavigation = true;
            hasToDo = false;
            footerButtons = 50;
            break;
        case "historical":
            scrollHeight = 157;
            contentDiv = 42 + 0;
            navigationDiv = 20;
            rightDiv = 20;
            hasRibbon = false;
            hasNavigation = true;
            hasToDo = true;
            footerButtons = 250;
            break;
        case "scenarioplanning":
            scrollHeight =205;
            contentDiv = 42 + 0;
            navigationDiv = 64;
            window.status = document.getElementById("scenarioHeader").offsetHeight + " px";
            rightDiv = 0;
            hasRibbon = false;
            hasNavigation = true;
            hasToDo = false;
            footerButtons = 20;
            break;
        case "billing":
            scrollHeight = 157;
            contentDiv = -25;
            navigationDiv = 0;
            rightDiv = 0;
            hasRibbon = false;
            hasNavigation = false;
            hasToDo = false;
            footerButtons = 0;
            break;   
    }
    
    //set footer buttons position
    if (document.getElementById('footerButtons'))
    {
        document.getElementById('footerButtons').style.right = footerButtons + "px";
    }
    
    //remove the required hight
    scrollHeight = document.body.clientHeight - scrollHeight;
    
    //reset to minimum if needed
    if (scrollHeight < 197)
    {
        scrollHeight = 197;
    }
       
    //Content Pane 
    document.getElementById("contentCell").style.height = scrollHeight+"px";  
    document.getElementById("ContentDiv").style.height = ((scrollHeight + 20) - contentDiv) +"px";
    
    //Navigation Pane
    if (hasNavigation)
    {
        document.getElementById("NavigationCell").style.height = scrollHeight+"px"; 
        document.getElementById("NavigationDiv").style.height = (scrollHeight + navigationDiv) +"px";  
    }
    
    //Help Pane
    if (hasToDo)
    {
        document.getElementById("rightCell").style.height = scrollHeight+"px"; 
        document.getElementById("rightDiv").style.height = scrollHeight + rightDiv +"px";
    }
    
    resetTabs();
}
function mainAjaxPanel_ResponseStart(sender, args)
{
}
function mainAjaxPanel_ResponseEnd(sender, args)
{
    var onload = "";
    
    if (document.body.attributes["onload"].value != 'null')
    {
        onload = document.body.attributes["onload"].value;
    }
    else
    {  
        onload = document.body.onload.toString()
    }
    
    if (onload != null && onload != "")
    {
        var funcText = onload;
        funcText = funcText.substring(funcText.indexOf("findHeight('")+12);
        funcText = funcText.substring(0,funcText.indexOf("'"));
        
        findHeight(funcText);
        
        resetTabs();
    }
}
function PopupAbove(e, dateControlName)
{ 
    var datePicker = $find(dateControlName);
    var popupElement = datePicker.get_popupContainer();
    var dimensions = datePicker.getElementDimensions(popupElement);
    var position = datePicker.getElementPosition(document.getElementById(dateControlName));
    datePicker.showPopup(position.x, position.y - dimensions.height);   
}        
function resetTabs()
{
    var width = parseInt(document.getElementById("bannerTabs").clientWidth);
    width += 500;        
    document.getElementById("bannerTabs").style.width = width + "px";
}              
function ResetForm()
{
    document.forms[0].reset();
    return false;
}                       
