function setCookie(name, value, path, domain, expires, secure) {
	var curCookie = name + "=" + escape(value) +
			"; expires=" + String("Sun, 31 Dec 2006 00:00:00 GMT") +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			((secure) ? "; secure" : "");
	document.cookie = curCookie;
}



function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}



function changeStyle(styleName) {
	styleName = document.styleChoiceForm.themeSelection.value;
	
	setCookie( 'T57style', styleName, '/' );
	location.href = location.href;
	hideChooser();
}



function checkForPersonalStyle() {
	var styleName = getCookie( 'T57style' );
	if (styleName != null && styleName != 'null') {
		document.write("<link href='/images/menus/" + styleName + "/css.css' rel='stylesheet' type='text/css' id='personalizedMenu'/>");
	}
}


function showChooser() {
	collapsed = document.getElementById("collapsedThemeChooser");
	expanded = document.getElementById("expandedThemeChooser");

	expanded.style.visibility = "visible";
	expanded.style.height = "auto";
	expanded.style.overflow = "visible";
	expanded.style.marginBottom = "10px";
	expanded.style.marginTop = "10px";
	
	expanded.style.top = collapsed.style.top;
	
	collapsed.style.visibility = "hidden";
}

function hideChooser() {
	collapsed = document.getElementById("collapsedThemeChooser");
	expanded = document.getElementById("expandedThemeChooser");

	expanded.style.visibility = "hidden";
	expanded.style.height = "0px";
	expanded.style.overflow = "hidden";
	expanded.style.marginTop = "0px";
	expanded.style.marginBottom = "0px";
	
	expanded.style.top = collapsed.style.top;
	
	collapsed.style.visibility = "visible";
}

antelopeColor = "#8C5F00";
antelopeText = "#FFFFFF";
bearColor = "#333333";
bearText = "#FFFFFF";
beaverColor = "#CC0000";
beaverText = "#FFFFFF";
bobwhiteColor = "#FF6600";
bobwhiteText = "#FFFFFF";
buffaloColor = "#990099";
buffaloText = "#FFFFFF";
eagleColor = "#FFCC00";
eagleText = "#3C3000";
foxColor = "#035803";
foxText = "#FFFFFF";
owlColor = "#006699";
owlText = "#FFFFFF";


function changeTempColor() {
	tc = document.getElementById("expandedThemeChooser");
	th = document.getElementById("expandedThemeHeader");
	tcColor = eval(document.styleChoiceForm.themeSelection.value + 'Color');
	thColor = eval(document.styleChoiceForm.themeSelection.value + 'Text');
	tc.style.borderColor = tcColor;
	th.style.backgroundColor = tcColor;
	th.style.color = thColor;
	reallyChangeColor( document.styleChoiceForm.themeSelection.value );
}


checkForPersonalStyle();
