// psp: 1 Jul. 2004: found this code at:
// 			http://www.eleritec.net/projects/dev/dhtml/layoutManager/JSLayoutManager.js
//			
//			4 Jul. 2004: adapted to suit center-content-area layout

// *******************************************
// Begin LayoutManager object definition
// *******************************************
/*
		// Constructor for our LayoutManager object, which holds references to the
		// elements in the DOM we want to track.  This way, we won't have to keep
		// looking them up every time the layout needs to revalidate.
		function LayoutManager() {
			this.titlebar = document.getElementById(LayoutManager.TITLEBAR_ID);
			this.lt_sidebar = document.getElementById(LayoutManager.LT_SIDEBAR_ID);
			this.contentArea = document.getElementById(LayoutManager.CONTENT_ID);
		}

		// constants used to indentify the ID's of the elements in the DOM
		// we wish to track.  This way, if they're renamed, we only need to
		// change the values in one place.
		LayoutManager.TITLEBAR_ID = "topbar";
		LayoutManager.LT_SIDEBAR_ID = "lt_sidebar";
		LayoutManager.CONTENT_ID = "content";
		LayoutManager.MAXWIDTH = "9000";

		// keeps track of the number of times we've tried to initialize the page
		LayoutManager.retries = 0;

		// member function on the layout manager used to revalidate the page layout
		LayoutManager.prototype.revalidate = LayoutManager_revalidate;

// *******************************************
// End LayoutManager object definition
// *******************************************


// *******************************************
// Begin LayoutManager revalidation code
// *******************************************

		// establish a cross-browser means of revalidating the layout of
		// elements within the page.  This is a member function, so it can
		// reference the internal fields within the parent LayoutManager object.
		function LayoutManager_revalidate() {
			// determine the dimensions of the browser's client area.
			// not sure where the extra 4 pixels in IE are coming from, but we need to
			// remove them or our scrollbars will be offset slightly off the page.
			var winW = document.all? document.body.offsetWidth-4: window.innerWidth;
			var winH = document.all? document.body.offsetHeight-4: window.innerHeight;
		
			// set footer position;

			var lt_w = this.lt_sidebar.offsetWidth;
			
			// determine the new width of the titlebar and content area
			var w = winW - (lt_w) - 70;

			// determine the new height of the content area
			var h = winH - this.titlebar.offsetHeight - 30;
		

			// Apply our newly calculated sizes to the titlebar and content area.
			// Gecko handles negative values gracefully.  IE throws an exception. Also, if
			// we allow zero-values inclusively, IE starts displaying some quirky horizontal 
			// scrollbar behavior (sometimes showing a scrollbar when one isn't necessary).
			if(w>0) {
				this.titlebar.style.width = w + "px";
				this.contentArea.style.width = w + "px";
			}
			if(h>0){
				this.lt_sidebar.style.height = h + "px";
				this.contentArea.style.height = h + "px";
			}
		}

// *******************************************
// End LayoutManager revalidation code
// *******************************************


// *******************************************
// Begin page initialization routines
// *******************************************

		// establish a means of determining whether or not the requisite elements
		// needed for our layout manager exist within the DOM
		function LayoutManager_isDOMValid() {
			return 	document.getElementById(LayoutManager.TITLEBAR_ID) &&
					document.getElementById(LayoutManager.LT_SIDEBAR_ID) &&  
					document.getElementById(LayoutManager.CONTENT_ID);
		}

		// establish a cross-browser means of adding event listeners to elements
		function LayoutManager_addEventListener(target, evtType, handler) {
			if(document.all) {
				// IE likes event handler names to start with "on", as in "onmouseover"
				// or "onresize"
				if(evtType.substring(0, 2)!="on")
					evtType = "on" + evtType;
				// IE uses "attachEvent()" to add event listeners
				target.attachEvent(evtType, handler);
			}
			else {
				// Gecko doesn't use the "on" prefix for event handler names.  It
				// uses "mouseover" or "resize".
				if(evtType.substring(0, 2)=="on")
					evtType = evtType.substring(2, evtType.length);
				// Gecko uses "addEventListener()" to add event listeners
				target.addEventListener(evtType, handler, false);
			}
		}

		// implementation for page initialization
		function LayoutManager_initialize() {
			// First, make sure the DOM in the browser window can support our layoutManager.
			if(!LayoutManager_isDOMValid()) {
				// Check the retry count.  50 is an arbitrary number, but it seems reasonable.
				// There are two reasons the DOM may be invalid.  Either the page simply isn't
				// setup to work with our LayoutManager, or the page isn't done loading and
				// the relevant elements we want to manage don't yet exist.
				if(LayoutManager.retries<50) {
					// If we have not exceeded the max number if allowed retries, then keep
					// retrying until we can initialize the LayoutManager (or we give up). The
					// idea is that by the time we hit our max number of retries, the page will
					// have finished loading and we will either successfully initialize our
					// LayoutManager, or we will hit the max retry ceiling and give up.
					LayoutManager.retries++;
					// Note that the setTimeout() call is asynchronous.  We will return immediately
					// after this call and our retry will happen in another thread after 50 millis.
					setTimeout("LayoutManager_initialize()", 50);
				}
				return;
			}

			// If we made it here, then we have verified that the DOM in the browser window will
			// support our LayoutManager.  Go ahead and construct a LayoutManager object.
			var layoutMgr = new LayoutManager();
			// Now force it to revalidate the page layout.
			layoutMgr.revalidate();

			// Also, we want to make sure that window-resizing will trigger a revalidate() on the
			// LayoutManager.  Create an anonymous function to handle the revalidation call.
			var revalidatorFunction = function() {
				layoutMgr.revalidate();
			};

			// Now, add the function to the window "onresize" event handler
			LayoutManager_addEventListener(window, "resize", revalidatorFunction);
		}

		// This is the entry point as the page loads in the browser.
		// We make the function call right here so that developers do not have to explictly
		// inline this call in the BODY onload attribute.  We do not add it to the BODY onload
		// event handler here because it is quite possible the document body does not yet even
		// exist in the DOM.
		LayoutManager_initialize();

// *******************************************
// End page initialization routines
// *******************************************
*/

// *******************************************
// Need this to get around a mozilla bug in
// which the divs with overflow:auto|scroll
// do not respond to the mousewheel
// *******************************************
function fixScroll(_div) {
	if(document.all) return;
	var s = _div.scrollTop;
	_div.childNodes[1].focus();
	_div.scrollTop = s;
}

function makeEmail(who, dom, tld){
	var em = who + "@" + dom + "." + tld;
	document.write("<a href='mailto:" + em + "'>" + em + "</a>");
	return;
}

function fixDisclaimer(){
	var testStr = 'The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content.  All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees';
	// get the last div
	var divs = document.getElementsByTagName('div');
	var size = divs.length;
	var d = null;
	for(i=0; i<size; i++){
		d = divs[i];
		if(d.innerHTML.indexOf(testStr) > 0){
			break;
		}
	}
	d.style.display="none";
}

