/*
 *	2D Navigation Menu
 *	Author: Eihab Ibrahim <sword@gamebox.net>
 *	September 29th, 2005
 */

/*
 *	Links ordered
 */

var menu = new Array();
var menulink = new Array();
for(var i=0; i<3; i++){
menulink[i] = new Array();
}
menu[0] = "aboutus2.htm";
menu[1] = "leadershipdevelopment.htm";
menulink[0][0] = "aboutus2.htm";
menulink[0][1] = "managementteam2.htm";
menulink[0][2] = "clientlist2.htm";
menulink[1][0] = "leadershipdevelopment.htm";
menulink[1][1] = "sessionfacilitation2.htm";
menulink[1][2] = "facilitationcert2.htm";

/*
 *	Global Variables
 */
var currentmain; // Main menu indicator
var currentsub; // Sub menu indicator


/*
 *	Initalization function 
 * Name: initmenu()
 * Description: Position submenus and colour current page if any
 *	Arguments: none
 * Returns: void
 */

function initmenu(){
	for(var i=0; i<3; i++){
		var dottedline = document.getElementById("mimg"+i);
		var cleft, ctop;
	   for(cleft=0, ctop=0; dottedline.offsetParent; dottedline=dottedline.offsetParent){
	      cleft += dottedline.offsetLeft;
	      ctop += dottedline.offsetTop;
	    }
	    var submenupos = document.getElementById("s"+i);
	    submenupos.style.left = cleft+27;
	    submenupos.style.top = ctop-5;
	}
	var clocation = "" + document.location + "";
	for(var i=0; i<menu.length; i++){
		if(clocation.indexOf(menu[i])>-1){
				var aref = document.getElementById("a"+i);
				aref.style.color = "orange";
				aref.className = "selected";
		}	
	}
	for(var i=0; i<menulink.length; i++){
		for(var j=0; j<menulink.length; j++){
			if(clocation.indexOf(menulink[i][j])>-1){
				currentmain = i;
				currentsub = j;
				var imgref = document.getElementById("s"+i+""+j);
				var aref = document.getElementById("l"+i+""+j);
				var parref = document.getElementById("a"+i);
				imgref.src = "images/boxorg.gif";
				aref.style.color = "orange";
				aref.className = "selected";
				parref.style.color = "orange";
				displaymenu(i);
				break;
			}
		}
	}
}

/*
 *	Submenu initalization function 
 * Name: initsub(int)
 * Description: Display submenu
 *	Arguments: integer, Reference to submenu number (object id s+number)
 * Returns: void
 */
function initsub(j){
	var tbox = document.getElementById("s"+j);
	tbox.style.display="block";
}


/*
 *	Table Box Orange, Blue
 * Name: tbo(object), tbb(object)
 * Description: Switch the box image to orange or blue respectively
 *	Arguments: object, Refernce to an img tag
 * Returns: void
 */

function tbo(imgref){
	if(imgref != document.getElementById("s"+currentmain+""+currentsub)){
		imgref.src = "images/boxorg.gif";
	}
}
function tbb(imgref){
	if(imgref != document.getElementById("s"+currentmain+""+currentsub)){
		imgref.src = "images/boxblue.gif";
	}
}

/*
 *	Display sub menu function 
 * Name: displaymenu(int)
 * Description: Creates sub menu and displays it
 *	Arguments:	- integer; Reference to entry in submenu array
 *	Returns: void
 */
function displaymenu(i){
	clearmenu();
	initsub(i);
	var dottedline = document.getElementById("mimg"+i);
	dottedline.src = "images/orangeline_on.gif";
}

/*
 *	Clear menu function 
 * Name: clearmenu()
 * Description: Clears menu location
 *	Arguments: none
 *	Returns: void
 */
function clearmenu(){
	for(var i=0; i<3; i++){
		var dottedline = document.getElementById("mimg"+i);
		dottedline.src = "images/orangeline.gif";
		var tbox = document.getElementById("s"+i);
		if(tbox){
			tbox.style.display="none";
		}
	}
}