﻿var bottomheight = 0;
var isLoaded = false;

function SetWidthHeight(objID,width,height)
{
    obj = document.getElementById (objID);
    obj.style .width = width + "px";
    obj.style.height = height + "px";
}

function LoadWindow(width,height)
{
    var clientHeight,clientWidth;
    clientHeight = window.document.body.clientHeight;
    clientWidth = window.document .body.clientWidth - 300;
    if(clientHeight < 900)
    {
        clientHeight = 900;
    }
    if(clientWidth < 964)
    {
        clientWidth = 966;
    }
    bottomheight = clientHeight - height - 95;
    SetWidthHeight("tbMain",clientWidth,clientHeight);
    SetWidthHeight("frmTop",width,height);
    SetWidthHeight("tdBottom",width,bottomheight);
    SetWidthHeight("frmBottom",width,bottomheight);
    SetWidthHeight("tdRight",(clientWidth -width),clientHeight);
    SetWidthHeight("frmCenter",(clientWidth - width),clientHeight - 280);
    SetWidthHeight("frmCenterTop",(clientWidth - width),280);
    isLoaded = true;
}

function ResizeWindow()
{
    isLoaded = false;
    LoadWindow(230,210);
}

function ShowCoordinate()
{
    document.title = " X:"+ event.x+" Y:"+event.y;
}



//////////////////////////////////////////////////////////////////////////////
////////////////上下文菜单相关函数/////////////////////////////////////////////


function HideContextMenuDirect()
{
    var contextmenu = document.getElementById("contextmenu");
    contextmenu.style.display='none';
}


function HideContextMenu(e){
             var contextmenu = document.getElementById("contextmenu");
//            var eventX = e.clientX;
//            var eventY = e.clientY;
            if(!e)
                e = window.event;
            //var eventX = e.clientX ? e.clientX : e.pageX;
            //var eventY = e.clientY ? e.clientY : e.pageY;
            var tempClientX = getEvtClientX(evt);
		    var tempClientY = getEvtClientY(evt);
		    
            var left = parseInt(contextmenu.style.left);
            var top = parseInt(contextmenu.style.top);
            var right = left+contextmenu.offsetWidth;
            var bottom = top+contextmenu.offsetHeight;
            var offset =0;
            
            if(!(eventX>left+offset&&
                eventY>top+offset&&
                eventX<right&&
                eventY<bottom))
            {
                     
                contextmenu.style.display='none';
                
            }
            
}


var calendarID, outColorOffset;

function _getSelfFrame(aFrameId)
{
    return window.frames ? self.frames[aFrameId] : self.document.getElementById(aFrameId).contentWindow;
}
function getTopFrameOfSelf(){ return _getSelfFrame("frmTop");}
function getCenterFrameOfSelf(){ return _getSelfFrame("frmCenter");}
function getBottomFrameOfSelf(){ return _getSelfFrame("frmBottom");}
