onerror = handleErrors;

var errMsg = null;
var errNum = 0;

function handleErrors(errTxt, errUrl, errLine) {
	var brwz,tyme,dest,i,fn,pn;
	if ((i = errTxt.indexOf('Unspecified error')) >= 0) {
		return true;
	}
	// test for non site-related urls
	// i.e., chrome://skype_ff_toolbar_win/content/injection_graph_func.js
	if (testErrURL(errUrl) == true) {
		brwz = navigator.userAgent;
		if ((i = errTxt.indexOf('Error loading script')) >= 0) {
			if ((i = brwz.indexOf('Firefox/')) >= 0) {
				return true;
			}
		}
		if ((i = errTxt.indexOf('is not defined')) >= 0) {
			if (errNum == 0) {
				errNum += 1;
				return true;
			}
		}
	}
	else {
		brwz = navigator.userAgent;
		tyme = getLocalTime();
		fn = '';
		pn = '';
		if (document.frmAddEdit) {
			if (document.frmAddEdit.CurrentFormName) {
				fn = document.frmAddEdit.CurrentFormName.value;
				if (document.frmAddEdit.CurrentFormID) {
					fn = fn + ' (' + document.frmAddEdit.CurrentFormID.value + ')';
				}
			}
			if (document.frmAddEdit.CurrentPageName) {
				pn = document.frmAddEdit.CurrentPageName.value;
				if (document.frmAddEdit.CurrentPageID) {
					pn = pn + ' (' + document.frmAddEdit.CurrentPageID.value + ')';
				}
			}
		}
		else {
			if (document.frmWorking) {
				if (document.frmWorking.CurrentFormName) {
					fn = document.frmWorking.CurrentFormName.value;
					if (document.frmWorking.CurrentFormID) {
						fn = fn + ' (' + document.frmWorking.CurrentFormID.value + ')';
					}
				}
			}
		}
		dest = '/error/jsError.asp?msg='+encodeURI(errTxt)+'&url='+encodeURI(errUrl)+'&line='+errLine+'&brwz='+encodeURI(brwz)+'&tyme='+encodeURI(tyme)+'&frm='+encodeURI(fn)+'&pg='+encodeURI(pn)+'&err=1&pop=Y';
		var popLeft = screen.availWidth+1000;
		var popTop = screen.availHeight+1000;
		var popParams = 'width = 1, height= 1, top=' + popTop + ', left=' + popLeft + ', scrollbars=yes, location=no, directories=no, status=yes, menubar=no, toolbar=no, resizable=no, fullscreen=no';
		window.open(dest, 'jsAlert', popParams);
		errMsg = 'There was a Javascript error on this page\n';
		errMsg += 'that may prevent it from displaying properly.\n\n';
		errMsg += 'This error may be related to a 3rd-party browser\n';
		errMsg += 'add-on (such as a toolbar or popup-blocker).\n\n';
		errMsg += 'Tech support has been notified.\n\n';
		errMsg += 'Click OK to continue.' + '\n\n';
		errMsg += 'Error: ' + errTxt + '\n';
		errMsg += 'URL: ' + errUrl + '\n';
		errMsg += 'Line: ' + errLine + '\n\n';
		alert(errMsg);
		return true;
	}
	errNum += 1;
	if (errNum == 1) {
		brwz = navigator.userAgent;
		tyme = getLocalTime();
		fn = '';
		pn = '';
		if (document.frmAddEdit) {
			if (document.frmAddEdit.CurrentFormName) {
				fn = document.frmAddEdit.CurrentFormName.value;
				if (document.frmAddEdit.CurrentFormID) {
					fn = fn + ' (' + document.frmAddEdit.CurrentFormID.value + ')';
				}
			}
			if (document.frmAddEdit.CurrentPageName) {
				pn = document.frmAddEdit.CurrentPageName.value;
				if (document.frmAddEdit.CurrentPageID) {
					pn = pn + ' (' + document.frmAddEdit.CurrentPageID.value + ')';
				}
			}
		}
		else {
			if (document.frmWorking) {
				if (document.frmWorking.CurrentFormName) {
					fn = document.frmWorking.CurrentFormName.value;
					if (document.frmWorking.CurrentFormID) {
						fn = fn + ' (' + document.frmWorking.CurrentFormID.value + ')';
					}
				}
			}
		}
		dest = '/error/jsError.asp?msg='+encodeURI(errTxt)+'&url='+encodeURI(errUrl)+'&line='+errLine+'&brwz='+encodeURI(brwz)+'&tyme='+encodeURI(tyme)+'&frm='+encodeURI(fn)+'&pg='+encodeURI(pn)+'&err=1&pop=Y';
		var popLeft = screen.availWidth+1000;
		var popTop = screen.availHeight+1000;
		var popParams = 'width = 1, height= 1, top=' + popTop + ', left=' + popLeft + ', scrollbars=yes, location=no, directories=no, status=yes, menubar=no, toolbar=no, resizable=no, fullscreen=no';
		window.open(dest, 'jsAlert', popParams);
		errMsg = 'There was a Javascript error on this page\n';
		errMsg += 'that may prevent it from displaying properly.\n\n';
		errMsg += 'Tech support has been notified.\n\n';
		errMsg += 'Click OK to continue.' + '\n\n';
		//errMsg += 'Error: ' + errTxt + '\n';
		//errMsg += 'URL: ' + errUrl + '\n';
		//errMsg += 'Line: ' + errLine;
		alert(errMsg);
		return true;
	}
	if (errNum == 2) {
		return true;
	}
	if (errNum == 3) {
		errMsg = 'There were more Javascript errors on this page.\n\n';
		errMsg += 'If more than three (3) errors are encountered,\n';
		if (window.opener) {
			errMsg += 'this popup window will close and tech support\n';
		}
		else {
			errMsg += 'this page will stop loading and tech support\n';
		}
		errMsg += 'will be automatically notified via e-mail.\n\n';
		errMsg += 'Click OK to continue.\n\n';
		//errMsg += 'Error: ' + errTxt + '\n';
		//errMsg += 'URL: ' + errUrl + '\n';
		//errMsg += 'Line: ' + errLine + '\n\n';
		alert(errMsg);
		return true;
	}
	else {
		brwz = navigator.userAgent;
		tyme = getLocalTime();
		fn = '';
		pn = '';
		if (document.frmAddEdit) {
			if (document.frmAddEdit.CurrentFormName) {
				fn = document.frmAddEdit.CurrentFormName.value;
				if (document.frmAddEdit.CurrentFormID) {
					fn = fn + ' (' + document.frmAddEdit.CurrentFormID.value + ')';
				}
			}
			if (document.frmAddEdit.CurrentPageName) {
				pn = document.frmAddEdit.CurrentPageName.value;
				if (document.frmAddEdit.CurrentPageID) {
					pn = pn + ' (' + document.frmAddEdit.CurrentPageID.value + ')';
				}
			}
		}
		else {
			if (document.frmWorking) {
				if (document.frmWorking.CurrentFormName) {
					fn = document.frmWorking.CurrentFormName.value;
					if (document.frmWorking.CurrentFormID) {
						fn = fn + ' (' + document.frmWorking.CurrentFormID.value + ')';
					}
				}
			}
		}
		dest = '/error/jsError.asp?msg='+encodeURI(errTxt)+'&url='+encodeURI(errUrl)+'&line='+errLine+'&brwz='+encodeURI(brwz)+'&tyme='+encodeURI(tyme)+'&frm='+encodeURI(fn)+'&pg='+encodeURI(pn)+'&err=4';
		if (window.opener) {
			document.location = dest +'&pop=Y';
		}
		else {
			document.location = dest +'&pop=N';
		}
	}
}

function testErrURL(s) {
	var testUrl, urlTestStr, urlPart1, urlPart2, i, nextPos;
	testUrl = s.toLowerCase();
	urlTestStr = '://';
	if ((i = testUrl.indexOf(urlTestStr)) >= 0) {
		urlPart1 = testUrl.substr(0, i);
		if (urlPart1 == 'http' || urlPart1 == 'https') {
			nextPos = i + urlTestStr.length;
			urlTestStr = 'pangaea';
			if ((i = testUrl.indexOf(urlTestStr,nextPos)) >= 0) {
				return true;
			}
			else {
				urlTestStr = 'localhost';
				if ((i = testUrl.indexOf(urlTestStr,nextPos)) >= 0) {
					return true;
				}
				else {
					return false; // non-site url format
				}
			}
		}
		else {
			return false; // non-site url format
		}
	}
	else {
		return false; // non-site url format
	}
	return true;
}

var ttTimer = null;
var ttState = 0;
var entryTarget = null;

var pixel = new Image();
pixel.src = '/images/pixel.gif';

var imgWorking = new Image();
imgWorking.src = '/fluid/images/circle-thick-orange.gif';

var objPopup = null;
var timerWorking = null;

var u3;
var sURL = unescape(window.location.pathname);

var browserType = '?';
var browserVersion = '?';
var elUnselect = true;

var fadeElementTimer = null;
var fadeElementOpacity = 0;

var prevDate = '';
var prevTime = '';

var viewportWidth, viewportHeight;

function popPageHelp(p,n) {
	var popW = (screen.availWidth) ? (screen.availWidth)/2 : 300;
	var popH = (screen.availHeight) ? (((screen.availHeight)/2) - (screen.height - screen.availHeight)) : 500;
	var leftPos = (screen.availWidth) ? (screen.availWidth-popW)/2 : 100;
	var topPos = (screen.availHeight) ? (((screen.availHeight-popH)/2) - (screen.height - screen.availHeight)) : 100;
	var popParams = 'width=' + popW + ', height=' + popH + ', top=' + topPos + ', left=' + leftPos + ', scrollbars=yes, location=no, directories=no, status=yes, menubar=no, toolbar=no, resizable=yes, fullscreen=no';
	var popPath = '/help/helpOpen.asp?path='+escape(p)+'&name='+escape(n);
	objPopup = window.open(popPath, 'help', popParams);
}

function getLocalTime() {
	var localStr = null;
	var curDateTime = new Date();
	var curYear = curDateTime.getYear();
	if (curYear < 1000) { curYear += 1900 }
	var curMo = curDateTime.getMonth() + 1;
	var curDay = curDateTime.getDate();
	var curDateStr = curMo + '/' + curDay + '/' + curYear;
	var curHour = curDateTime.getHours()
	var curMin = curDateTime.getMinutes()
	var curSec = curDateTime.getSeconds()
	var curTimeStr = ((curHour < 10) ? "0" : "") + curHour + ":" + ((curMin < 10) ? "0" : "") + curMin + ":" + ((curSec < 10) ? "0" : "") + curSec;
	localStr = curDateStr + ' ' + curTimeStr;
	return localStr;
}

function setCSSHover() {
	h='\n<!--[if IE]><style>body{behavior:url(/fluid/htc/csshover.htc);}</style><![endif]-->';
	document.write(h);
}

setCSSHover();

function goHome() {
	document.location = '/goHome.asp';
}

//----------------------------------------------------------------------------
// Code to determine the browser and version.
//----------------------------------------------------------------------------

function getBrowser() {

	var ua, s, i;

	this.isIE    = false;  // Internet Explorer
	this.isOP    = false;  // Opera
	this.isNS    = false;  // Netscape
	this.version = null;

	ua = navigator.userAgent;
	
	s = 'Opera';
	if ((i = ua.indexOf(s)) >= 0) {
		this.isOP = true;
		this.version = parseFloat(ua.substr(i + s.length));
		browserType = 'Opera';
		browserVersion = this.version;
		return;
	}

	s = 'Netscape6/';
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = parseFloat(ua.substr(i + s.length));
		browserType = 'Netscape';
		browserVersion = this.version;
		return;
	}

	s = 'Firefox/';
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = parseFloat(ua.substr(i + s.length));
		browserType = 'Firefox';
		browserVersion = this.version;
		return;
	}

	// Treat any other "Gecko" browser as Netscape 6.1.

	s = 'Gecko';
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = 6.1;
		browserType = 'Gecko';
		browserVersion = '(treated as Netscape 6.1)';
		return;
	}

	s = 'MSIE';
	if ((i = ua.indexOf(s))) {
		this.isIE = true;
		this.version = parseFloat(ua.substr(i + s.length));
		browserType = 'Microsoft IE';
		browserVersion = this.version;
		return;
	}
}

var objBrowser = new getBrowser();

//----------------------------------------------------------------------------
// Code to determine if cookies are enabled.
//----------------------------------------------------------------------------

var objCookieTest = {};

objCookieTest.set = function(name,value,days){
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days*24*60*60*1000));
		var expires = "; expires=" + date.toGMTString();
	}
	else {
		var expires = "";
	}
	document.cookie = name + "=" + value + expires + "; path=/";
}

objCookieTest.get = function(name) {
	name += "=";
	var s = document.cookie.split("; ");
	for(var i = 0; i < s.length; i++) {
		var c = s[i];
		if (c.indexOf(name) == 0) {
			return unescape(c.substring(name.length,c.length));
		}
	}
	return null;
}

objCookieTest.erase = function(name) {
	this.set(name,"",-1);
}

objCookieTest.isEnabled = function() {
	this.set("cookietest","cookietest");
	return this.get("cookietest") != null;
}

/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


//----------------------------------------------------------------------------
// Code to determine if popups are blocked.
//----------------------------------------------------------------------------

function popupTest() {
	var objRegExp = new RegExp('object','gi');
	try {
		leftPos = screen.width + 1000;
		topPos = screen.height + 1000;
		popParams = 'width = 1, height= 1, top=' + topPos + ', left=' + leftPos + ', scrollbars=yes, location=no, directories=no, status=yes, menubar=no, toolbar=no, resizable=no, fullscreen=no';
		objPopup = window.open('','test', popParams);
		objPopup.close();
	}
	catch(e) { }
	if (!objRegExp.test(String(objPopup))) {
		return "blocked";
	}
	else {
		//alert('No pop-up blocker or pop-up blocker is disabled!');
		return "enabled";
	}
}

//----------------------------------------------------------------------------
// Code to determine browser window dimensions.
//----------------------------------------------------------------------------

function getWinHeight() {
	var winH = 0;
	if (typeof(window.innerHeight) == 'number') {
		winH = window.innerHeight;
		if (document.documentElement && document.documentElement.clientHeight) {
			winH2 = document.documentElement.clientHeight;
		}
		else {
		    if (document.body && document.body.clientHeight) {
				winH2 = document.body.clientHeight;
		    }
		}
		if (winH2 > 0 && winH2 < winH) { winH = winH2 }
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			winH = document.documentElement.clientHeight;
		}
		else {
		    if (document.body && document.body.clientHeight) {
				winH = document.body.clientHeight;
		    }
		}
	}
	return winH;
}

function getWinWidth() {
	var winW = 0;
	if (typeof(window.innerWidth) == 'number') {
		winW = window.innerWidth;
		if (document.documentElement && document.documentElement.clientWidth) {
			winW2 = document.documentElement.clientWidth;
		}
		else {
		    if (document.body && document.body.clientWidth) {
				winW2 = document.body.clientWidth;
		    }
		}
		if (winW2 > 0 && winW2 < winW) { winW = winW2 }
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			winW = document.documentElement.clientWidth;
		}
		else {
		    if (document.body && document.body.clientWidth) {
				winW = document.body.clientWidth;
		    }
		}
	}
	return winW;
}


//----------------------------------------------------------------------------
// Code to get the true offset of anything on NS4, IE4/5 & NS6, even if it's in a table!
//----------------------------------------------------------------------------

function getAbsX(elt) { return (elt.x) ? elt.x : getAbsPos(elt,"Left"); }
function getAbsY(elt) { return (elt.y) ? elt.y : getAbsPos(elt,"Top"); }

function getAbsPos(elt,which) {
	iPos = 0;
	while (elt != null) {
		iPos += elt["offset" + which];
		elt = elt.offsetParent;
	}
	return iPos;
}

function findPosX(obj) {
	var curLeft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent)	{
			if (obj.offsetLeft >= 0) {
				curLeft += obj.offsetLeft
			}
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) {
		curLeft += obj.x;
	}
	return curLeft;
}

function findPosY(obj) {
	var curTop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent)	{
			curTop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y) {
		curTop += obj.y;
	}
	return curTop;
}

//----------------------------------------------------------------------------
// Code to redirect unsupported browsers.
//----------------------------------------------------------------------------

function bypassBrowserCheck() {
	return false;
}

supportedTest = function() {
	if (objCookieTest.isEnabled() != true) {
		document.location = '/unsupported.asp?e=cookies';
	}
	if (bypassBrowserCheck() == true) {
	}
	else {
		if (objBrowser.isOP == true) {
			//document.location = '/unsupported.asp?e=Opera';
		}
		if (objBrowser.isIE == true && objBrowser.version < 5.5) {
			document.location = '/unsupported.asp?e=oldIE';
		}
	}
}

runPopupTest = function() {
	var popTest = popupTest();
	if (popTest == 'blocked') {
		document.location = '/unsupported.asp?e=popupblocker';
	}
}

function closePopup() {
	if (objPopup && !objPopup.closed && objPopup.location)	{
		objPopup.close();
	}
}

function focusPopup() {
	if (objPopup && !objPopup.closed && objPopup.location)	{
		if (objPopup.focus) {
			objPopup.focus();
			return false;
		}
	}
}

function disableSelection(el) {
	if (typeof el.onselectstart!="undefined") //IE route
		el.onselectstart=function(){return false}
	else if (typeof el.style.MozUserSelect!="undefined") //Firefox route
		el.style.MozUserSelect="none"
	else //All other route (ie: Opera)
		el.onmousedown=function(){return false}
	el.style.cursor = "default"
}

function startUnselect() {
	if (document.getElementById) {
		el = document.getElementById('pageBanner');
		if (el) { disableSelection(el); }
		el = document.getElementById('navmenu');
		if (el) { disableSelection(el); }
		el = document.getElementById('photoPages');
		if (el) { disableSelection(el); }
		el = document.getElementById('formsNavigation');
		if (el) { disableSelection(el); }
		el = document.getElementById('tooltip');
		if (el) { disableSelection(el); }
	}
}

function childEls(el,f) {
	f(el)
	for (var c = el.firstChild; c; c = c.nextSibling) {
		if (c.nodeType == 1) {
			childEls(c,f);
		}
	}
}

function unselectable(el) {
	if (el.id == 'layout') {
		return;
	}
	if (el.tagName == 'INPUT' || el.tagName == 'TEXTAREA') {
		return;
	}
	if (el.className == 'pauseUnselect') {
		elUnselect = false;
	}
	if (elUnselect == false && el.className == 'resumeUnselect') {
		elUnselect = true;
	}
	if (elUnselect == true) {
		//el.unselectable = 'on';
		cn = el.className;
		if (cn != '') {
			el.className = cn + ' unselectable';
		}
		else {
			el.className = 'unselectable';
		}
		el.onselectstart=function() { document.selection.empty();return false; };
	}
}

function cancelMouseDrag(o,e) {
	var txt = '';
	if (window.getSelection)	{
		txt = window.getSelection();
	}
	else if (document.getSelection) {
		txt = document.getSelection();
	}
	else if (document.selection) {
		txt = document.selection.createRange().text;
	}
	else return;
	if (txt != '') {
		if (!e) var e = window.event;
		e.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();
		e.keyCode = 0;
		e.returnValue = false;
		if (document.selection) {
			alert('Sorry, but you can\'t drag\nyour selection into this area!');
			document.selection.empty();
		}
	}
	return false;
}

function doHourglass() {
	document.body.style.cursor = 'wait';
}

function clearHourglass() {
	document.body.style.cursor = '';
}

function pageWait() {
	setTimeout("disableInputs()", 500);
}

function disableInputs() {
	document.body.style.cursor = 'wait';
	//if (document.getElementById('navmenu')) {
	//	closeMenu();
	//}
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'hidden') {
			//w = xWidth(x[i]);
			//h = xHeight(x[i]);
			x[i].style.cursor = 'wait';
			x[i].disabled = true;
			//xResizeTo(x[i],w,h);
		}
	}
	var x = document.getElementsByTagName('select');
	for (var i=0;i<x.length;i++) {
		x[i].style.cursor = 'wait';
		x[i].disabled = true;
	}
	var x = document.getElementsByTagName('textarea');
	for (var i=0;i<x.length;i++) {
		x[i].style.cursor = 'wait';
		x[i].disabled = true;
	}
	return true;
	objLinks = document.links;
	for(i=0;i<objLinks.length;i++){
		objLinks[i].disabled = true;
		//link with onclick
		if (objLinks[i].onclick){  
			objLinks[i].onclick = new Function("return false;");
		}
		//link without onclick
		else {  
			objLinks[i].onclick = function(){return false;}
		}
	}
	return true;
}

function isChild(childEl,parentEl) {
	while(childEl) {
		if (childEl==parentEl) 
			return true;
		childEl=childEl.parentNode;
	}
	return false;
}

function getObj(objID) {
	if (document.getElementById) {
		return document.getElementById(objID);
	}
	else if (document.all) {
		return document.all[objID];
	}
	else if (document.layers) {
		return document.layers[objID];
	}
}

function getScrollerWidth() {
    var scr = null;
    var inn = null;
    var wNoScroll = 0;
    var wScroll = 0;

    // Outer scrolling div
    scr = document.createElement('div');
    scr.style.position = 'absolute';
    scr.style.top = '-1000px';
    scr.style.left = '-1000px';
    scr.style.width = '100px';
    scr.style.height = '50px';
    // Start with no scrollbar
    scr.style.overflow = 'hidden';

    // Inner content div
    inn = document.createElement('div');
    inn.style.width = '100%';
    inn.style.height = '200px';

    // Put the inner div in the scrolling div
    scr.appendChild(inn);
    // Append the scrolling div to the doc
    document.body.appendChild(scr);

    // Width of the inner div sans scrollbar
    wNoScroll = inn.offsetWidth;
    // Add the scrollbar
    scr.style.overflow = 'auto';
    // Width of the inner div width scrollbar
    wScroll = inn.offsetWidth;
    
    // Remove the scrolling div from the doc
    document.body.removeChild(
        document.body.lastChild);

    // Pixel width of the scroller
    return (wNoScroll - wScroll);
}

function sendEmailBasic(sendTo, CC, BCC, replyTo, subject, message) {
    var emailBody;
    var emailTo;
    var emailSubject;
    var emailCC;
    var emailBCC;
    var emailReplyTo;

    var emailURL; // The URL that will open the user's email client
    
    var emailDisclaimer;
    
    emailDisclaimer = "\n\nThis e-mail contains information which (a) may be PROPRIETARY IN NATURE OR OTHERWISE PROTECTED BY LAW FROM DISCLOSURE, and (b) is intended only for the use of the addressee(s) named above. If you are not the addressee, or the person responsible for delivering this to the addressee(s), you are hereby notified that reading, copying or distributing this e-mail is prohibited. If you have received this e-mail in error, please contact the sender immediately.";

    // Set some default values
    emailBody = message + emailDisclaimer;
    emailTo = sendTo ? sendTo : ' ';
    emailSubject = subject ? subject : ' ';
    emailCC = CC ? CC : ' ';
    emailBCC = BCC ? BCC : ' ';
    emailReplyTo = replyTo ? replyTo : ' ';
    
    emailURL = "mailto:" + escape(emailTo) + 
	"?subject=" + escape(emailSubject) +
	"&cc=" + escape(emailCC) +
	"&bcc=" + escape(emailBCC) +
	"&replyto=" + escape(emailReplyTo) +
	"&body=" + escape(emailBody);
	
	//alert(emailURL);

    window.location = emailURL;
    return true;
}

//----------------------------------------------------------------------------
// Code to load functions on certain page events.
//----------------------------------------------------------------------------

function addLoadEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("load", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onload", func);
	}
	else if (document.getElementById) {
		window.onload=func; 
	}
	else {
		document.location = '/unsupported.asp?e=eventsJS'; 
	}
	return false;
}

function addResizeEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("resize", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onresize", func);
	}
	else if (document.getElementById) {
		window.onresize=func; 
	}
	else {
		document.location = '/unsupported.asp?e=eventsJS'; 
	}
	return false;
}

function addFocusEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("focus", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onfocus", func);
	}
	else if (document.getElementById) {
		window.onfocus=func; 
	}
	else {
		document.location = '/unsupported.asp?e=eventsJS'; 
	}
	return false;
}

function addBlurEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("blur", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onblur", func);
	}
	else if (document.getElementById) {
		window.onblur=func; 
	}
	else {
		document.location = '/unsupported.asp?e=eventsJS'; 
	}
	return false;
}

function addBeforeUnloadEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("beforeunload", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onbeforeunload", func);
	}
	else if (document.getElementById) {
		window.onbeforeunload=func; 
	}
	return false;
}

function addUnloadEvent(func) {
	if (window.addEventListener) {
		window.addEventListener("unload", func, false);
	} 
	else if (window.attachEvent) {
		window.attachEvent("onunload", func);
	}
	else if (document.getElementById) {
		window.onunload=func; 
	}
	return false;
}

function popLookup(i,t) {
	h = viewportHeight - 200;
	popWinStatusBar('/formslib/lookupOpen.asp?fld=' + i + '&sql=' + t, 'lookup', 400, h, 'yes', 'center');
}

function popAirport(ap,cd,ct) {
	h = viewportHeight - 200;
	popWinStatusBar('/formslib/airportOpen.asp?airport=' + ap + '&code=' + cd + '&city=' + ct, 'lookup', 400, h, 'yes', 'center');
}

function popAirline(al,cd) {
	h = viewportHeight - 200;
	popWinStatusBar('/formslib/airlineOpen.asp?airline=' + al + '&code=' + cd, 'lookup', 400, h, 'yes', 'center');
}

function popCalendar(i) {
	if (document.getElementById) {
		el = document.getElementById(i);
		if (el) {
			var calW, calH; //dimensions of calendar popup
			calW = 300;
			calH = 250;
			var elX, elY; //position of page element
			elX = xPageX(el);
			elY = xPageY(el);
			var scrX, scrY; //scroll amount of page element
			scrX = xScrollX(el);
			scrY = xScrollY(el);
			var winX, winY; //position of popup window
			if (typeof window.screenLeft != "undefined") { //IE
				winX = window.screenLeft + elX - scrX;
				winY = window.screenTop + elY - scrY; 
			}
			else if (typeof window.screenX != "undefined") { //NS/Moz
				winX = window.screenX + elX - scrX;
				winY = window.screenY + elY - scrY;
			}
			else { //default - center of screen
				winX = screen.availWidth/2 - calW/2;
				winY = screen.availHeight/2 - calH/2;
			}
			if ((winX + calW) > (screen.availWidth - 25)) {
				winX = screen.availWidth - calW - 50;
			}
			if ((winY + calH) > (screen.availHeight - 50)) {
				winY = screen.availHeight - calH - 100;
			}
			popWinStatusBarXY('/formslib/calendarOpen.asp?fld=' + el.id, 'calendar', calW, calH, 'no', winX, winY);
		}
	}
}

function popClock(i) {
	if (document.getElementById) {
		el = document.getElementById(i);
		if (el) {
			var calW, calH; //dimensions of calendar popup
			calW = 200;
			calH = 150;
			var elX, elY; //position of page element
			elX = xPageX(el);
			elY = xPageY(el);
			var scrX, scrY; //scroll amount of page element
			scrX = xScrollX(el);
			scrY = xScrollY(el);
			var winX, winY; //position of popup window
			if (typeof window.screenLeft != "undefined") { //IE
				winX = window.screenLeft + elX - scrX;
				winY = window.screenTop + elY - scrY; 
			}
			else if (typeof window.screenX != "undefined") { //NS/Moz
				winX = window.screenX + elX - scrX;
				winY = window.screenY + elY - scrY;
			}
			else { //default - center of screen
				winX = screen.availWidth/2 - calW/2;
				winY = screen.availHeight/2 - calH/2;
			}
			if ((winX + calW) > (screen.availWidth - 25)) {
				winX = screen.availWidth - calW - 50;
			}
			if ((winY + calH) > (screen.availHeight - 50)) {
				winY = screen.availHeight - calH - 100;
			}
			popWinStatusBarXY('/formslib/clockOpen.asp?fld=' + el.id, 'calendar', calW, calH, 'no', winX, winY);
		}
	}
}

function popVideo(i,v) {
	if (document.getElementById) {
		el = document.getElementById(i);
		if (el) {
			var vidW, vidH; //dimensions of video popup
			vidW = 350;
			vidH = 300;
			var elX, elY; //position of page element
			elX = xPageX(el);
			elY = xPageY(el);
			var scrX, scrY; //scroll amount of page element
			scrX = xScrollX(el);
			scrY = xScrollY(el);
			var winX, winY; //position of popup window
			if (typeof window.screenLeft != "undefined") { //IE
				winX = window.screenLeft + elX - scrX;
				winY = window.screenTop + elY - scrY; 
			}
			else if (typeof window.screenX != "undefined") { //NS/Moz
				winX = window.screenX + elX - scrX;
				winY = window.screenY + elY - scrY;
			}
			else { //default - center of screen
				winX = screen.availWidth/2 - vidW/2;
				winY = screen.availHeight/2 - vidH/2;
			}
			if ((winX + vidW) > (screen.availWidth - 25)) {
				winX = screen.availWidth - vidW - 50;
			}
			if ((winY + vidH) > (screen.availHeight - 50)) {
				winY = screen.availHeight - vidH - 100;
			}
			popWinStatusBarXY('/formslib/videoOpen.asp?fld=' + el.id + '&vid=' + v, 'video', vidW, vidH, 'no', winX, winY);
		}
	}
}

function setRowCookie(value) {
	var today = new Date();     
	var expiredate = new Date();      
	expiredate.setTime(today.getTime() + 1000*60*10);
	var rowCookie = 'row:' + escape(document.location.pathname) + '=' + escape(value) + '; path=/; expires=' + expiredate.toGMTString();
	document.cookie = rowCookie;
}

function getRowCookie() {
	var nameEQ = 'row:' + escape(document.location.pathname) + '=';
	var ca = document.cookie.split(';');
	for (var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') {
			c = c.substring(1,c.length);
		}
		if (c.indexOf(nameEQ) == 0) {
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}

function expireRowCookie() {
	if (getRowCookie()) {
		document.cookie = 'row:' + escape(document.location.pathname) + '=; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT';
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function resizeLayout() {
	return;
}

function setElementOpacity(el, op) {
	if (el.filters) {
		var w = xWidth(el);
		xWidth(el, w);
		el.style.filter='alpha(opacity='+parseInt(op)+')';
	}
	else {
		el.style.MozOpacity = op/101;
	}
}

function fadeInElement(el1, el2, el3) {
	clearTimeout(fadeElementTimer);
	if (fadeElementOpacity<100) {
		fadeElementOpacity+=25;
		if (document.getElementById) {
			setElementOpacity(document.getElementById(el1), fadeElementOpacity);
			if (el2 != '') {
				setElementOpacity(document.getElementById(el2), fadeElementOpacity);
			}	
			if (el3 != '') {
				setElementOpacity(document.getElementById(el3), fadeElementOpacity);
			}	
		}
		t = 'fadeInElement(\'' + el1 + '\',\'' + el2 + '\',\'' + el3 + '\')';
		fadeElementTimer = setTimeout(t, 5);
	}
}

function hideNoscript() {
	if (document.getElementById) {
		if (document.getElementById('noscript')) {
			document.getElementById('noscript').style.display = 'none';
		}
	}
}

function showWorking() {
	if (document.getElementById) {
		el = document.getElementById('workingDiv');
		if (el) {
			if (objBrowser.isIE) {
				el.style.filter='alpha(opacity=10)';
			}
			else {
				el.style.opacity=.1;
			}
			vupDims();
			xMoveTo(el, 0, 0);
			xResizeTo(el, vupW, minVupH);
			msg = document.getElementById('workingMsg');
			if (msg) {
				xMoveTo(msg, (vupW-xWidth(msg))/2, (minVupH-xHeight(msg))/2);
			}
		}
	}
}

function hideWorking() {
	if (document.getElementById) {
		el = document.getElementById('workingDiv');
		if (el) {
			xMoveTo(el, -999, -999);
			xResizeTo(el, 10, 10);
			msg = document.getElementById('workingMsg');
			if (msg) {
				xMoveTo(msg, -999, -999);
			}
		}
	}
}

addLoadEvent(hideWorking);
addLoadEvent(hideNoscript);

//addLoadEvent(supportedTest);
addLoadEvent(startUnselect);
//addLoadEvent(startSessionXtendr);
//addBeforeUnloadEvent(doHourglass);
addFocusEvent(focusPopup);
addUnloadEvent(closePopup);
//addUnloadEvent(doHourglass);
//addFocusEvent(clearHourglass);

