// global variables
	var searchBox = null; // document element
	var searchText = null; // form element
	var quickLinksBox = null; // document element
	var globalObjVar = null;
	var time = null;
	var setGlobals_done = false;
	var box = new Array(
		"searchBox",
		"searchText",
		"quickLinksBox"
	);
	var JSmenu_count = 0;
	// make e-mail
	var liame_us = "cobweb";
	var liame_dom = "auburn";
	var liame_str = "<g<ac>"+ liame_us +"</c><h<t>"+"&atsym"+";</at><do>"+ liame_dom +"&moc;</do>";
	liame_us = null;
	liame_dom = null;

// Handles onclick;
if ( typeof survey___ != "function" ) document.onclick=allGone;
else if( !survey___() ) document.onclick=allGone;

function setGlobals(){
	
	try{
		searchBox = document.getElementById( box[0] );
		searchText = document.searchForm[ box[1] ];
		quickLinksBox = document.getElementById( box[2] );
		setGlobals_done = true;
	}
	catch(e){
		setGlobals_done = false;
	}
}

function getInsideWindowWidth() {
	
	// if a Netscape-compatible browser
	if (window.innerWidth) {
		
		return window.innerWidth;
	}
	// if IE6 with CSS support
	else if (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) {
		
		return document.body.parentElement.clientWidth;
	}
	// if IE 5.5 or earlier
	else if (document.body && document.body.clientWidth) {
		
		return document.body.clientWidth;
	}
	return 0;
}


// ----> (1.A) functions for the _links_ at the top of the page
function quickLinksMouseOver(){
	
	resetTime();
	Blur(searchText);
	hideElement(searchBox);
	displayElement(quickLinksBox);
}
function quickLinksMouseOut(){
	
	resetTime();
	timedHide(quickLinksBox, 1);
}
//         ------
function searchLinkMouseOver(){
	
	resetTime();
	hideElement(quickLinksBox);
	displayElement(searchBox);
	Focus(searchText);
}
function hideBoxes(){
	
	resetTime();
	hideElement(quickLinksBox);
	Blur(searchText);
	hideElement(searchBox);
}
// ----> END (1.A)


// ----> (1.B) functions for the
// search & quickLinks _boxes_ at the top of the page
function quickLinksBoxMouseOver(){
	
	displayElement(quickLinksBox);
	resetTime();
}
function quickLinksBoxMouseOut(){
	timedHide(quickLinksBox, 1);
}
//         ------
function searchBoxMouseOver(){
	
	displayElement(searchBox);
	Focus(searchText);
	resetTime();
}
function searchBoxMouseOut(){
	timedHide(searchBox, 7);
}
function searchBoxKeyDown(){
	timedHide(searchBox, 12);
}
// ----> END (1.B)


function displayElement(x){
	try{
		if ( x != null ){
			if ( x.style != undefined ){
				x.style.visibility = "visible";
				x.style.display = "block";
			}
		}
	}
	catch(e){return false;}
}
function hideElement(x){
	try{
		if ( x != null ){
			if ( x.style != undefined ){
				x.style.visibility = "hidden";
				x.style.display = "none";
			}
		}
	}
	catch(e){return false;}
}
function toggleElementDisplay(x){
	
	try{
		if( x != null ){
			if( x.style != undefined ){
				if ( x.style.display == "none" ||
					 x.style.visibility == "hidden" ) displayElement(x);
				else hideElement(x);
			}
		}
	}
	catch(e){return false;}
}
// Force Focus
function Focus(frmObj){
	try{
		if( frmObj != null ){
			if ( frmObj != undefined ){
				frmObj.focus();
			}
		}
	}
	catch(e){return false;}
}
// Force Blur
function Blur(frmObj){
	try{
		if( frmObj != null ){
			if ( frmObj != undefined ){
				frmObj.blur();
			}
		}
	}
	catch(e){return false;}
}


function positionBoxes(){
	
	if ( setGlobals_done ){
		
		quickLinksBox.style.left = getInsideWindowWidth() / 2 + 100;
		quickLinksBox.style.top = 14 ;
		
		searchBox.style.left = getInsideWindowWidth() / 2 + 60;
		searchBox.style.top = 24;
	}
}

/*
This function hides searchBox and quickLinksBox and blurs
searchText when user clicks on an element that is not
searchBox, searchText, or quickLinksBox.
*/
function allGone(e){
	
	if ( setGlobals_done ){
		
		if( searchBox.style.visibility == "visible" ||
			quickLinksBox.style.visibility == "visible" ){
			
			var obj;
			if ( !e ){
				var e = window.event;
			}
			if ( e.target ){
				obj = e.target;
			}
			else if ( e.srcElement ){
				obj = e.srcElement;
			}
			if ( obj.nodeType == 3 ){ // Safari bug
				obj = obj.parentNode;
			}
			
			tag = obj.tagName;
			obj = obj.id;
			r_set = true;
			
			if ( tag == "DIV" || tag == "INPUT" || tag == "LI" ){
				for( i = 0; i < box.length; i++ ){
					if ( obj == box[ i ] ){
						r_set = false;
					}
				}
				if ( obj == "" )
					r_set = false;
			}
			
			if ( r_set ){
				resetTime();
				Blur(searchText);
				hideElement(searchBox);
				hideElement(quickLinksBox);
			}
		}// end if
	}// end if
	else{
		return false;
	}
}// end function

function resetTime(){
	if ( time != null ){
		clearTimeout( time );
		time = null;
	}
}

function timedHide(obj, sec){
	
	globalObjVar = obj;
	resetTime();
	time = setTimeout( "hideElement(globalObjVar);Blur(searchText);", sec*1000 );
}


function menu(){
	
	if ( arguments.length > 0 ){
		
		x = arguments[0];
		header = x[1];
		header_link = x[0];
	}
}


// start Generate mailto our email
function symat(x){
	type = "edu";
	return (x.replace("&atsym;","@")).replace("&moc;","."+type);
}
function symat2(x){
	return symat((((x.replace("<g<ac>","")).replace("</c><h<t>","")).replace("</at><do>","")).replace("</do>", ""));
}
function makeMail(x){
	
	x.href = "mailto:"+symat2(liame_str);
}
function liame(x){
	
	document.write("<a onmouseover='makeMail(this);' dir='>' href='>mailto:'>"+ ( (x==-1)?symat(liame_str):"&gt;error occurred&lt;" ) +"</a>");
}

// end mailto functions



// prevent the main Auburn web site from showing up
// in frames on other web sites.  -jcm Feb. 2005
// Copied from http://www.auburn.edu/includes/ddjavascript.js -agm Aug. 2007
if ( window.parent != window.self ) { window.open(document.location,'_top'); }


// Functions for the popups
// June 25, 2008 [Evan]: Added setting focus to greybg because IE sucks.
function pop_viewx(){
	try{
		document.getElementById("greybg").style.height = document.body.clientHeight;
		document.getElementById("greybg").style.display = "block";
		document.getElementById("opt").style.display = "block";
		document.getElementById("greybg").focus();
	}
	catch(e){alert(e);}
}// end pop_viewx();

function pop_closex(){
	try{
		document.getElementById("greybg").style.height = 0;
		document.getElementById("greybg").style.display = "none";
		document.getElementById("opt").style.display = "none";
	}
	catch(e){alert(e);}
}// end pop_closex();

// end functions for popups

function is_array(x){
	if ( typeof x == "object" && x != null ) return true;
	else return false;
}// end Fucntion is_array(x)

/*this function creates an XMLHttpRequest object and returns it.*/
function get_ajax(){
	var xmlHttp=null; //initialize to null
	try{
		xmlHttp=new XMLHttpRequest(); //try this for firefox
	}
	catch (e){//uh-oh! error!
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");//try for another browser
		}
		catch (e){//if that fails
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");//try for ie
		}
	}
	return xmlHttp;//return the object
}


