var IE = (document.all) ? true : false;
var IE4 = (IE && !document.getElementById) ? true : false;
var IE5 = (IE && document.getElementById) ? true : false;

var NS4 = (document.layers) ? true : false;
var NS6 = (document.getElementById && !IE) ? true : false;

var sub_folders = new Array("folder ","list ", "here ")
var path_adjustment = (window.location+"").match(new RegExp(sub_folders.join('|'),"i")) ? '../' : '';
var strCurrentPage = (window.location+"").replace(/^.*[\\\/]([^\\\/]*)$/,'$1');
if (!strCurrentPage) strCurrentPage = 'index.html';
var reCurrentPage = new RegExp(strCurrentPage,"i");

var boolMenusLoaded = false;

var menus = new Array();
menus[1] = new Array(
					new menuElement("Team Praxis","team_praxis.html"),
					new menuElement("Praxis Vision","vision.html"),
					new menuElement("Praxis Mission","mission.html"),
					new menuElement("Core Competencies","core_c.html")
					);

menus[2] = new Array(
					new menuElement("Training & Development","training&development.html"),
					new menuElement("Consulting","consulting.html"),
					new menuElement("Corporate Communications","Corporate.html"),
					new menuElement("Placements & Headhunting","placements.html"),
					new menuElement("Career Development","career.html")
					
					);

menus[3] = new Array(
					new menuElement("Management Consulting","#"),
					new menuElement("Market Research","#"),
					new menuElement("Personnel Consulting","#"),
					new menuElement("Recruitment & Staffing","#"),
					new menuElement("Training & Development","#")
					);

if (NS6){
	function moveTo(lPos,tPos){
		lPos = lPos + 0;
		tPos = tPos + 0;
//		this.style.pixelLeft = lPos;
//		this.style.pixelTop = tPos;
		this.style.left = lPos;
		this.style.top = tPos;
	}
}

function init(){
	if (NS4){
		elMenu1 = document.elMenu1;
		elMenu2 = document.elMenu2;
		elMenu3 = document.elMenu3;
		elMenu1_parent = document.elMenu1_parent;
		elMenu2_parent = document.elMenu2_parent;
		elMenu3_parent = document.elMenu3_parent;
	}else if (NS6){
		elMenu1 = document.getElementById('elMenu1');
		elMenu2 = document.getElementById('elMenu2');
		elMenu3 = document.getElementById('elMenu3');
		elMenu1.moveTo = moveTo;
		elMenu2.moveTo = moveTo;
		elMenu3.moveTo = moveTo;
		elMenu1_parent = document.elMenu1_parent;
		elMenu2_parent = document.elMenu2_parent;
		elMenu3_parent = document.elMenu3_parent;
	}
}

var current_menu = hiding_menus = false;

function showMenu(menu_id){
	if (boolMenusLoaded){
		new_menu = eval('elMenu'+menu_id);
//		alert('here'+elMenu1.name);
		stopHide();
		if (new_menu != current_menu){
			doHide();
			var parent = eval('elMenu'+menu_id+'_parent');
			if (IE) {   
				xPos = yPos = 0;
				obj = parent;
				while(obj.offsetParent!=null){
					xPos += obj.offsetLeft;
					yPos += obj.offsetTop;
					obj = obj.offsetParent;
				}
				xPos += obj.offsetLeft;
				yPos += obj.offsetTop;
				new_menu.style.pixelLeft = xPos;
				new_menu.style.clip = 'rect(auto 185 auto auto)';
				new_menu.style.pixelTop = yPos + parent.height;
				new_menu.style.visibility = "visible";
			}else{
				if (NS4){
					xPos = parent.x - 1;
					yPos = parent.y;
				}else{
					xPos = parent.offsetLeft - 1;
					yPos = parent.offsetTop;
				}
//				new_menu.clip.right = 185;
//				new_menu.clip.bottom = new_menu.height;
//				new_menu.style.clip = 'rect(auto 185 auto auto)';
				new_menu.moveTo(xPos,yPos+parent.height);
				new_menu.bgColor = "#FFFFFF";
				new_menu.onMouseOver = stopHide; 
				new_menu.onMouseOut = hideMenu;
				if (NS6) new_menu.style.visibility = "visible";
				else new_menu.visibility = "show";
//				alert(new_menu.innerHTML);
			}
			current_menu = new_menu;
		}
	}
}

function doHide(){
	if (current_menu){
		if (IE || NS6) current_menu.style.visibility = "hidden";
		else if (NS4) current_menu.visibility = "hide";
		current_menu = false;
	}
}

function hideMenu(){
	if (current_menu) hiding_menus = setTimeout("doHide()",500);
}

function stopHide(){
	if (hiding_menus) clearTimeout(hiding_menus);
}

function menuElement(title,link){
	this.title = title ? title : false;
	this.link = link ? path_adjustment + link : false;
}

function popUp(URL) {	if (URL){
		var external = window.open(URL, 'external', 'toolbar=0,scrollbars=auto,location=0,statusbar=0,menubar=0,resizable=yes,width=700,height=580');		external.focus();	}
}
//prepLayer("name",function);
function prepLayer(lyerNam,funcToCall){
	document.layers[lyerNam].document.captureEvents(Event.MOUSEUP);
	document.layers[lyerNam].document.onmouseup=funcToCall;
}

// the stuff that actually creates the menus: 

var arrow = new Image();
var arrow_src = '';
arrow.src = path_adjustment +'images/drop_arr_03.gif';

var the_str = '';
for (i in menus){
	the_str += '<div name="elMenu'+i+'" id="elMenu'+i+'" bgColor="#FFFFFF" class="menu" onMouseOver="stopHide()" onMouseOut="hideMenu()">\n';
	the_str += '\t<table width="185" border="0" cellspacing="1" cellpadding="1">\n';
	var top = 1;
	var intElementHeight;
	if (document.layers) intElementHeight = 22;
	else intElementHeight = 20;
	for (j in menus[i]){
		the_str += '\t\t<tr>\n';
		the_str += '\t\t\t<td';
		if (document.layers){				
			the_str += '><layer width="183" height="'+intElementHeight+'" position="relative" valign="center" left="1" top="'+top+'"';
			top += 23;
		}
		if (menus[i][j].link){
			if (menus[i][j].link.match(reCurrentPage)) the_str += ' bgcolor="#006699"';
			else{
				the_str += ' bgcolor="#6699CC" onMouseOver="this.bgColor=\'#006699\'"'
					+ ' onMouseOut="this.bgColor=\'#6699CC\'"';
				if (menus[i][j].link.match(/http/i)) the_str += ' onClick="popUp(\''+menus[i][j].link+'\')"';
				else the_str += ' onClick="document.location=\''+menus[i][j].link+'\'"';
			}
		}else the_str += ' bgcolor="#929EEO" align="center"';
		the_str += '><table border="0" cellpadding="2" cellspacing="0">\n';
		the_str += '\t\t\t<tr valign="center">\n';
//		if (menus[i][j].link) the_str += '\t\t\t\t<td valign="center"><img src="'+arrow.src+'" alt="" width="7" height="6" hspace="8" vspace="0" border="0"></td>\n';
		if (menus[i][j].link){
			if (!IE) the_str += '\t\t\t\t<td valign="center" class="dropmenub">&nbsp;</td>\n';
			else the_str += '\t\t\t\t<td valign="center" class="dropmenub">&nbsp;<!--img src="images/dd_pixel.gif" alt="" width="1" height="1" hspace="4" vspace="0" border="0"--></td>\n';
		}
		the_str += '\t\t\t\t<td class="dropmenub" valign="center"><p class="dropmenub">';
		if (menus[i][j].link && !menus[i][j].link.match(reCurrentPage)) the_str += '<a href="'+menus[i][j].link+'" id="menu_link"'+(menus[i][j].link.match(/http/i)?' target="external"':'')+' class="dropmenub">'
		the_str += menus[i][j].title;
		if (menus[i][j].link && !menus[i][j].link.match(reCurrentPage)) the_str += '</a>'
		if (document.layers) the_str += '</layer>';
		the_str += '</p></td>\n';
		the_str += '\t\t\t</tr>\n';
		the_str += '\t\t\t</table></td>\n';
		the_str += '\t\t</tr>\n';
	}
	if (document.layers){				
		top += 3;
	}
	the_str += '\t</table>\n';
	the_str += '</div>\n';
}
document.open();
document.write(the_str);
document.close();
//if (!IE) alert(document.body.innerHTML);
boolMenusLoaded = true;
