﻿function BodyHeightSet() 
{ 
    var Tab = document.getElementById("MainTable");
    var Header = document.getElementById("Header");
    var Spacer1 = document.getElementById("Spacer1");
    var NavTopX = document.getElementById("NavTopX");
    var Spacer2 = document.getElementById("Spacer2");
    var Workspace = document.getElementById("Workspace");
    var LeftColumn = document.getElementById("LeftColumn");
    var LeftColumnMain = document.getElementById("LeftColumnMain");
    var Sponsor = document.getElementById("Sponsor");
    ClientHeight = window.innerHeight?window.innerHeight:document.documentElement.clientHeight;
    ClientHeight -=25;
    Tab.style.height = ClientHeight.toString() + "px";
    HeaderHeight = Header.style.height.replace("px","");
    HeaderHeight = parseInt(HeaderHeight,10)
    Spacer1Height = Spacer1.style.height.replace("px","");
    Spacer1Height = parseInt(Spacer1Height,10)
    NavTopXHeight = NavTopX.style.height.replace("px","");
    NavTopXHeight = parseInt(NavTopXHeight,10)
    Spacer2Height = Spacer2.style.height.replace("px","");
    Spacer2Height = parseInt(Spacer2Height,10)
    if (Sponsor)
    {
        SponsorHeight = Sponsor.style.height.replace("px","");
        SponsorHeight = parseInt(SponsorHeight,10)
        WorkspaceHeight = ClientHeight - HeaderHeight - Spacer1Height - NavTopXHeight - Spacer2Height - SponsorHeight ;
    }
    else
        WorkspaceHeight = ClientHeight - HeaderHeight - Spacer1Height - NavTopXHeight - Spacer2Height ;
    var RightColomn = document.getElementById("RightColumn");
    if (RightColomn)
    {
        if (Sponsor)
        {
            if ((RightColomn.offsetHeight - SponsorHeight) > WorkspaceHeight)
            WorkspaceHeight = RightColomn.offsetHeight - SponsorHeight;
        }
        else
        if (RightColomn.offsetHeight > WorkspaceHeight)
            WorkspaceHeight = RightColomn.offsetHeight
    }
    
    /*
    if (LeftColumn) 
    {
        LeftColumn.style.height = Workspace.style.height;
        var LeftColumnItem = document.getElementById("LeftColumnItem");
        LeftColumnItemHeight = WorkspaceHeight - 85;
        LeftColumnItem.style.height = LeftColumnItemHeight.toString() + "px";
    }
    */
    if (LeftColumnMain)
    {
        LeftColumnMainHeight = LeftColumnMain.offsetHeight;
        if (LeftColumnMainHeight >  WorkspaceHeight)
            WorkspaceHeight = LeftColumnMainHeight;
    }
    Workspace.style.height = WorkspaceHeight.toString() + "px";
} 

function GoNext(url, type)
{  
    GoNextAdv(url, type, "");
}
function GoNextAdv (url, type, NewWindow)
{
    
    var Workspace = document.getElementById("Workspace");
    var Height = parseInt(Workspace.style.height.replace("px",""),10);
    /*
    
    var RightColomn = document.getElementById("RightColumn");
    if (RightColomn)
    {
        if (RightColomn.offsetHeight < Height)
            Height = RightColomn.offsetHeight
    }
    var Sponsor = document.getElementById("Sponsor");
    if (Sponsor)
    {
        SponsorHeight = parseInt(Sponsor.style.height.replace("px",""),10)
        Height += SponsorHeight;
    }
    
    url += "&Height=" + Height + "px";
    */

    if (type!="0")
        url += "&Height=" + document.getElementById("RightColumn").offsetHeight + "px";
    
    if (typeof(type)=="undefined")
        location.href = url;
    else
    {
        if (type==0)
            openWindow(url);
        else
        {
            var WRMain = document.getElementById("WRMain");
            if (WRMain)
            {
                search = "url=";
                pos = url.indexOf(search);
                if (pos>0)
                {
                    pos = pos + search.length;
                    url = url.substr(pos);
                }
                WRMain.src = unescape(url);
                WRMain.style.height = Height + "px";
                
            }
            else
                location.href = url;
         }
    }
}

function openWindow(url)
{
    var theWindow = window.open(url,"_new","toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=800, height=600, top=0, left=0");
    theWindow.focus();
}

