﻿function Default_resizePage(id) 
{
    var offsetTop = 0;
    var bPageElem = document.getElementById(id);
    
    for (var elem = bPageElem; elem != null; elem = elem.offsetParent) 
    {
        offsetTop += elem.offsetTop;
    }

    var height = Default_getWindowHeight() - offsetTop;

    if (height >= 0) 
    {
        bPageElem.style.height = height + "px";               
    }
}

function Default_getWindowHeight() 
{
    if (window.self && self.innerHeight) 
    {
        return self.innerHeight;
    }

    if (document.documentElement && document.documentElement.clientHeight) 
    {
        return document.documentElement.clientHeight;
    }

    return 0;
}

function openPopUpWindow(url, targetname, w, h)
{   
    // Set default values if parameters not provided
    if (targetname == null)
        targetname = '';
    
    if (w == null)
        w = '860px';
        
    if (h == null)
        h = '500px';    
    
	newwindow = window.open(
	    url, 
	    targetname,
	    'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + w + ',height=' + h + ''
	    );
	    
    newwindow.focus();
}

function closeWindow() {
    if (confirm("This window will close, are you sure?"))
        window.close();
}

function mouseX() 
{
    var evt = window.event;
    if (evt.pageX) 
        return evt.pageX;
    else if (evt.clientX)
        return evt.clientX + (document.documentElement.scrollLeft ?
            document.documentElement.scrollLeft :
            document.body.scrollLeft);
    else 
        return null;
}

function mouseY() 
{
    var evt = window.event;
    if (evt.pageY) 
        return evt.pageY;
    else if (evt.clientY)
        return evt.clientY + (document.documentElement.scrollTop ?
            document.documentElement.scrollTop :
            document.body.scrollTop);
    else 
        return null;
}

function hide(id)
{   
	document.getElementById(id).style.display='none';	
	document.getElementById(id).style.visibility='hidden';
}

function show(id) {
	document.getElementById(id).style.display='block';	
	document.getElementById(id).style.visibility='visible';
}
	    
// Calculates the object's absolute position, and width and height
// - use this to get exact mouse xy coordinates
function GetAbsPosition(object) 
{
    var position = new Object;
    position.x = 0;
    position.y = 0;

    if( object ) 
    {
        position.x = object.offsetLeft;
        position.y = object.offsetTop;

        if( object.offsetParent ) 
        {
            var parentpos = GetAbsPosition(object.offsetParent);
            position.x += parentpos.x;
            position.y += parentpos.y;
        }
    }

    position.cx = object.offsetWidth;
    position.cy = object.offsetHeight;

    return position;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Menu stuff
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function swapImage(imgObj, imgFile) 
{
    imgObj.src = imgFile;
}

Menu = { timer: null, current: null };
Menu.getStyle = function(name) 
{
    if (document.getElementById) return document.getElementById(name).style;
    else if (document.all) return document.all[name].style;
    else if (document.layers) return document.layers[name];
}

Menu.show = function(name) 
{    
    if (this.timer) clearTimeout(this.timer);
    this.getStyle(name).visibility = "visible";
    this.getStyle(name).display = "block";
    this.current = name;
}

Menu.hide = function() 
{
    this.timer = setTimeout("Menu.doHide()", 300);
}

Menu.doHide = function() 
{
    if (this.current) 
    {
        this.getStyle(this.current).visibility = "hidden";
        this.getStyle(this.current).display = "none";
        this.current = null;
    }
}

