//
// W. L. Graham
// Calculate the footer position and place it there, considering
// the heights of the window, left navigation, and content areas.
// From a suggestion of Bobby van der Sluis of "A List Apart", q.v., 
// Used by permission.
//
function isIE () {
	var ua = window.navigator.userAgent;
	var msie = ua.indexOf ( "MSIE " );
	return (msie >= 0);
}

function isIE6 () {
	var ua = window.navigator.userAgent;
	var msie = ua.indexOf ( "MSIE 6 " );
	return (msie >= 0);
}

function isOpera () {
	var ua = window.navigator.userAgent;
	var opera = ua.indexOf ( "Opera " );
	return (opera >= 0);
}

function getPosition(e) {
	e = e || window.event;
	var cursor = {x:0, y:0};
	if (e.pageX || e.pageY) {
		cursor.x = e.pageX;
		cursor.y = e.pageY;
	}
    else {
        cursor.x = e.clientX +
            (document.documentElement.scrollLeft ||
            document.body.scrollLeft) -
            document.documentElement.clientLeft;
        cursor.y = e.clientY +
            (document.documentElement.scrollTop ||
            document.body.scrollTop) -
            document.documentElement.clientTop;
	}
	return cursor;
}

function cursorSpot() {

// If there is an element named here, position to that element 
// (this avoids the menu flying out undesirably on these pages)

	gotIt=document.getElementById('AlphaByName');

	if (gotIt) {
		gotIt.focus();
	}
}

function footerSpot() {

// Position the bottom of the footer relative to window and content

	var windowHeight=0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}

	// Constant top-of-page DIV;s
	footerHeight = document.getElementById('footer').clientHeight;
	headerHeight = document.getElementById('myheader').clientHeight;
	bannerHeight = document.getElementById('banner').clientHeight;
	globallinksHeight = document.getElementById('globallinks').clientHeight;
	breadcrumbHeight = document.getElementById('breadcrumb').clientHeight;
	pagetitleHeight = document.getElementById('pagetitle').clientHeight;
	contentHeight = document.getElementById('content').clientHeight;
	leftnavHeight = document.getElementById('leftnavigation').clientHeight;
	footerTopalaWindow  = windowHeight - footerHeight;
	footerTopalaLeftNav = leftnavHeight + bannerHeight + 0; // image is 140+padding 
	footerTopalaContent =  pagetitleHeight + contentHeight + headerHeight + bannerHeight + globallinksHeight + breadcrumbHeight;
	Fudge = 10;

	if (isIE() || isOpera())
	{
		longestDiv =  Math.max (footerTopalaWindow, (10*60) + 60, footerTopalaContent); 
		// Because the IE browser "doubles" the values when positioning; use constants
		footerTop = (longestDiv + Fudge) + 'px';
		document.getElementById('footer').style.setAttribute('position', 'absolute');
		document.getElementById('footer').style.setAttribute('visibility', 'visible');
		document.getElementById('footer').style.setAttribute('top', footerTop);
	} else {
		longestDiv =  Math.max (footerTopalaWindow, footerTopalaLeftNav, footerTopalaContent);
		footerTop = (longestDiv + Fudge) + 'px';
		document.getElementById('footer').style.setProperty('position', 'absolute', null);
		document.getElementById('footer').style.setProperty('visibility', 'visible', null);
		document.getElementById('footer').style.setProperty('top', footerTop, null);
	}
	return true;
}

// Add a GIF v. PNG (IE cannot do png transparency) LOGO

function putLogo () {

	if ( isIE() ) {

		document.writeln('<img alt="LIS Logo" src="/images/logos/LIS2Logo-140x140.gif" style="margin-top:1em;" height="140" width="140" border="0" />');

	} else {

		document.writeln('<img alt="LIS Logo" src="/images/logos/LIS2Logo-140x140.png" style="margin-top:1em;" height="140" width="140" border="0" />');

	}

	return true;
}

function rightnow () {
/* 
/* Set datetime into a hidden form field by writing the field
*/
dobj=new Date();
value='<input type="hidden" name="datetimesubmitted" value="';
value+= dobj;
value+='" />';
document.write(value);
return;
}