/*
 * 22 April 2004
 * Justin Hewitt
 * Justin.Hewitt@Monarch-Airlines.com
 *
 * This file generates the HTML code used for displaying the flymonarch.com and bookflymonarch.com
 * site menus. Note that file paths used below should be relative using the virtual dirs or bok or
 * fly.
 *
 * NOTE This page requires the variables flyHost and bokHost which are set in scpCmn.js
 */

function SetTopMenu() {	
	var mnu = "";
	var fly = "";
	var topArr = new Array(3);
	var host = flyHost;
	// Check if secure page
	if (window.location.href.indexOf("https") > -1) {
		host = flyHostSec;
	}	
	// Check to see how fly should be set
	if (window.location.href.indexOf(host) == -1) {
		fly = "/fly";
	}	
	//Array("url","onMouseOverAction","onMouseOutAction","cellWidth")
	topArr[0] = new Array("/index.asp","","","home",65);	
	topArr[1] = new Array("/cnt/legal.asp","","","legal",100);	
	topArr[2] = new Array("/cnt/privacy.asp","","","privacy policy",100);	
	// #############################################
	// ######### DONT EDIT BELOW THIS LINE #########
	// #############################################	
	mnu += 	"<table height='17' cellspacing='0' cellpadding='0' border='0'>";
	mnu += 		"<tr>";	
	for (i = 0; i < topArr.length; i++) {
		mnu += SetTopMenuItem(topArr[i],host)
	}	
	mnu +=		"</tr>";
	mnu +=	"</table>";	
	mnu +=	"<div id='hidelayers' style='position: absolute; z-index: 1; top: 0px; left: 0px; width: 605px; height: 76px; visibility: hidden' ><a href='#' onMouseOver='hideAll(); hideLayer(\"hidelayers\");'><img height='76' width='700' src='" + host + "/pic/cmn/spacer.gif' border='0'></a></div>";
	mnu +=	"<div id='hidelayerstop' style='position: absolute; z-index: 2; top: 0px; left: 0px; width: 605px; height: 40px; visibility: hidden'><a href='#' onMouseOver='hideAll(); hideLayer(\"hidelayerstop\");'><img height='75' width='700' src='" + host + "/pic/cmn/spacer.gif' border='0'></a></div>";
	document.write(mnu);
}
 
function SetMenu(mode) {
	var thirdPartyArr = new Array(7);
	var modeArr = new Array(1);		
	//Array("name","thirdPartyImageNumber","baseModeUrl","scheduledHeaderImage","charterHeaderImage","pathToFlyMonarch.com","pathToBookFlyMonarch.com","pathToSecureFlyMonarch.com")
	modeArr[0] = new Array("home","1","http://www.flymonarch.com","scdhome","chthome","",bokHost,"");
	var fly = modeArr[mode][5];
	var flySec = modeArr[mode][7];
	var bok = modeArr[mode][6];	
	//Array("destinationUrl","linkText","imageId","imageName","modeSettings")
	thirdPartyArr[0] = new Array("/cnt/inclusive.asp","inclusive tour","b1","inclusive",modeArr[mode]);
	thirdPartyArr[1] = new Array("/cnt/adhoc.asp","ad-hoc charter","b3","adhoc",modeArr[mode]);
	thirdPartyArr[2] = new Array("/cnt/lease.asp","aircraft leases","b4","lease",modeArr[mode]);
	thirdPartyArr[3] = new Array("/cnt/sub.asp","sub-charters","b5","sub",modeArr[mode]);
	thirdPartyArr[4] = new Array("/cnt/group.asp","group companies","b6","group",modeArr[mode]);
	thirdPartyArr[5] = new Array("/cnt/info.asp","useful information","b7","info",modeArr[mode]);
	thirdPartyArr[6] = new Array("/cnt/contact.asp","contact us","b8","contact",modeArr[mode]);
	//thirdPartyArr[7] = new Array("/cnt/legal.asp","legal","b9","legal",modeArr[mode]);
	//thirdPartyArr[8] = new Array("/cnt/privacy.asp","privacy","b10","privacy",modeArr[mode]);
	// #############################################
	// ######### DONT EDIT BELOW THIS LINE #########
	// #############################################	
	var mnu = "";		
	// Third Party Links
	mnu +=			"<div id=\"divFold2\" class=\"clFold\">";	
	for (i = 0; i < thirdPartyArr.length; i++) {
		mnu +=			SetThirdPartyLink(thirdPartyArr[i][0],thirdPartyArr[i][1],thirdPartyArr[i][2],thirdPartyArr[i][3],thirdPartyArr[i][4],CheckSecureImageHost(fly,flySec));
	}
	mnu +=				"<img src='" + CheckSecureImageHost(fly,flySec) + "/pic/nav/textras_line.gif' width='150' height='2' alt='' border='0'><br>";
	// Menu Footer Divs	
	mnu +=				"<div id='divFoldSub2_0' class='clFoldSub'>";
	mnu +=					"<div id='divFoldSub2_0_0'  class='clFoldSub2'></div>";
	mnu +=				"</div>";
	mnu +=			"</div>";
	mnu +=			"<div id='divFold3' class='clFold'>";				
	mnu +=				"<div id='divFoldSub3_0' class='clFoldSub'>";
	mnu +=					"<div id='divFoldSub3_0_0'  class='clFoldSub2'></div>";
	mnu +=				"</div>";
	mnu +=			"</div>";
	document.write(mnu);
}


// Set a section of menu items
function SetMenuItems(itmArr,itmClass,divImg,host) {
	var mnuItms = "";
	for (i = 0; i < itmArr.length; i++) {
		mnuItms += SetMenuItem(itmArr[i][0],itmArr[i][1],itmArr[i][2],host);		
		if (i != (itmArr.length - 1)) {
			mnuItms += SetMenuDivider(itmClass,divImg,host);
		}
	}	
	return mnuItms;
}

// Set an individual menu item
function SetMenuItem(url,text,mnuClass,host) {
	var mnuItm = 	"<tr>";
	mnuItm +=			"<td class='" + mnuClass + " width='10'><img src='/pic/cmn/spacer.gif' width='10' height='1' alt='' border='0'></td>";
	mnuItm +=			"<td width='14' height='20' class='" + mnuClass + "'><img src='" + host + "/pic/nav/arrow_white.gif' width='3' height='5' alt='' border='0' name='imgFold0Sub0'></td>";	
	mnuItm +=			"<td class='" + mnuClass + "' width='126' align=left><a href='" + url + "' class='nav'>" + text + "</a></td>";
	mnuItm +=		"</tr>";
	return mnuItm;
}

// Set a menu section header
function SetMenuSectionHeader(div1,div2,type,mode,host) {
	var modeArr = new Array(mode);	
	var mnuHdr = 	"<div id='" + div1 + "' class='clFold'>";
	if (type == "sch") {
		mnuHdr += 			"<a href='#' onclick=\"MM_nbGroup('down','group1','imgFold0','" + host + "/pic/nav/scdclick.gif',1); foldmenu('0'); return false\" onMouseOver=\"MM_nbGroup('over','imgFold0','" + host + "/pic/nav/scdover.gif','" + host + "/pic/nav/scdclick.gif',1)\" onMouseOut=\"MM_nbGroup('out')\"  class=\"clFoldLinks\" onfocus=\"if(this.blur)this.blur()\"><img src='" + host + "/pic/nav/" + modeArr[0][3] + ".gif' width=\"150\" height=\"37\" alt=\"scheduled flights\" border=\"0\" name='imgFold0'></a><br>";
	} else {
	if (type == "cha") {
		mnuHdr +=			"<a href='#' onclick=\" MM_nbGroup('down','group1','imgFold1','" + host + "/pic/nav/chtclick.gif',1); foldmenu('1'); return false\" onMouseOver=\"MM_nbGroup('over','imgFold1','" + host + "/pic/nav/chtover.gif','" + host + "/pic/nav/chtclick.gif',1)\" onMouseOut=\"MM_nbGroup('out')\"  class=\"clFoldLinks\" onfocus=\"if(this.blur)this.blur()\"><img src='" + host + "/pic/nav/" + modeArr[0][4] + ".gif' width='150' height='37' alt='charter flights' border='0' name='imgFold1'></a><br>";
		}
	}
	mnuHdr +=				"<div id='" + div2 + "' class='clFoldSub' class='clFoldSub'>";
	mnuHdr +=					"<table width='150' cellspacing='0' cellpadding='0' border='0'>";
	mnuHdr +=						"<tr>";
	mnuHdr +=							"<td colspan='3' align='center' class='schsmall'><img src='" + host + "/pic/nav/line_1.gif' width='150' height='2' alt='' border='0'></td>";
	mnuHdr +=						"</tr>";
	mnuHdr +=						"<tr>";
	mnuHdr +=							"<td class='schsmall' width='10'><img src='" + host + "/pic/cmn/spacer.gif' width='10' height='1' alt='' border='0'></td>";
	mnuHdr +=							"<td height='1' width='14' align='left' class='schsmall'><img src='" + host + "/pic/cmn/spacer.gif' width='14' height='1' alt='' border='0'></td>";
	mnuHdr +=							"<td class='schsmall' width='126'><img src='" + host + "/pic/cmn/spacer.gif' width='126' height='1' alt='' border='0'></td>";
	mnuHdr +=						"</tr>";
	return mnuHdr;
}

// Set a menu section footer
function SetMenuSectionFooter(div1) {
	var mnuFtr = 				"</table>";
	mnuFtr +=				"<div id='" + div1 + "'  class='clFoldSub2'></div>";
	mnuFtr +=			"</div>";
	mnuFtr +=		"</div>";
	return mnuFtr
}

// Set the divider between menu items
function SetMenuDivider(mnuClass,img,host) {
	var mnuDiv = 	"<tr>";
	mnuDiv +=			"<td colspan='3' align='center' class='" + mnuClass + "'><img src='" + host + "/pic/nav/" + img + "' width='132' height='2' alt='' border='0'></td>";
	mnuDiv +=		"</tr>";
	return mnuDiv;
}

// Set a third party link
function SetThirdPartyLink(url,text,name,img,mode,host) {
	var modeArr = new Array(mode);
	var mnuThdPrt = 	"<a href=\"" + url + "\" target='_self' onmouseover=\"document." + name + ".src='" + host + "/pic/nav/" + img + "_2.gif'\" onmouseout=\"document." + name + ".src='" + host + "/pic/nav/" + img + "_" + modeArr[0][1] + ".gif'\">";
	mnuThdPrt += 		"<img src='" + host + "/pic/nav/" + img + "_" + modeArr[0][1] + ".gif' width='150' height='22' alt='' border='0' name='" + name + "'></a><br>";
	return mnuThdPrt;
}

// Set Top Menu Top Items
function SetTopMenuItem(dtl,host) {
	var dtlArr = new Array(dtl);
	var mnuItm = 	"<td width='" + dtlArr[0][4] + "' onMouseOver='lOn(this);' onMouseOut='lOut(this);' class='cornav' align='center'>";
	mnuItm += 		"<a href='" + dtlArr[0][0] + "' onmouseover=\"" + dtlArr[0][1] + "\" onmouseout=\"" + dtlArr[0][2] + "\" class='top'>" + dtlArr[0][3] + "</a></td>";
	mnuItm +=		"<td class='darkgrey'><img src='" + host + "/pic/cmn/spacer.gif' width='1' height='1' alt='' border='0'></td>";
	return mnuItm;
}

// Set Tclasop Menu Sub Items
function SetTopMenuSubItem(dtl,host) {
	var mnuSub =	"<div id='" + dtl[0][0] + "'>";
	mnuSub +=		"<table width='181' height='55' cellspacing='0' cellpadding='0' border='0'>";
	mnuSub +=			"<tr>";
	mnuSub +=				"<td colspan='6'><img src='" + host + "/pic/cmn/spacer.gif' width='5' height='5' alt='' border='0'></td>";
	mnuSub +=			"</tr>";
	mnuSub +=			"<tr>";
	mnuSub +=				"<td width='85' valign='top'>";
	for (i = 0; i < dtl.length; i++) {
		mnuSub += 				"<a href='" + dtl[i][1] + "' class='topsub'>" + dtl[i][2] + "</a><br>"
		if (i == 2) {
			mnuSub += 		"</td>";
			mnuSub +=		"<td class='corsmall'><img src='" + host + "/pic/cmn/spacer.gif' width='1' height='1' alt='' border='0'></td>";
			mnuSub +=		"<td><img src='" + host + "/pic/cmn/spacer.gif' width='5' height='1' alt='' border='0'></td>";
			mnuSub +=		"<td width='80' valign='top'>"
		}
	}
	mnuSub +=				"<td><img src='" + host + "/pic/cmn/spacer.gif' width='4' height='1' alt='' border='0'></td>";
	mnuSub +=			"</tr>";
	mnuSub +=			"<tr>";
	mnuSub +=				"<td colspan='6'><img src='" + host + "/pic/cmn/spacer.gif' width='5' height='5' alt='' border='0'></td>";
	mnuSub +=			"</tr>";
	mnuSub +=		"</table>";
	mnuSub +=		"</div>";
	return mnuSub;
}

// Check if is a secure url and change to non-secure
function CheckSecureUrl(url,host) {
	var loc = window.location.href;
	if (loc.indexOf("https") > -1) {
		url = "http://" + window.location.host + url;
	}
	return url;
}

// Check if is secure to set the image host
function CheckSecureImageHost(host,hostSec) {
	var loc = window.location.href;
	if (loc.indexOf("https") > -1) {
		host = hostSec;
	}
	return host;
}

// Display function
function lOn(td){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor="#cccccc";
	}
}


// Display function
function lOut(td){
	if(document.getElementById||(document.all && !(document.getElementById))){
		td.style.backgroundColor="#ffffff";
	}
}
