var DELAY = 1500;
var mo = false;
var chk;
var actM = null;
var actB = null;
function getTV(obj) {
	var tVal = 0;
	while (obj!=document.body) {
		tVal += obj.offsetTop;
		obj=obj.offsetParent;
	}
	return tVal;
}
function getLV(obj) {
	var lVal = 0;
	while (obj!=document.body) {
		lVal += obj.offsetLeft;
		obj=obj.offsetParent;
	}
	return lVal;
}
function roll(obj,st) {
	obj.className = (st) ? "mm_over" : "mm_out";
}
function mmRoll(id,obj,st) {
	if (st) {
		roll(obj,st);
		mo = true;
		clearTimeout(chk);
		mCtrl(id,obj,st);
	}
	else {
		if (!id) {
			roll(obj,st);
			actB = null;
		}
		mo = false;
		chk = setTimeout("chkM()",DELAY);
	}
}
function smRoll(obj,st) {
	obj.className = (st) ? "sm_over" : "sm_out";
	mo = st;
	if (st) {
		clearTimeout(chk);
	}
	else {
		chk = setTimeout("chkM()",DELAY);
	}
}
function mCtrl(id,obj,st) {
	var bVers = navigator.appVersion.toLowerCase();
	var mXPos = 0;
	var mYPos = 0;
	cMenu();
	actB = obj;
	if (id) {	
		roll(obj,st);
		var mTbl = document.getElementById(id);
		actM = mTbl;
		var pad = obj.offsetParent.cellPadding;
		mXPos = getLV(obj) + (pad*1) + 2;
		mYPos = getTV(obj) + (obj.offsetHeight - (parseInt(pad) + 1));
		if (bVers.indexOf("mac") >= 0) {
			if (bVers.indexOf("msie") >= 0) { mXPos += 8; mYPos += 15; }
			if (bVers.indexOf("safari") >= 0) { mXPos += 6; mYPos += 15; }
		}
		mTbl.style.left = mXPos;
		mTbl.style.top = mYPos;
		mTbl.style.display = '';
	}
}
function cMenu() {
	if (actM) {
		actM.style.display = 'none';
		if (actB) {
			roll(actB,false);
		}
	}
}
function chkM() {
	if (!mo) {
		cMenu();
	}
}
function navBg(obj,st) {
	obj.style.backgroundColor = (st) ? "#e7f7c6" : "";
	obj.style.cursor = (st) ? "hand" : "pointer";
}

var lastDisp = null;

function dr(id) {
	return document.getElementById(id);
}
function chkDisp(id) {
	if (id) {
		dr(id).style.display = "none";
	}
}
function divCtrl(id) {
	if (dr(id)) {
		chkDisp(lastDisp);
		dr(id).style.display = "";
		lastDisp = id;
	}
}

function popWindow(urlName,winName,w,h,resize,scroll,toolb,loc,dir,menu,stat) {

	var winWidth = (!w || isNaN(w)) ? 640 : w;
	var winHeight = (!h || isNaN(h)) ? 400 : h;
	var allowResize = (!resize || (resize != "no" && resize != "yes")) ? "yes" : resize;
	var allowScroll = (!scroll || (scroll != "no" && scroll != "yes")) ? "yes" : scroll;
	var showMenu = (!menu || (menu != "no" && menu != "yes")) ? "no" : menu;
	var showLoc = (!loc || (loc != "no" && loc != "yes")) ? "no" : loc;
	var showDir = (!dir || (dir != "no" && dir != "yes")) ? "no" : dir;
	var showToolbar = (!toolb || (toolb != "no" && toolb != "yes")) ? "no" : toolb;
	var showStatus = (!stat || (stat != "no" && stat != "yes")) ? "no" : stat;

	thisWin = window.open(urlName,winName,'width='+winWidth+',height='+winHeight+',resizable='+allowResize+',scrollbars='+allowScroll+',menubar='+showMenu+',location='+showLoc+',directories='+showDir+',toolbar='+showToolbar+',status='+showStatus);
	thisWin.focus();
}

var newModal;

function popModal(urlName,winName,w,h,help,stat) {

	var winWidth = (!w || isNaN(w)) ? 350 : w;
	var winHeight = (!h || isNaN(h)) ? 150 : h;
	var showHelp = (!help || (help != "no" && help != "yes")) ? "no" : help;
	var showStatus = (!stat || (stat != "no" && stat != "yes")) ? "no" : stat;

	newModal = window.showModalDialog(urlName,winName,'dialogHeight:' + winHeight + 'px; dialogWidth:' + winWidth + 'px; help:' + showHelp + '; status:' + showStatus + '');
}

