/****************************************************************
* design and development - christopher aalholm / apt as - 2001 	*
****************************************************************/

content = new Array();

/* add menuitems using the same style as below */
/* Contact */
	content[0] 	  = new Array();
	content[0][0] = '<a href="#" id="menu0_0" name="menu0_0" class="menu">punkt 1</a>';
	content[0][1] = '<a href="#" id="menu0_1" name="menu0_1" class="menu">punkt 2</a>';
	
/* Research */
	content[1] 	  = new Array();
	content[1][0] = '<a href="ResearchFields.html" id="menu1_0" name="menu1_0" class="menu">Research Fields</a>';
	content[1][1] = '<a href="ResearchProjects.html" id="menu1_1" name="menu1_1" class="menu">Projects</a>';
	content[1][2] = '<a href="Researchers.html" id="menu1_2" name="menu1_2" class="menu">Researchers</a>';
	content[1][3] = '<a href="Publications.html" id="menu1_3" name="menu1_3" class="menu">Publications</a>';
	content[1][4] = '<a href="AcademicEvents.html" id="menu1_4" name="menu1_4" class="menu">Academic Events</a>';

	
/* Exhibition */
	content[2] 	  = new Array();
	content[2][0] = '<a href="Exhibition.html" id="menu2_0" name="menu2_0" class="menu">Permanent Exhibition</a>';
	content[2][1] = '<a href="TemporaryExhibitions.html" id="menu2_1" name="menu2_1" class="menu">Temporary Exhibitions</a>';


/* Education */

	content[3] 	  = new Array();
	content[3][0] = '<a href="SchoolVisits.html" id="menu3_0" name="menu3_0" class="menu">Visit for Pupils</a>';
	content[3][1] = '<a href="TeacherCourses.html" id="menu3_1" name="menu3_1" class="menu">Teacher Courses</a>';
	content[3][2] = '<a href="EduMaterial.html" id="menu3_2" name="menu3_2" class="menu">Educational Material</a>';
	content[3][3] = '<a href="EduNetwork.html" id="menu3_3" name="menu3_3" class="menu">Educational Network</a>';

/* About */
	content[4] 	  = new Array();
	content[4][0] = '<a href="background.html" id="menu4_0" name="menu4_0" class="menu">Background</a>';
	content[4][1] = '<a href="Statutes.html" id="menu4_1" name="menu4_1" class="menu">Statutes</a>';
	content[4][2] = '<a href="Board.html" id="menu4_2" name="menu4_2" class="menu">Board</a>';
	content[4][3] = '<a href="Vacancies.html" id="menu4_3" name="menu4_3" class="menu">Vacancies</a>';
	content[4][4] = '<a href="VillaGrande.html" id="menu4_4" name="menu4_4" class="menu">Villa Grande</a>';
	content[4][5] = '<a href="Staff.html" id="menu4_5" name="menu4_5" class="menu">Staff</a>';
	
/* Library */
	content[5] 	  = new Array();
	content[5][0] = '<a href="#" id="menu5_0" name="menu5_0" class="menu">Background</a>';
	content[5][1] = '<a href="#" id="menu5_1" name="menu5_1" class="menu">Statutes</a>';
	content[5][2] = '<a href="#" id="menu5_2" name="menu5_2" class="menu">Board</a>';
	content[5][3] = '<a href="#" id="menu5_3" name="menu5_3" class="menu">Stillinger</a>';
	content[5][4] = '<a href="#" id="menu5_4" name="menu5_4" class="menu">Villa Grande</a>';
	content[5][5] = '<a href="#" id="menu5_5" name="menu5_4" class="menu">Staff</a>';

// private functions below - DO NOT ALTER !!!

var i;
var j;
var top;
var bgtop;
var bgleft;
var bgheight;
var bgwidth;
var clleft;
var cltop;
var macAddx = (navigator.platform.indexOf("Mac")!= -1)?10:0;
var macAddy = (navigator.platform.indexOf("Mac")!= -1)?30:0;
var btnSize = new Array(132,132,132,132,132);
var width   = new Array(132,132,132,132,132);

if ((document.getElementById)||(document.all)){	// if msie, netscape 6
	var x = getXpos(document.images['posit']);
	var y = getYpos(document.images['posit']);
	
	bgleft = x+macAddx;
	bgtop  = y+1+macAddy;
	
	
	cltop = y+100;
	clleft= x;
	bgLayer(clleft,cltop)
	
	// loop through the outer array (content)
	for(i=0;i<content.length;i++){
	
		bgwidth = width[i]+2;
		bgheight = (content[i].length * 17)+1;
		document.writeln('<div id="menubg'+i+'" style="position: absolute; top:'+bgtop+'px; left:'+bgleft+'px; width:'+bgwidth+'px; height:'+bgheight+'px; visibility: hidden; z-index:5;" class="menubg">');
		top = 1;
		// loop through the inner array and write the div's
		
		if(navigator.userAgent.indexOf("Netscape") != -1){
			for(j=0;j<content[i].length;j++){
				document.writeln('<div id="menu'+i+'_'+j+'" style="position: absolute; top:'+top+'px; left:1px; width:'+width[i]+'px; height:16px; visibility:inherit; z-index:5;" onmouseover="hiLite(this);" onmouseout="loLite(this);" class="menuoff">'+content[i][j]+'</div>');
				top = top+17;
			}
		}else if(navigator.userAgent.indexOf("MSIE 5.5") != -1){
			for(j=0;j<content[i].length;j++){
				document.writeln('<div id="menu'+i+'_'+j+'" style="position: absolute; top:'+top+'px; left:1px; width:'+width[i]+'px; height:16px; visibility:inherit; z-index:5;" onmouseover="hiLite(this);" onmouseout="loLite(this);" class="menuoff">'+content[i][j]+'</div>');
				top = top+17;
			}
		}else{
			for(j=0;j<content[i].length;j++){
				document.writeln('<div id="menu'+i+'_'+j+'" style="position: absolute; top:'+top+'px; padding-top:3px; left:1px; width:'+width[i]+'px; height:13px; visibility:inherit; z-index:5;" onmouseover="hiLite(this);" onmouseout="loLite(this);" class="menuoff">'+content[i][j]+'</div>');
				top = top+17;
			}
		}
				
		document.writeln('</div>');
		bgleft = bgleft+btnSize[i];		
	}

}else if(document.layers){
	var x = document.images['posit'].x;
	var y = document.images['posit'].y;
	
	bgleft = x+macAddx;
	bgtop  = y+1+macAddy;
	
	cltop = y+100;
	clleft= x;
	bgLayer(clleft,cltop)
	// loop through the outer array (content)
	for(i=0;i<content.length;i++){
	
		bgwidth = width[i]+2;
		bgheight = (content[i].length * 17)+1;
		
		document.writeln('<layer name="menubg'+i+'" position="absolute" top="'+bgtop+'px" left="'+bgleft+'px" width="'+bgwidth+'px" height="'+bgheight+'px" visibility="hide" z-index="5" bgcolor="#ffffff">');
		top = 1;
		// loop through the inner array and write the div's
		for(j=0;j<content[i].length;j++){
			document.writeln('<layer name="menu'+i+'_'+j+'" position="absolute" top="'+top+'px" left="1px" width="'+width[i]+'px" height="16px" visibility="inherit" z-index="5" bgcolor="#D9E3E5" onmouseover="hiLite(this);" onmouseout="loLite(this);" class="menuoff">'+content[i][j]+'</layer>');
			top = top+17;
		}
		
		document.writeln('</layer>');
		bgleft = bgleft+btnSize[i];		
	}
}

menu = true;

function bgLayer(myX,myY){
	// function: create the closing layer
	// returns : nothing
	
	var height = 0;
	var width  = 0;
	
	// set height to the same as the longest submenu
	for(i=0;i<content.length;i++){
		if(content[i].length>height){
			height = content[i].length;
		}
	}
	
	// calculate the width
	for(i=0;i<btnSize.length;i++){
		width = width + btnSize[i];
	}
	
	// some more math..
	width  = width + 30;
	height = (height*14)+30;
	
	// write the layer
	if((document.getElementById)||(document.all)){
		document.writeln('<div id="bg" style="position:absolute;top:'+myY+'px;left:'+myX+'px;width:'+width+'px;height:'+height+'px;visibility:hidden;z-index:1;><a href="#" onmouseover="hideMenu();resetImg()"><img src="../elements/pixel.gif" width="'+width+'" height="'+height+'" alt="" onmouseover="hideMenu();resetImg()" border="0"></a></div>');
		myY = myY-25;
		document.writeln('<div id="bgtop" style="position:absolute;top:'+myY+'px;left:'+myX+'px;width:'+width+'px;height:10px;visibility:hidden;z-index:1;"><a href="#" onmouseover="hideMenu();resetImg()"><img src="../elements/pixel.gif" width="'+width+'" height="10" alt="" onmouseover="hideMenu();resetImg()" border="0"></a></div>');
	} else if(document.layers){
		document.writeln('<layer name="bg" position="absolute" top="'+myY+'px" left="'+myX+'px" width="'+width+'px" height="'+height+'px" visibility="hidden" z-index="3" onmouseover="hideMenu();resetImg()"></layer>');
		myY = myY-25;
		document.writeln('<layer name="bgtop" position="absolute" top="'+myY+'px" left="'+myX+'px" width="'+width+'px" height="10px" visibility="hidden" z-index="3" onmouseover="hideMenu();resetImg()"></layer>');
	}
}

function getYpos(obj) {
	// function: return the y-position of a specifiec image
	// returns : int
	
	return(obj.offsetTop + ((obj.offsetParent) ? getYpos(obj.offsetParent) : 0));
}

function getXpos(obj) {
	// function: return the x-position of a specifiec image
	// returns : int
	return(obj.offsetLeft + ((obj.offsetParent) ? getXpos(obj.offsetParent) : 0));
}
