// Suppresses all JavaScript error dialogs
window.onerror = null;

var menuActive = 0;
var onLayer;
var timeOn = null;


// Shows a layer according to name
function showLayer(layerName) {
	if (timeOn != null) {
    		clearTimeout(timeOn);
    		hideLayer(onLayer);
  	}
 
	if (document.getElementById) {
		document.getElementById(layerName).style.visibility = "visible";
	} 
	else if (document.layers) {
		document.layers[layerName].visibility = "show";
	} 
	else if (document.all) {
    	document.all[layerName].style.visibility = "visible";
  	}
  	onLayer = layerName;
}



var selectedLink = "";
function changeStyles(a1Pos, a2Pos, a3Pos ) {
	var basePath = document.getElementById("basePath").value;
	var a1 = document.getElementById("a1");
	a1.style.backgroundRepeat = "no-repeat";
	var a1Top = "0px "+a1Pos;
	a1.style.backgroundPosition = a1Top;
	
	var a2 = document.getElementById("a2");
	a2.style.backgroundRepeat = "no-repeat";
	var a2Top = "0px "+a2Pos;
	a2.style.backgroundPosition = a2Top;
	
	var a3 = document.getElementById("a3");
	a3.style.backgroundRepeat = "no-repeat";
	var a3Top = "0px "+a3Pos;
	a3.style.backgroundPosition = a3Top;
	
	
	if(selectedLink == "a1")
	{
		a1.style.backgroundPosition = "0px 0px";
	}
	else if(selectedLink == "a2")
	{
		a2.style.backgroundPosition = "0px 0px";
	}
	else if(selectedLink == "a3")
	{
		a3.style.backgroundPosition = "0px 0px";
	} 
	
	
}
function onMouseOverHandler(obj) {
	
	if(obj.id == "a1") {
		changeStyles("-37px", "-74px", "-74px");
	} else if(obj.id == "a2") {
		changeStyles("-74px", "-37px", "-74px");
	} else if (obj.id == "a3") {
		changeStyles("-74px", "-74px", "-37px");
	}
}
function onMouseOutHandler(obj) {
	changeStyles("-74px", "-74px", "-74px");
}
function setStyle(obj) {
	selectedLink = obj.id;
	if(obj.id == "a1") {
		changeStyles("0px", "-74px", "-74px");
	} else if(obj.id == "a2") {
		changeStyles("-74px", "0px", "-74px");
	} else if (obj.id == "a3") {
		changeStyles("-74px", "-74px", "0px");
	}
}

// Hides the layer
// This function isn't called in the HTML page but it's used below in the timeout function
function hideLayer(layerName) {
	if (menuActive == 0) {
    		if (document.getElementById) {
      			document.getElementById(layerName).style.visibility = "hidden";
    		}
			else if (document.layers) {
      			document.layers[layerName].visibility = "hidden";
    		} 
			else if (document.all) {
      			document.all[layerName].style.visibility = "hidden";
    		}
  	}
}



// Shows up when you roll the mouse over a menu item
function menuOver() {
	clearTimeout(timeOn);
	menuActive = 1;
}


// Hides after a brief pause when you roll the mouse off the menu
// Change the 400 to higher and lower numbers to affect this code
function menuOut() {
	menuActive = 0;
	timeOn = setTimeout("hideLayer(onLayer)", 400);
}


function textSizeControl() {
	var size = getCookie("fontSize");
	if(size == "20") {
		setStyle(document.getElementById("a3"));
	} else if(size == "17") {
		setStyle(document.getElementById("a2"));
	} else {
		setStyle(document.getElementById("a1"));
	}
}

