function showMenu(i){
	hideMenus();
	var menu="menu"+i;
	var el=document.getElementById(menu);
	if (el){
			el.style.visibility="visible";
			document.body.onmousemove=checkXY;
	}
}

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;
var db ="";

function checkXY(e){
	e=(e)? e: ((window.event) ? window.event: null);
	if(e){
		getMouseXY(e);
	}
	el=getOpenMenu();
	if (el){
		var menu=document.getElementById("menublock");
		if (menu){
			menupos= new Position(menu);
		}
		var pos= new Position(el);
		//writetostatus(tempY);
		if (tempX < pos.left){
			if (tempY > menupos.top && tempY < (menupos.bottom)){
				return;
			}
		} else {
			if(tempX <= pos.right && tempY >= pos.top && tempY <= pos.bottom){
				return; //leave menu open unless mouse moves outside of menu area 
			}
		}
		//close the open menu
		document.body.onmousemove=null;
		hideMenus();
		try {
		resetArrows();
		}
		catch (err) {}
	}
}

function Position(elt){
		var x = 0;
		var y = 0;
		var offsetPointer=elt;
			while (offsetPointer) {//loop through parent elements to add offsets. x and y  end up being position of elt
			x += offsetPointer.offsetLeft;
			y += offsetPointer.offsetTop;
			offsetPointer = offsetPointer.offsetParent;
		}
		// correct for MacIE body margin factors
		if (navigator.userAgent.indexOf("Mac") != -1 &&
		typeof document.body.leftMargin != "undefined") {
			x += document.body.leftMargin;
			y += document.body.topMargin;
		}
		this.left=x;
		this.top=y;
		this.height=elt.offsetHeight;
		this.width=elt.offsetWidth;
		this.right=x+this.width;
		this.bottom=y+this.height;
}
function writetostatus(input){
    window.status=input;
    return true;
}

function getMouseXY(e) {
	if (e.pageX || e.pageY) 	{
		tempX = e.pageX;
		tempY = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		tempX = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		tempY = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	} 
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  return true;
}

function getOpenMenu() {
	var menu;
	for (i=1;i<7;i++){
		menu=document.getElementById("menu"+i);
		if (menu)
			if (menu.style.visibility=="visible"){
				return menu;
			}
	}
	return false; 
}

function hideMenu(i){
	var menu="menu"+i;
	var el=document.getElementById(menu);
	if (el){
		el.style.visibility="hidden";
		return true;
	}
	return false; //there is no such menu
}

function hideMenus(){
	var i=0;
	var c;
	do {
		i++;
		c=hideMenu(i);
	} while (c); // repeat until no more menus to hide
		
}

function wf3(){
	var flash="<div id='moodgadget' style='float:right'>"
	flash=flash+"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='201' height='113' id='moodweather' align='middle'>"
	flash=flash+"<param name='allowScriptAccess' value='sameDomain' />"
	flash=flash+"<param name='movie' value='moodweather.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#0066c4' /><embed src='moodweather.swf' quality='high' bgcolor='#0066c4' width='201' height='113' name='moodweather' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
	flash=flash+"</object></div>"
	flash=flash+"<div id='banner' style='width:620'>"
	flash=flash+"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='620' height='113' id='banner' align='middle'>"
	flash=flash+"<param name='allowScriptAccess' value='sameDomain' />"
	flash=flash+"<param name='movie' value='banner.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#0066c4' /><embed src='banner.swf' quality='high' wmode='transparent' bgcolor='#0066c4' width='620' height='113' name='banner' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
	flash=flash+"</object></div>"	

	document.write(flash);
}

function wf1(){

	flash="<div id='menublock'>"
	flash=flash+ "<object id='sidemenu' noexternaldata='true' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='200' height='405' align='middle'>"
	flash=flash+"<param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='flash/side nav bar.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#0066c4' /><embed src='flash/side nav bar.swf' quality='high' bgcolor='#0066c4' width='200' swLiveConnect='true' height='405' name='sidemenu' align='middle' allowScriptAccess='sameDomain'"
	flash=flash+"type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>"
	flash=flash +"</div>"
	if(!isIE()) flash=flash + "<div style='height: 4px'></div>"
	flash=flash+"<div style='text-align: center'>"
	flash=flash+"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' noexternaldata='true' class='AC' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='160' height='150' id='logo' align='middle'>"
	flash=flash+"<param name='allowScriptAccess' value='sameDomain' />"
	flash=flash+"<param name='movie' value='flash/logo.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#0066C4' /><embed src='flash/logo.swf' quality='high' bgcolor='#0066C4' width='160' height='150' name='logo' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>"
	flash=flash+"</div>"
	document.write(flash);
}

function wf2(){
	flash="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' noexternaldata='true' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='500' height='46' id='top nav bar' align='left'>"
	flash=flash+"<param name='allowScriptAccess' value='sameDomain' />"
	flash=flash+"<param name='movie' value='flash/top nav bar.swf' /><param name='quality' value='high' /><param name='bgcolor' value='#0066c4' /><embed src='flash/top nav bar.swf' quality='high' bgcolor='#0066c4' width='500' height='46' name='top nav bar' align='left' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
	flash=flash+"</object>"
	document.write(flash);
}


function resetArrows(){
	if (isIE())
		var flash=document.getElementById("sidemenu");
	else
		var flash=window.document.sidemenu;
	if(flash)
	    flash.restoreArrows();
}

function bodyClick(e){
	getMouseXY(e);
	var el=getOpenMenu();
	if (el){
		var left=el.offsetLeft;
		var right=left+el.offsetWidth;
		var top=el.offsetTop;
		var bottom=top+el.offsetHeight;
		if(tempX <= right)
			if (tempY >= top && tempY <= bottom){
				return; //do not close menus on click, if it occurs within the open menu
			}
		//close the open menu
        hideMenus();
		resetArrows();
	}
}


function isNav() {
return (navigator.appName == "Netscape" && !isOpera() && !isSafari());
}
function isIE() {
return (navigator.appName == "Microsoft Internet Explorer");
}
function isOpera() {
return (navigator.userAgent.indexOf("Opera") != -1);
}
function isSafari() {
return (navigator.userAgent.indexOf("Safari") != -1);
}