function BrowserInfo() {
	var agent = window.navigator.userAgent;
	if (agent.indexOf("MSIE") != -1) {
			var start = agent.indexOf("MSIE");
			this.name = "MSIE";
			this.version = parseFloat(agent.substring(start + 5, agent.indexOf(";", start)));
	} else if (agent.indexOf("Firefox") != -1) {
			var start = agent.indexOf("Firefox");
			this.name = "Firefox";
			this.version = agent.substring(start + 8, agent.length);
			var firstDec = this.version.indexOf(".") + 1;
			while (this.version.indexOf(".", firstDec) != -1)
				this.version = this.version.substring(0, firstDec) + this.version.substring(firstDec).replace(".", "");
			this.version = parseFloat(this.version);
	} else {
			this.name = "Unknown";
			this.version = 0;
	}
}

var info = new BrowserInfo();
var userAgent = window.navigator.userAgent
var isIE = (window.navigator.userAgent.indexOf("MSIE") != -1);
var isFirefox = (window.navigator.userAgent.indexOf("Firefox") != -1);
var isIE6 = (parseFloat(userAgent.substring(userAgent.indexOf("MSIE ") + 5)) <= 6);
var isSafari = (navigator.userAgent.indexOf("Safari") > 0);
//var isIE6 = (info.name == "MSIE" && info.version < 7);

if (info.name == "MSIE" && info.version < 7)
	document.writeln('<link href="stylesIE6.css" rel="stylesheet" type="text/css" />');
else
	document.writeln('<link href="stylesDynamic.css" rel="stylesheet" type="text/css" />');

if (info.name == "MSIE")
	document.writeln('<link href="stylesIE.css" rel="stylesheet" type="text/css" />');


function writePngImage(url, width, height, alt) {
	if (!isIE6)
		document.write("<img alt=\"" + alt + "\" src=\"" + url + "\" style=\"width: " + width + "px; height: " + height + "px;\">");
	else
		document.write("<img alt=\"" + alt + "\" src=\"spacer.png\" style=\"width: " + width + "px; height: " + height + 
			"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod=scale);\">");
}

function writePngClass(url, width, height, alt, className) {
	if (!isIE6)
		document.write("<img alt=\"" + alt + "\" class=\"" + className + "\" src=\"" + url + "\" style=\"width: " + width + "px; height: " + height + "px;\">");
	else
		document.write("<img alt=\"" + alt + "\" class=\"" + className + "\"  src=\"spacer.png\" style=\"width: " + width + "px; height: " + height + 
			"px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "', sizingMethod=scale);\">");
}

//expanded = true;

function showMenus() {
//	if (expanded == true) {
		toggleElement('sitemap', 3);
		showMoreMenu(true);
/*	} else {
		toggleElement('sitemap', 3);
		hideMoreMenu();
	}*/
}

function toggleElement(id, steps) {
	var html = document.getElementById(id);
	if (html.style.display != "none") {
		html.style.height = html.offsetHeight + "px";
		html.style.overflow = "hidden";
		animStep(id, false, html.offsetHeight, steps);
	} else {
		html.style.display = "";
		html.style.overflow = "";
		html.style.height = "";
		var h = html.offsetHeight;
		html.style.overflow = "hidden";
		html.style.height = "0px";
		animStep(id, true, h, steps);
	}
	
	return false;
}

function animStep(id, expanding, height, steps) {
	var html = document.getElementById(id);
	var newHeight = parseInt(html.style.height);
	speed = height / steps;
	if (expanding) {
		newHeight += speed;
		
		if (newHeight >= height) {
			html.style.height = height + "px";
			html.style.overflow = "";
			return;
		}
		fadeOne();
	} else {
		newHeight -= speed;
		if (newHeight <= 0) {
			html.style.height = "0px";
			html.style.display = "none";
			return;
		}
	}
	
	html.style.height = newHeight + "px";
	setTimeout("animStep('" + id + "', " + expanding + ", " + height + "," + steps + ");", 10);
}

var delay = 30;
var increment = 5;

function fadeOne() {
	var fade1 = document.getElementById("fade1");

	var fadeTxt = document.getElementById("fadeTxt1"); // has to be here for IE
	fadeTxt.style.width = '100%'; // has to be here for IE

	fade1.style.display = '';

	setOpacity("fadeTxt1", 0);
	fadeDiv("fade1", 0);
	return false;
}

function fadeDiv(div,opacity) {
	if (opacity < 100) {
		opacity += increment;
		switch (div) {
			case "fade1":
				setOpacity("fadeTxt1", opacity);
				setTimeout("fadeDiv('fade1'," + opacity + ");", delay);
				break;
			default:	
				setOpacity(div, opacity);
				setTimeout("fadeDiv('" + div + "'," + opacity + ");", delay);
				break;
		}
	}
}

function setOpacity(div_name, opacity) {
	var div = document.getElementById(div_name);
	div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + opacity + ")";
	div.style.MozOpacity = opacity/100;
	div.style.opacity = opacity/100;
}

var hide;
var show;
var Showing = 0;
var menuVisible = false;

function showMoreMenu(force) {
	if (menuVisible == true || force == true) {
		if (Showing==1 && !force) { window.status = new Date().getMilliseconds().toString(); return; }

		Showing = 1;

		clearTimeout(show);

		menuVisible = true;
		show = setTimeout("menuFadeIn('menu_more_dropdown');", 250);
	}
//	expanded = true;
}

function hideMoreMenu(force) {
	clearTimeout(hide);
	hide = setTimeout("start_hideMoreMenu();", 500);
//	expanded = false;
}


function cancelHide() {
	Showing = 1;
	clearTimeout(hide);
}

function start_hideMoreMenu() {
	Showing = 0;

	menuFadeOut('menu_more_dropdown');
}

function menuFadeIn(id) {
	menuFadeInStep(id, 0);
}

function menuFadeInStep(id,val) {
	var more = document.getElementById(id);

	more.style.display = 'block';

	if (val < 100) {
		val = val + 25;
		setOpacity(id, val);
	}	
	if (val != 100) {
		var hdl = setTimeout("menuFadeInStep('" + id + "'," + val + ");",25);
		id = hdl;
	}
	else {
		if (id=="menu_more_dropdown") {
			moreVisible = true;
			more.style.filter = "";
		}
	}
}

function menuFadeOut(id) {
	var element = document.getElementById("id");
	menuFadeOutStep(id, 100);
}

function menuFadeOutStep(id,val) {
	var more = document.getElementById(id);

	if (val > 0) {
		val = val - 10;
		setOpacity(id, val);
	}
	if (val != 0) {
		var hdl = setTimeout("menuFadeOutStep('" + id + "'," + val + ");",25);
		id = hdl;
	}
	else {	
		if (id=="menu_more_dropdown") {
			menuVisible = false;
			more.style.display = 'none';
		}
	}
}

function submitForm(id) {
	document.getElementById(id).submit();
	return false;
}


function renderFlash(src, width, height, features) {
	document.writeln('<embed src="' + src + '" quality="high" width="' + width + 
					 '" height="' + height + '" align="middle" allowscriptaccess="sameDomain" ' +
					 'type="application/x-shockwave-flash" ' + features + 
  					 'pluginspage="http://www.macromedia.com/go/getflashplayer" />');
}
