function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
	}
	return null;
}

function SetCookie (name, value, expires) {

	document.cookie = (name + "=" + escape(value)) +
		("; expires=" + expires.toGMTString()) + 
		("; path=/ ");
}

var focusOnSearch = GetCookie("focusOnSearch");
	
function openme(myDoc, myWidth, myHeight, wName, wScrollBars) {
	var xMax, yMax, xOffset, winPrefix

	winPrefix = "toolbar=no, menubar=no, directories=no, location=no, scrollbars=" + wScrollBars + ", resizable=yes, ";

	if (document.all) {
		xMax = screen.width, yMax = screen.height;
	} else if (document.layers || document.getElementById) {
		xMax = window.outerWidth, yMax = window.outerHeight;
	} else {
		xMax = 800, yMax = 600;
	}

	xOffset = (xMax - myWidth)/2, yOffset = (yMax - myHeight)/2;
	
	window.open(myDoc,'_blank', winPrefix + 'width=' + myWidth + ',height=' + myHeight + ',screenX=' + xOffset + ',screenY=' + yOffset + ',top=' + yOffset + ',left=' + xOffset + '');
}

function toggle(the_sub) {
	// Prefix all Div's that will be hidden/shown with the follow text
	var menu_prefix = "menu_";

	// Get a list of all div's on the page
	var subs_array = document.getElementsByTagName("div")

	// Hide all div's that match the menu_prefix
	for (i=0;i<subs_array.length;i++) {
		if (String(subs_array.item(i).id).substring(0,5) == menu_prefix) {
			var my_sub = document.getElementById(subs_array.item(i).id);
			my_sub.style.display = "none";
		}
	}

	// Show the div that you want expanded
	document.getElementById(the_sub).style.display = "block";
}
	
