function search_focus () {
	if (!document.getElementById) return null;
	if (document.getElementById("searchInput")) {
		document.searchform.search.focus();
	}
	else if (document.getElementById("user")) {
		document.getElementById("user").focus();
	}
}

//sets the menu highlighting when Menu, Glossary, or Help pages are active
function set_menu () {
	var docpathname = location.pathname;
	if (docpathname.indexOf('menu') > -1) {
		var menuSearch=document.getElementById('m01');
		menuSearch.className='';
		var menuMenu=document.getElementById('m02');
		menuMenu.className='menuhot';
	}
	else if (docpathname.indexOf('glos') > -1) {
		var menuSearch=document.getElementById('m01');
		menuSearch.className='';
		var menuGlos=document.getElementById('m03');
		menuGlos.className='menuhot';
	}
	else if (docpathname.indexOf('aowa') > -1) {
		var menuSearch=document.getElementById('m01');
		menuSearch.className='';
		var menuHelp=document.getElementById('m04');
		menuHelp.className='menuhot';
	}
}

//set the font size according to the user's preference, called by setFontSize() or user click
function chgFnt(x) {
	var bodyID = document.getElementById("pagebody");
	setCookie(x);
	switch(x) {
		case "1":
			bodyID.style.fontSize="small";
			break;
		case "2":
			bodyID.style.fontSize="medium";
			break;
		case "3":
			bodyID.style.fontSize="large";
			break;
	}
	return false
}

//saves the font size preference to a cookie, expires in one year
function setCookie(x) {
	var nextyear = new Date();
	nextyear.setFullYear(nextyear.getFullYear() + 1);
	document.cookie = "iukbtext=" + x + "; expires=" + nextyear.toGMTString() + "; path=/";
}

//sets the font size according to the cookie value, called by onload
function setFontSize() {
	var allCookies = document.cookie;
	var pos = allCookies.indexOf("iukbtext=");
	if (pos != -1) {
		var start = pos + 9;
		var end = allCookies.indexOf(";", start);
		if (end == -1) end = allCookies.length;
		var value = allCookies.substring(start, end);
		chgFnt(value);
	}
}

function setSearchOptions(searchRealm) {
	if (document.getElementById) {
		var arcChoice = document.getElementById("archivedChoiceForm");
		var docCount = document.getElementById("documentCount");
	
		if (searchRealm == "KB") {
			arcChoice.disabled = false;
			docCount.disabled = false;
		}
		else {
			arcChoice.disabled = true;
			docCount.disabled = true;
		}
	}
}

function initLogin() {
	if (document.getElementById) {
		var loginLink = document.getElementById("loginLink");
		var closeLink = document.getElementById("closeLink");
		loginLink.onclick = showLogin;
		closeLink.onclick = hideLogin;
	}
}

function showLogin() {
	if (document.getElementById) {
		var loginPopup = document.getElementById("loginForm");
		loginPopup.className = "show";
	}
}

function hideLogin() {
	if (document.getElementById) {
		var loginPopup = document.getElementById("loginForm");
		loginPopup.className = "hide";
	}
}