﻿function blankLoad(){}
function scrollToBottom() { window.scrollBy(0,5000) }
function openMsg(url) { window.open(url, "MessageWindow", "resizable=1, scrollbars=1, height=325, width=550"); }
function sendTo(url) { window.location = url; }
function changeBG(item, bgColor) { item.style.backgroundColor = bgColor; }
function setFocus(elementId) { document.getElementById(elementId).focus(); }
function swapClass(element, newClass) { element.className = newClass; }
function noClass(element) { element.className = ''; }

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function showTip(id, inputObj)
{
    var panel = document.getElementById(id);
    panel.style.display = panel.style.display != 'block' ? 'block' : 'none';
    panel.style.position = 'absolute';
    
    var coords = findPos(inputObj);
    panel.style.left = coords[0] + 125 + 'px';
    panel.style.top = coords[1] + 3 + 'px';
}

// A general function to add an event handler
function addHandler(obj, evt, newhandler, captures) {
	if (obj.attachEvent) { obj.attachEvent('on' + evt, newhandler); }
	else if (obj.addEventListener) { obj.addEventListener(evt, newhandler, captures); }
	else {
		var oldhandler;
		if (oldhandler = obj['on' + evt]) {
			obj['on' + evt] = function() {
				oldhandler();
				newhandler();
			}
		}
		else { obj['on' + evt] = newhandler; }
	}
}

var fixHeightOnOff = true;
function fixHeightTrue() { fixHeightOnOff = true; }
function fixHeightFalse() { fixHeightOnOff = false; }

function fixHeight() {
    var obj = document.getElementById('centerDiv');
    if (fixHeightOnOff == false) {
        obj.style.height = 'auto';
    }
    else {
        if (obj.offsetHeight < 400) {
            obj.style.height = '400px';
        }
    }
}

if (document.getElementById) { addHandler(window,'load',fixHeight,false); }
