/*==== START SNIFFER, see: http://www.webreference.com/tools/browser/javascript.html for revisions ====*/
	/* NOTE: this browser sniffer has been chosen due to its wide-use and frequent updates. It has been
	 * well tested and is free. It can be stripped down if size is an issue, but this will need to be
	 * done to any updates as well.
	 */

	// JavaScript Browser Sniffer
	// Eric Krok, Andy King, Michel Plungjan Jan. 31, 2002
	// see http://www.webreference.com/ for more information
	//
	// This program is free software; you can redistribute it and/or modify
	// it under the terms of the GNU General Public License as published by
	// the Free Software Foundation; either version 2 of the License, or
	// (at your option) any later version.
	//
	// please send any improvements to aking@internet.com and we'll
	// roll the best ones in

	var agt=navigator.userAgent.toLowerCase();
	var appVer = navigator.appVersion.toLowerCase();
	var is_minor = parseFloat(appVer);
	var is_major = parseInt(is_minor);
	var is_opera = (agt.indexOf("opera") != -1);
	var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
	var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
	var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
	var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
	var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);
	var is_opera7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1);
	var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);
	var is_opera6up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5);
	var is_opera7up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5 && !is_opera6);
	var iePos = appVer.indexOf('msie');
	if (iePos !=-1) {
		is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)))
		is_major = parseInt(is_minor);
	}
	var is_konq = false;
	var kqPos = agt.indexOf('konqueror');
	if (kqPos !=-1) {
		is_konq = true;
		is_minor = parseFloat(agt.substring(kqPos+10,agt.indexOf(';',kqPos)));
		is_major = parseInt(is_minor);
	}
	var is_getElementById = (document.getElementById) ? "true" : "false";
	var is_getElementsByTagName = (document.getElementsByTagName) ? "true" : "false";
	var is_documentElement = (document.documentElement) ? "true" : "false";
	var is_safari = ((agt.indexOf('safari')!=-1) && (agt.indexOf('mac')!=-1))?true:false;
	var is_khtml = (is_safari || is_konq);
	var is_gecko = ((!is_khtml) && (navigator.product) && (navigator.product.toLowerCase()=="gecko"))?true:false;
	var is_gver = 0;
	if (is_gecko) is_gver=navigator.productSub;
	var is_moz = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1) && (is_gecko) && ((navigator.vendor=="") || (navigator.vendor=="Mozilla") || (navigator.vendor=="Debian")));
	var is_fb = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1) && (is_gecko) && (navigator.vendor=="Firebird"));
	var is_fx = ((agt.indexOf('mozilla/5')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1) && (is_gecko) && (navigator.vendor=="Firefox"));
	if ((is_moz) || (is_fb) || (is_fx)) {
		var is_moz_ver = (navigator.vendorSub)?navigator.vendorSub:0;
		if(!(is_moz_ver)) {
			is_moz_ver = agt.indexOf('rv:');
			is_moz_ver = agt.substring(is_moz_ver+3);
			is_paren = is_moz_ver.indexOf(')');
			is_moz_ver = is_moz_ver.substring(0,is_paren);
		}
		is_minor = is_moz_ver;
		is_major = parseInt(is_moz_ver);
	}
	var is_fb_ver = is_moz_ver;
	var is_fx_ver = is_moz_ver;
	var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1) && (!is_khtml) && (!(is_moz)) && (!is_fb) && (!is_fx));
	if ((navigator.vendor) && ((navigator.vendor=="Netscape6") || (navigator.vendor=="Netscape")) && (is_nav)) {
		is_major = parseInt(navigator.vendorSub);
		is_minor = parseFloat(navigator.vendorSub);
	}
	var is_nav2 = (is_nav && (is_major == 2));
	var is_nav3 = (is_nav && (is_major == 3));
	var is_nav4 = (is_nav && (is_major == 4));
	var is_nav4up = (is_nav && is_minor >= 4);
	var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) );
	var is_nav6 = (is_nav && is_major==6);
	var is_nav6up = (is_nav && is_minor >= 6)
	var is_nav5 = (is_nav && is_major == 5 && !is_nav6);
	var is_nav5up = (is_nav && is_minor >= 5);
	var is_nav7 = (is_nav && is_major == 7);
	var is_nav7up = (is_nav && is_minor >= 7);
	var is_ie = ((iePos!=-1) && (!is_opera) && (!is_khtml));
	var is_ie3 = (is_ie && (is_major < 4));
	var is_ie4 = (is_ie && is_major == 4);
	var is_ie4up = (is_ie && is_minor >= 4);
	var is_ie5 = (is_ie && is_major == 5);
	var is_ie5up = (is_ie && is_minor >= 5);
	var is_ie5_5 = (is_ie && (agt.indexOf("msie 5.5") !=-1));
	var is_ie5_5up =(is_ie && is_minor >= 5.5);
	var is_ie6 = (is_ie && is_major == 6);
	var is_ie6up = (is_ie && is_minor >= 6);
	var is_aol = (agt.indexOf("aol") != -1);
	var is_aol3 = (is_aol && is_ie3);
	var is_aol4 = (is_aol && is_ie4);
	var is_aol5 = (agt.indexOf("aol 5") != -1);
	var is_aol6 = (agt.indexOf("aol 6") != -1);
	var is_aol7 = ((agt.indexOf("aol 7")!=-1) || (agt.indexOf("aol7")!=-1));
	var is_aol8 = ((agt.indexOf("aol 8")!=-1) || (agt.indexOf("aol8")!=-1));
	var is_webtv = (agt.indexOf("webtv") != -1);
	var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1));
	var is_AOLTV = is_TVNavigator;
	var is_hotjava = (agt.indexOf("hotjava") != -1);
	var is_hotjava3 = (is_hotjava && (is_major == 3));
	var is_hotjava3up = (is_hotjava && (is_major >= 3));
	var is_js;
	if (is_nav2 || is_ie3) is_js = 1.0;
	else if (is_nav3) is_js = 1.1;
	else if ((is_opera5) || (is_opera6)) is_js = 1.3;
	else if (is_opera7up) is_js = 1.5;
	else if (is_khtml) is_js = 1.5;
	else if (is_opera) is_js = 1.1;
	else if ((is_nav4 && (is_minor <= 4.05)) || is_ie4) is_js = 1.2;
	else if ((is_nav4 && (is_minor > 4.05)) || is_ie5) is_js = 1.3;
	else if (is_nav5 && !(is_nav6)) is_js = 1.4;
	else if (is_hotjava3up) is_js = 1.4;
	else if (is_nav6up) is_js = 1.5;
	else if (is_nav && (is_major > 5)) is_js = 1.4;
	else if (is_ie && (is_major > 5)) is_js = 1.3;
	else if (is_moz) is_js = 1.5;
	else if (is_fb || is_fx) is_js = 1.5;
	else is_js = 0.0;
	var is_anchors = (document.anchors) ? "true":"false";
	var is_regexp = (window.RegExp) ? "true":"false";
	var is_option = (window.Option) ? "true":"false";
	var is_all = (document.all) ? "true":"false";
	document.cookie = "cookies=true";
	var is_cookie = (document.cookie) ? "true" : "false";
	var is_images = (document.images) ? "true":"false";
	var is_layers = (document.layers) ? "true":"false";
	var is_forms = (document.forms) ? "true" : "false";
	var is_links = (document.links) ? "true" : "false";
	var is_frames = (window.frames) ? "true" : "false";
	var is_screen = (window.screen) ? "true" : "false";
	var is_java = (navigator.javaEnabled());
/*==== END SNIFFER ====*/

function MenuRegistry() {
	this.registeredMenus = new Array();
	this.closeTimer = null;
}
	MenuRegistry.prototype.clearCloseTimer = function() {
		if( this.closeTimer ) {
			clearTimeout( this.closeTimer );
			this.closeTimer = null;
		}
	}
	MenuRegistry.prototype.closeAll = function() {
		for( menuName in this.registeredMenus ) {
			this.registeredMenus[menuName].close();
		}
	}
	MenuRegistry.prototype.delayedClose = function() {
		this.clearCloseTimer();
		this.closeTimer = setTimeout('menuRegistry.closeAll();', 500);
	}
	MenuRegistry.prototype.getMenu = function( menuName ) {
		return this.registeredMenus[menuName];
	}
	MenuRegistry.prototype.open = function( menuName ) {
		this.clearCloseTimer();
		for( thisMenuName in this.registeredMenus ) {
			if( thisMenuName == menuName )
				this.registeredMenus[thisMenuName].open();
			else
				this.registeredMenus[thisMenuName].close();
		}
	}
	/** MenuRegistry.register( Menu )
	 * Registers a menu.
	 **/
	MenuRegistry.prototype.register = function( menu ) {
		this.registeredMenus[menu.name] = menu;
	}
menuRegistry = new MenuRegistry();

function Menu( menuName, isActive, alignRight ) {
	this.name = menuName;
	this.isActive = (isActive) ? true : false;
	this.alignRight = (alignRight) ? true : false;
	var m = document.getElementById(menuName+"Menu");
	this.hasMenu = ( !m ) ? false : true;

	var src = document.images[ this.name + "BtnImg" ].src;
	var btnImgPath = src.substring( 0, src.lastIndexOf("/")+1 );
	this.defaultImage = new Image();
	this.defaultImage.src = src;
	this.activeImage = new Image();
	this.activeImage.src = btnImgPath + this.name + "_active.gif";
	if( this.hasMenu )
		this.lastHeight = getElement("menuWrapper",frames[( this.name + "Frame" )].document).offsetHeight;
	this.sizeSet = false;
	this.sizePosition = false;
	var o = document.getElementById(menuName+"Btn");
	var t = 0;
	var l = 0;
	var h = o.offsetHeight;
	var w = o.offsetWidth;
	do {
		t += o.offsetTop;
		l += o.offsetLeft;
		o = o.offsetParent;
	} while( o.tagName != "BODY" );

	if( this.hasMenu ) {
		if( this.alignRight ) {
			m.style.top = (t+h)+"px";
			m.style.left = (l + w - m.offsetWidth)+"px";
		} else {
			m.style.top = (t+h)+"px";
			m.style.left = (l)+"px";
		}
	}
}
	Menu.prototype.close = function() {
		if( this.hasMenu ) {
			this.getLayer().style.visibility = "hidden";
			getElement(this.name + "Frame" ).height = this.lastHeight + 1;
		}

		if( !this.isActive ) {
			var btnImg = getElement( this.name + "BtnImg" );
			btnImg.src = this.defaultImage.src;
		}
	}
	Menu.prototype.crop = function() {
		if( this.hasMenu ) {
			this.lastHeight = getElement("menuWrapper",frames[( this.name + "Frame" )].document).offsetHeight;
			getElement(this.name + "Frame" ).height = this.lastHeight;
			if( !this.sizeSet && is_cookie ) {
				(new CookieBuilder( this.name + "Height", this.lastHeight )).setCookie();
				this.sizeSet = true;
			}
		}
	}
	Menu.prototype.getButton = function() {
		return getElement( this.name + "Btn" );
	}
	Menu.prototype.getLayer = function() {
		return getElement( this.name + "Menu" );
	}
	Menu.prototype.open = function() {
		if( this.hasMenu ) {
			this.getLayer().style.visibility = "visible";
			this.crop();
		}
		if( !this.isActive ) {
			var btnImg = getElement( this.name + "BtnImg" );
			btnImg.src = this.activeImage.src;
		}
	}
var cookiesArray = new Array();

function parseCookies() {
	var cookie_string = document.cookie;
	var cPairStrings = cookie_string.split("; ");
	for(var pair = 0; pair < cPairStrings.length; pair++){
		var cPair = cPairStrings[pair].split("=");
		cookiesArray[cPair[0]] = cPair[1];
	}
}
parseCookies();

function getCookie( cookieName ) {
	var cVar = "";
	if(cookiesArray[cookieName] != "") cVar = cookiesArray[cookieName];
	return cVar;
}
function CookieBuilder( name, value ){
	this.name = name;
	this.value = "" + value;
	this.expires = new Date();
	this.expires.setTime( this.expires.getTime() + (1000*60*10) );
	this.path = null;
	var host = location.hostname;
	var ip = /^[\d\.]+$/;
	if( ip.test( host ) ) this.domain = host;
	else {
		var splitHost = host.split(".");
		if( splitHost.length == 1 ) this.domain = splitHost[0];
		else this.domain = "." + splitHost[splitHost.length-2] + "." + splitHost[splitHost.length-1];
	}
	this.secure = null;
}
	CookieBuilder.prototype.setCookie = function() {
		var cookie_string = "";
		if(this.name && this.value){
			cookie_string += this.name + "=" + escape(this.value);
			if(this.expires) cookie_string += ";expires=" + this.expires.toGMTString();
			if(this.path) cookie_string += ";path=" + this.path;
			if(this.domain) cookie_string += ";domain=" + this.domain;
			if(this.secure) cookie_string += ";secure";
			document.cookie = cookie_string;
		}
	}


var isLoaded = false;

var canDoMenus = (is_ie5up || is_opera6up || is_khtml || is_gecko);

function getElement( id, inElement ) {
	inElement = (inElement)?inElement:document;
	return inElement.getElementById?inElement.getElementById(id):(inElement.all?inElement.all[id]:null);
}

function btnOver( menuBtn ) {
	if( !(isLoaded && canDoMenus ) ) return;
	var menuName = menuBtn.id.substring(0,menuBtn.id.indexOf("Btn"));
	menuRegistry.open(menuName);
}

function btnOut( menuBtn ) {
	if( !(isLoaded && canDoMenus ) ) return;
	menuRegistry.delayedClose();
}

function itemOver( item ) {
	var holder;
	holder = item.getElementsByTagName("DIV");
	window.parent.menuRegistry.clearCloseTimer();
	if( item.getAttribute( "menuAction" ) ) {
		item.className = item.className + "Active";
		holder[0].className = holder[0].className + "Active";
	}
}

function itemOut( item ) {
	var holder;
	holder = item.getElementsByTagName("DIV");
	window.parent.menuRegistry.delayedClose();
	item.className = item.className.substring( 0, item.className.length - 6 );
	holder[0].className = holder[0].className.substring( 0, holder[0].className.length - 6 );
}

function itemClick( item ) {
	if( item.getAttribute( "menuAction" ) ) {
		eval( item.getAttribute( "menuAction" ) );
		window.parent.menuRegistry.closeAll();
	}
}


function writeMenu( menuName, height ) {
	if( is_cookie ) {
		var cookiedHeight = getCookie( menuName + "Height" );
		if( cookiedHeight ) height = cookiedHeight;
	}
	document.write('<div id="'+menuName+'Menu" style="position: absolute; top: 0px; left: 0px; visibility: hidden;"><iframe src="menus/'+menuName+'Menu.html" name="'+menuName+'Frame" id="'+menuName+'Frame" width="150" height="'+height+'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"><\/iframe><\/div>');
}

