var menuActiveLeft = new Image;
var menuActiveRight = new Image;
var menuActiveBg = new Image;
var menuLeft = new Image;
var menuRight = new Image;
var menuBg = new Image;
var menuArray = new Array();
menuArray.push(["HOME", "index.html", true]);
menuArray.push(["About us", [["Brief history", "1_0.html"], ["Aims &amp; Objectives", "1_1.html"]], true]);
menuArray.push(["Education", [["What is Neo-Humanist Education?", "2_0.html"], ["Curriculum &amp; Teaching Methods", "2_1.html"], ["Second Step", "2_2.html"], ["Themes", "2_3.html"], ["The playschool", "2_4.html"], ["Literacy program", "2_5.html"]], true]);
menuArray.push(["Practical Sunrise", [["Admissions", "3_0.html"], ["Fees", "3_1.html"], ["Lunch &amp; Snacks", "3_2.html"], ["The Danish kommune", "3_3.html"], ["Hours", "3_4.html"], ["Parents", "3_5.html"]], true]);
menuArray.push(["Calendar", "4_0.html", true]);
menuArray.push(["Gallery", "5_0.html", false]);
menuArray.push(["Contact", "6_0.html", true]);
menuArray.push(["Jobs", "7_0.html", true]);
menuArray.push(["e-Circle", "http://intranet.sunrisepreschool.dk", false]);
function makeMenu() {
	var outPutString = "";
	var subOutPutString = "";
	for (var i = 0; i < menuArray.length; i++) {
		//
		//topmenu
		//
		if(menuArray[i][2]){
			if (i == thisPage) {
				outPutString += "<div id=\"menu_" + i + "\" class=\"menuActive\" onmouseout=\"doMouseOut('" + i + "')\" onmouseover=\"doMouseOver('" + i + "')\">";
				outPutString += "<div id=\"menuActiveLeftBorder\" class=\"menuBorder\"><img id=\"MLB" + i + "\" border=0 src=\"images/menuActiveLeft.gif\" width=4 height=37 /></div>";
				outPutString += "<div id=\"menuText" + i + "\" class=\"menuTextActive\">";
				if (typeof menuArray[i][1] == "object") {
					outPutString += "<span>" + menuArray[i][0]+ "</span>";
				} else {
					outPutString += "<a onmouseout=\"doMouseOut('" + i + "')\" onmouseover=\"doMouseOver('" + i + "')\" href=\"";
					outPutString += menuArray[i][1] + "\">" + menuArray[i][0] + "</a>";
				}
				outPutString += "</div>";
				outPutString += "<div id=\"menuActiveRightBorder\" class=\"menuBorder\"><img id=\"MRB" + i + "\" border=0 src=\"images/menuActiveRight.gif\" width=9 height=37 /></div>";
				outPutString += "</div>";
			} else {
				outPutString += "<div id=\"menu_" + i + "\" class=\"menu\" onmouseover=\"doMouseOver('" + i + "')\" onmouseout=\"doMouseOut('" + i + "')\">";
				outPutString += "<div id=\"menuLeftBorder\" class=\"menuBorder\"><img id=\"MLB" + i + "\" border=0 src=\"images/menuLeft.gif\" width=4 height=37 /></div>";
				outPutString += "<div id=\"menuText" + i + "\" class=\"menuTextNav\">";
				if (typeof menuArray[i][1] == "object") {
					outPutString += "<span>" + menuArray[i][0]+ "</span>";
				} else {
					outPutString += "<a onmouseout=\"doMouseOut('" + i + "')\" onmouseover=\"doMouseOver('" + i + "')\" href=\"";
					outPutString += menuArray[i][1] + "\">" + menuArray[i][0] + "</a>";
				}
				outPutString += "</div>";
				outPutString += "<div id=\"menuRightBorder\" class=\"menuBorder\"><img id=\"MRB" + i + "\" border=0 src=\"images/menuRight.gif\" width=9 height=37 /></div>";
				outPutString += "</div>";
			}
			//
			//Submenu
			//
			
			if (typeof menuArray[i][1] == "object") {
				subOutPutString += "<div onmouseout=\"doMouseOut('" + i + "')\" onmouseover=\"doMouseOver('" + i + "')\" id=\"subMenu" + i + "\" style=\"position:absolute; top: 37px; display:none\">";
				subOutPutString += "<div style=\"width:192px; height:3px;\"><img id=\"subMenu_01\" src=\"images/subMenu_01.gif\" width=\"192\" height=\"3\" /></div>";
				subOutPutString += "<div style=\"width:192px; padding:0px 1px 0px 1px; background-image:url(images/subMenu_088.gif); background-repeat:repeat-y;\">";
				subOutPutString += "<div style=\"width:189px; background-color:#f1eed4; background-repeat:repeat-x; background-image:url(images/subMenu_03.gif); background-position:bottom;\">";
				subOutPutString += "<div style=\"padding:4px 3px;\">";
				for (var j = 0; j < menuArray[i][1].length; j++) {
					subOutPutString += "<a href=\"" + menuArray[i][1][j][1] + "\" class=\"sublevel\">" + menuArray[i][1][j][0] + "</a>";
				}
				subOutPutString += "</div>";
				subOutPutString += "</div>";
				subOutPutString += "</div>";
				subOutPutString += "<div style=\"width:192px; height:4px;\"><img id=\"subMenu_05\" src=\"images/subMenu_05.gif\" width=\"192\" height=\"4\" alt=\"\" /></div>";
				subOutPutString += "</div>";
			}
		}
	}
	var output = outPutString + subOutPutString
	//alert(output)
	document.writeln(outPutString + subOutPutString);
}
function makePageSubMenu() {
	var outPutString = "";
	var linkString1 = "";
	var linkString2 = "";
	for (var j = 0; j < menuArray[thisPage][1].length; j++) {
		if (j < 3) {
			linkString1 += "<a href=\"" + menuArray[thisPage][1][j][1] + "\" class=\"pageSublevel\">" + menuArray[thisPage][1][j][0] + "</a>";
		} else {
			linkString2 += "<a href=\"" + menuArray[thisPage][1][j][1] + "\" class=\"pageSublevel\">" + menuArray[thisPage][1][j][0] + "</a>";
		}
	}
	outPutString = "<div style=\"position:absolute; left:0px; top:0px; width:180px; height:50px\">" + linkString1 + "</div>";
	outPutString += "<div style=\"position:absolute; left:180px; top:0px; width:170px; height:50px\">" + linkString2 + "</div>";
	document.writeln(outPutString);
}
function newimage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
var preloadflag = false;
function preloadimages() {
	if (document.images) {
		menuActiveLeft.src= "images/menuActiveLeft.gif";		
		menuActiveRight.src= "images/menuActiveRight.gif";
		menuActiveBg.src= "images/menuActiveBg.gif";
		menuLeft.src= "images/menuLeft.gif";
		menuRight.src= "images/menuRight.gif";
		menuBg.src= "images/menuBg.gif";
		preloadflag = true;
	}
}

// Example:

// simplePreload( '01.gif', '02.gif' ); 

function simplePreload()

{ 

  var args = simplePreload.arguments;

  document.imageArray = new Array(args.length);

  for(var i=0; i<args.length; i++)

  {

    document.imageArray[i] = new Image;

    document.imageArray[i].src = args[i];

  }

}
var timeout;
var active = -1;
var old = -1;
function setActive(nr){
	old = active;
	active = nr;
	if (old != -1 && old != active) {
		hide(old);
	}
	resetHide(nr)
}


function hideWait(nr){
	clearTimeout(document.getElementById("menu_" + nr).timeout);
	document.getElementById("menu_" + nr).timeout = setTimeout("hide('" + nr + "')", 500);
}
function resetHide(nr){
	clearTimeout(document.getElementById("menu_" + nr).timeout);
}

function hide(nr) {	
	if (nr != thisPage) {
		document.getElementById("MLB" + nr).src = menuLeft.src;
		document.getElementById("MRB" + nr).src = menuRight.src;
		document.getElementById("menu_" + nr).style.backgroundImage = "url(" + menuBg.src + ")";
		document.getElementById("menuText" + nr).className = "menuTextNav";
	}
	if (typeof menuArray[nr][1] == "object") {
		document.getElementById("subMenu" + nr).style.display = "none";
	}
	if(active==nr){
		active = -1;
	}
	clearTimeout(document.getElementById("menu_" + nr).timeout);
}


function doMouseOver(nr) {
	document.getElementById("MLB" + nr).src = menuActiveLeft.src;
	document.getElementById("MRB" + nr).src = menuActiveRight.src;
	document.getElementById("menu_" + nr).style.backgroundImage = "url(" + menuActiveBg.src + ")";
	document.getElementById("menuText" + nr).className = "menuTextActive";
	if (typeof menuArray[nr][1] == "object") {
		document.getElementById("subMenu" + nr).style.display = "block";
		document.getElementById("subMenu" + nr).style.left = document.getElementById("menu_" + nr).offsetLeft + "px";
	}
	setActive(nr)	
}
function doMouseOut(nr) {	
	if (typeof menuArray[nr][1] == "object") {		
		hideWait(nr);
	}else{
		hide(nr);
	}
}


