//++++++++++ Rollover Image Code ++++++++++
function FindObj(n, d) { 
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=FindObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}
var findObj = FindObj;	// alias 'cause I keep forgetting!!!

function SwapImage() { 
var i,j=0,x,a=SwapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=FindObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function SwapImageRestore() { 
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function PreloadImages() { 
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=PreloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//~~~~~~~~~~ Rollover Image Code ~~~~~~~~~~

//++++++++++ Dropdown Menu Code ++++++++++
var cleartimer = new Array();
var deploytimer = new Array();
var menusdeployed = false;
var menudeploydelay = 150;
var menucleardelay = 200;
var liArray = new Array();
var imgArray = new Array();
var hoverRegex = new RegExp("sfhover\\b");
var imgRegex = new RegExp("_over");

// sets all images except the parent of the "exception" node to the non-mouseover state
// if exception is null, clear all mouseoverimages unconditionally
function clearoverimg(exception) {
	var imgparent;
	for (var i=0; i<imgArray.length; i++) {
		// ugly.
		// essentially, reset any image "over" states unless the image is
		// a (grand)child of the currently-selected menu
		
		if (!exception) 
			imgArray[i].src=imgArray[i].src.replace(imgRegex, "");
		else {
			// check all parents of node[i] to see if they're the parent
			imgparent = imgArray[i];
			while(imgparent.parentNode && imgparent != exception) {
				imgparent = imgparent.parentNode;
			}
			
			// if this isn't the exception, change image from IMAGENAME_over to IMAGENAME
			if (imgparent != exception)
				imgArray[i].src=imgArray[i].src.replace(imgRegex, "");
		}
	}
}

// resets all open menus, but preserve the mouseover state of the parent element image
// called every time a new menu is opened, as well as when the clear menu timer expires
function clearmenus(caller) {
	for (var i=0; i<liArray.length; i++) {
	  liArray[i].className=liArray[i].className.replace(hoverRegex, "");
	}
	if (!caller) clearoverimg(); // with a null caller, clear all images
	else if (caller.getElementsByTagName("img").length > 0) clearoverimg(caller);
	
	// turn off the auto-clear of menus
	cleartimeouts();
	menusdeployed=false;
}

function cleartimeouts() {
	while (cleartimer.length) clearTimeout(cleartimer.pop());
	
	if (deploytimer.length) {
		deploytimer.pop(); // remove calling object from stack
		clearTimeout(deploytimer.pop());
	}
}

function openmenu(caller) {
	// procedure for opening a new menu: 
	// clear all current menus
	// set current menu to visible
	// remove all pending timers
	clearmenus(caller);
	caller.className+=" sfhover";
      	cleartimeouts();
	menusdeployed=true;
}

function sfHover() {
	liArray = document.getElementById("mainNavBar").getElementsByTagName("LI");
	imgArray = document.getElementById("mainNavBar").getElementsByTagName("img");

	for (var i=0; i<liArray.length; i++) {
		liArray[i].onmouseover=liArray[i].onfocus=function() {
			if (!menusdeployed) {
				cleartimeouts();
				deploytimer.push(setTimeout("openmenu(deploytimer.pop());", menudeploydelay));
				deploytimer.push(this);
			} else {
				openmenu(this);
			}
		}
		liArray[i].onmouseout=liArray[i].onblur=function() {
			if (deploytimer.length) clearmenus();
			else if (!cleartimer.length ) cleartimer.push(setTimeout("clearmenus()", menucleardelay));
		}
	}
}

//	switchIt() :: Simple function to hide/display a list. Assumes the existance of a "cBox[assetid]" (collapse box)
//	and "eBox[assetid]" (expand box) object somewhere on the page. Uses FindObj() provided by T29. (Brian, 2008-02-28)
function switchIt(list, assetId) {
	var a=FindObj(list + assetId).style;
	if (a.display=="none") {
		a.display="block";
		FindObj("cBox" + assetId).style.display = "inline";
		FindObj("eBox" + assetId).style.display = "none";
	}
	else {
		a.display="none";
		FindObj("cBox" + assetId).style.display = "none";
		FindObj("eBox" + assetId).style.display = "inline";
	}
	return false;
}

//	Turns the display of any number of BLOCK (<DIV> etc.) OBJECTS on and off. Designed to be used with findObj() as
//	in: toggleBlocks(findObj('a'), findObj('b'), findObj('z')); return false; (Brian, 2008-08-01)
function toggleBlocks() {
	for (var i = 0; i < arguments.length; i++) {
		var o = arguments[i];
		if (o != null) {
			if (o.style != null) {
				if (o.style.display == 'none') {
					o.style.display = '';
				}
				else {
					o.style.display = 'none';
				}
			}
		}
	}
}

function say(car, cdr, text) {
    if (cdr == null) { cdr = new Array('edu', 'stlcc') }
    var a = new Array('o', 't', 'l', 'i', 'a', 'm');
    a.reverse(); car.reverse(); cdr.reverse();
    var j = car.join('') + '&' + '#6' + '4;' + cdr.join('.');
    if ((text == null) || (text == '')) { text = j }
    document.write('<a href="' + a.join('') + ':' + j + '">' + text + '</a>');
    return true;
}

// TEST CODE
function test_set(element, timer)
{
	if (timer == 'deploy')
		menudeploydelay = parseInt(element.value);
	else if (timer == 'clear')
		menucleardelay = parseInt(element.value);
} 
//~~~~~~~~~~ Dropdown Menu Code ~~~~~~~~~~

//++++++++++ Popup Code ++++++++++
function popupResize()
{
	window.resizeTo(500,500);
}
//~~~~~~~~~~ Popup Code ~~~~~~~~~~

//++++++++++  ++++++++++
//~~~~~~~~~~  ~~~~~~~~~~
