// JavaScript Document
var currentMenu = null;

if (!document.getElementById)
	document.getElementById = function() { return null; }

/* Include the required stylesheet */


{
	document.write('<style media="screen" type="text/css">@import url(stylesheet.css);</style>\n'
				 + '<link rel="alternate stylesheet" type="text/css" href="stylesheet.css" title="Big Text" media="screen">\n'
				 + '<link rel="alternate stylesheet" type="text/css" href="stylesheet_contrast.css" title="High Contrast" media="screen">\n'
				 + '<link rel="stylesheet" type="text/css" href="stylesheet_print.css" title="Print Stylesheet" media="print">\n');
}

function ChooseStyle(aStyle)
{
	var expdate = new Date();
	expdate.setTime(expdate.getTime() + (1000*3600*24*365));
	document.cookie = 'style=' + aStyle + '; expires=' + expdate.toGMTString() + '; path=/';
	self.location = self.location;
}

function initializeMenu(menuId, actuatorId, actuatorLinkId) {
	var menu = document.getElementById(menuId);
	var actuator = document.getElementById(actuatorId);
	var actuatorLink = document.getElementById(actuatorLinkId);

	if (menu == null || actuator == null || actuatorLink == null) return;

	//if (window.opera) return; // I'm too tired

	actuator.onmouseover = function() {
		if (currentMenu) {
			currentMenu.style.visibility = "hidden";
			this.showMenu();
		}
		else
		{
			this.showMenu();
		}
	}
  
	actuator.onmouseout = function() {
		currentMenu.style.visibility = "hidden";
		currentMenu = null;
		actuatorLink.style.paddingBottom = '0px';
		actuatorLink.style.paddingTop = '0px';
		return false;
	}

	actuator.showMenu = function() {
		menu.style.left = this.offsetLeft + "px" ;
		menu.style.top = this.offsetTop + this.offsetHeight + 3 + "px";
		actuatorLink.style.paddingBottom = '4px';
		actuatorLink.style.paddingTop = '3px';
		menu.style.visibility = "visible";
		currentMenu = menu;
	}
}

window.onload = function() {
	initializeMenu("familyMenu", "familyActuator", "familyLink");
	initializeMenu("workMenu", "workActuator", "workLink");
	initializeMenu("playMenu", "playActuator", "playLink");
	
	/* Associate logo's onclick event with home page */
	var logo = document.getElementById('logo');
	if (logo != null)
	{
		logo.onclick = function() 
		{
			window.location='index.htm   ';
			return false;
		}
	}
	
	/* Associate style links's onclick events with the relevant action */
	var defaultstylelink = document.getElementById('defaultstylelink');
	if (defaultstylelink != null)
	{
		defaultstylelink.onclick = function() 
		{
			ChooseStyle('default');
			return false;
		}
	}
	
	
}

