ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ns6 = ((navigator.vendor == "Netscape6")||(navigator.product == "Gecko"))&& (parseInt(navigator.productSub)>=20010710)? true:false

var subMenuShowing = "none";
var onMainMenu = "no";
var onSubMenu = "no";
var menuNumber = "";
var intervalTimeID;
var mainItemHighlighted = "none";
var mainMenuItem = "";
var mainBodyTextLoaded = "no";

var acceptablebrowser = "no";
if (ie4) { acceptablebrowser = "yes" } 
if (ns4) { acceptablebrowser = "yes" }
if (ns6) { acceptablebrowser = "yes" }

if (acceptablebrowser != "yes") {
	self.location = "/misc/wrongbrowser.html";
} 

function bodyTextIsLoaded() {
	mainBodyTextLoaded = "yes";
}


function mouseOverMainMenuItem(menuitem,mainitem)  {
	clearInterval(intervalTimeID);
	onMainMenu = "yes";
	showSubMenu(menuitem,mainitem);
}

function mouseOutMainMenuItem(mainitem)  {
	onMainMenu = "no";
	waitASec();
}

function mouseOverSubMenuItem()  {
	clearInterval(intervalTimeID);
	onSubMenu = "yes";
}

function mouseOutSubMenuItem()  {
	onSubMenu = "no";
	waitASec();
}

function showSubMenu(menuNumber,mainMenuItem)  {

	if (subMenuShowing != "none")  {
		hideSubMenu(subMenuShowing,mainItemHighlighted);
	}
	if (ns4) {
		if (mainBodyTextLoaded == "yes")  {
			menuToShow = eval("document." + menuNumber);
			menuToShow.visibility = "show";
			menuToHighlight = eval("document.menubackground.document." + mainMenuItem);
			menuToHighlight.visibility = "show"; 
		}
	}
	if (ns6) {
		if (mainBodyTextLoaded == "yes")  {
			menuToShow = eval("document.getElementById('" + menuNumber + "').style");
			menuToShow.visibility = "visible";
			menuToHighlight = eval("document.getElementById('" + mainMenuItem + "').style");
			menuToHighlight.visibility = "visible";
		}
	}
	if (ie4) {
		menuToShow = eval(menuNumber + ".style");
		menuToShow.visibility = "visible"; 
		menuToHighlight = eval(mainMenuItem + ".style");
		menuToHighlight.visibility = "visible"; 
	}
	subMenuShowing = menuNumber;
	mainItemHighlighted = mainMenuItem;
}

function hideSubMenu(menuNumber,mainMenuItem)  {

	if (ns4) {
		if (mainBodyTextLoaded == "yes")  {
			menuToShow = eval("document." + menuNumber);
			menuToShow.visibility = "hide";
			menuToHighlight = eval("document.menubackground.document." + mainMenuItem);
			menuToHighlight.visibility = "hide";
		}
	}
	if (ns6) { 
		if (mainBodyTextLoaded == "yes")  {
			menuToShow = eval("document.getElementById('" + menuNumber + "').style");
			menuToShow.visibility = "hidden";
			menuToHighlight = eval("document.getElementById('" + mainMenuItem + "').style");
			menuToHighlight.visibility = "hidden";
		}
	}
	if (ie4) {
		menuToShow = eval(menuNumber + ".style");
		menuToShow.visibility = "hidden";
		menuToHighlight = eval(mainMenuItem + ".style");
		menuToHighlight.visibility = "hidden";
	}
	subMenuShowing = "none";
	mainMenuHighlighted = "none";
}

function waitASec()  {
	intervalTimeID = (window.setInterval ('checkMouse()', 1000));
}

function checkMouse()  {
	if ((onMainMenu == "no") && (onSubMenu == "no") && (subMenuShowing != "none")) {
		hideSubMenu(subMenuShowing,mainItemHighlighted);
	} 
}

function initialise() {	
	bodyTextIsLoaded();
	pulloutActive = 0;
	if (ns4) {
		experience = document.pulloutInterface.document.pulloutContent.document.textexperience;
		education = document.pulloutInterface.document.pulloutContent.document.texteducation;
		skills = document.pulloutInterface.document.pulloutContent.document.textskills;
		achievements = document.pulloutInterface.document.pulloutContent.document.textachievements;
//		websites = document.pulloutInterface.document.pulloutContent.document.textwebsites;
	}
	if (ns6) {
		experience = document.getElementById('textexperience').style;
		education = document.getElementById('texteducation').style;
		skills = document.getElementById('textskills').style;
		achievements = document.getElementById('textachievements').style;
	//	websites = document.getElementById('textwebsites').style;
	}
	if (ie4) {
		experience = textexperience.style;
		education = texteducation.style;
		skills = textskills.style;
		achievements = textachievements.style;
	//	websites = textwebsites.style;
	}

	pulloutShown = experience;         
	pulloutShown.xpos = 0;
	pulloutNew = "none";                      
	pulloutNew.xpos = -600;
}

// Pullout Function, starts the sequence
function pullout(which) { 
	if (!pulloutActive && pulloutShown != which) {
		pulloutActive = 1;  // this makes it so you can't start it again until it's finished
		pulloutNew = which;
		pulloutNew.xpos = -600;
		pulloutLeft(); 
	}
}

// Slide the old layer out of view
function pulloutLeft() { 
	if (pulloutShown.xpos > -600) { 
		pulloutShown.xpos -= 25;
		pulloutShown.left = pulloutShown.xpos;
		setTimeout("pulloutLeft()",1);
	} else {
		hide(pulloutShown);
		show(pulloutNew);
		pulloutRight();
	}
}

// Slide the new layer into view
function pulloutRight() {
	if (pulloutNew.xpos < 0) {
		pulloutNew.xpos += 25;
		pulloutNew.left = pulloutNew.xpos;
		setTimeout("pulloutRight()",1);
	} else {
		pulloutShown = pulloutNew;
		pulloutActive = 0;  // stops the sequence
	}
}

// Show/Hide Functions
function show(showobj) {
	if (ns4) showobj.visibility = "show";
	if (ie4||ns6) showobj.visibility = "visible";
}

function hide(hideobj) {
	if (ns4) hideobj.visibility = "hide";
	if (ie4||ns6) hideobj.visibility = "hidden";
}

