/************************************************************************************************************************
menu.js || Right Click Menu
------------------------------------------------------------------------------------------------------------------------
Developed By Cory Caines || Kreated Nine Web Development
************************************************************************************************************************/
var menuObj = new Object();

menuObj.menu = [
	['index.php','Home'],
	['company.php','Company'],
	['team.php','Team'],
	['studyguide/','Study Guide'],
	['products.php','Products'],
	['testimonials.php','Testimonials'],
	['rmtcommunity.php','RMT Community'],
	['contact.php','Contact']
];

//add the menu
document.write("<div id=\"menu\" class=\"box_bounds menu\"></div>");
build_menu();
var mCls = null;
//disable hightlighting
document.onselectstart=new Function ("return false");

browser = new browser();
function browser() {
	this.IE    = false;
	this.NS    = false
	agent = navigator.userAgent;
	if ((i = agent.indexOf("MSIE")) >= 0) {
		this.IE = true;
		return;
	}
	if ((i = agent.indexOf("Gecko")) >= 0) {
		this.NS = true;
		return;
	}
	if ((i = agent.indexOf("Netscape6/")) >= 0) {
		this.NS = true;
		return;
	}
}



//right click
function init_click(e){
	if(document.all){
		//for ie
		button=event.button;
	}else{
		//for ns and ff
		button=e.which;
	}
	if(button==2||button==3){
		show_menu(e);
	}
	return true;
}

if(document.layers){
	//for ns4
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=init_click;
}
else{
	//for all other browsers
	document.onmouseup=init_click;
	document.oncontextmenu=new Function("return false")
}

function build_menu(){	
	var msrc='';
	var menu = new Object();
	menu = menuObj.menu;
	var site_root = $("site_root").value;
	for(var mi in menu){
		href = menu[mi][0];
		page = menu[mi][1]
		if(page == 'spacer'){
			msrc += "<div class=\"navItem hdot\"><!-- Spacer --></div>";
		}else{
			msrc+="<div id=\"mi\" class=\"navItem hdot\">";
				msrc+="<a href=\""+site_root+"/"+href+"\" onmouseout=\"ct();\" onmouseover=\"ct();\">"+page+"</a>";
			msrc+="</div>";
		}
	}
	$("menu").style.width = "100px";
	$("menu").innerHTML = msrc;
}

function show_menu(e){
	ct();
	var menu = $("menu");

	var tbody = (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
	if(browser.NS){
		xpos = e.pageX;
		ypos = e.pageY;
	}else{
		e = event;
		xpos = e.clientX
		ypos = e.clientY;
		ypos = (tbody.scrollTop + ypos);
	}
	
	menu.style.top = ((ypos)-5)+"px";
	menu.style.left = (xpos-5)+"px";
	menu.onmouseout = function(){
		mCls = window.setTimeout("reset_menu()",500);
	}
	menu.onmousemove = ct;
}

function reset_menu(){
	var menu = $("menu");
	menu.style.top = "-500px";
	menu.style.left = "-500px";
}

function ct(){
	if(mCls != null){
		window.clearTimeout(mCls);	
	}
}