 function getTop(el) {
	iPos = 0;
	while (el!=null) {
	 	iPos += el.offsetTop;
		el = el.offsetParent;
	}
	return iPos;
}

function getLeft(el) {
	iPos = 0;
	while (el!=null) {
	 	iPos += el.offsetLeft;
		el = el.offsetParent;
	}
	return iPos;
}

function addEvent (el, evName, evFunction) {
	if (isIE) {
		eval("el.attachEvent('" + evName + "'," + evFunction + ")"); 
	} else {
		eval("el." + evName + " = " + evFunction);
	}
}

function getTarg (e) {
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;
	return targ;
}

function itemOver(e) {
	var targ = getTarg(e);
	targ.style.backgroundColor = targ.parentNode.onColor;
}

function itemOut(e) {
	var targ = getTarg(e);
	targ.style.backgroundColor = targ.parentNode.offColor;
}

function itemClick(e) {
	var targ = getTarg(e);
	location.href = targ.URL;
}

function menuOver(e) {
	clearTimeout(lastTimeout);
}

function menuOut(e) {
	var targ = getTarg(e);
	while (!targ.chanCode) {
		targ = targ.parentNode;
	}
	menuOffProcess(targ.chanCode);
}

function menuOffNow (chanCode) {
	getEl(chanCode).style.visibility = hid;
	if (isIE) selectVis(vis);
}

function menuOffProcess (chanCode) {
	lastTimeout = setTimeout("menuOffNow('" + chanCode + "Menu')",10);
}

function menuOnProcess (el) {
	clearTimeout(lastTimeout);
	if (el.style.visibility != vis) {
		//rfrshMenuAd(el.chanCode);
		if (actMenu != "") getEl(actMenu+"Menu").style.visibility = hid;
		actMenu = el.chanCode;
		el.style.visibility = vis;
		if (isIE) selectVis(hid);
	}
}

function selectVis(state) {
	selects = document.getElementsByTagName("select");
	for (selectIndex = 0; selectIndex < selects.length; selectIndex++) {
		selects[selectIndex].style.visibility = state;
	}
}

function areaOver (e) {
	var targ = getTarg(e);
	menu = getEl(targ.chanCode + "Menu");
	menuOnProcess(menu);
}

function areaOut (e) {
	var targ = getTarg(e);
	menu = getEl(targ.chanCode + "Menu");
	menuOffProcess(targ.chanCode);
}

function newMenu (chanCode) {
	var menuDiv = makeEl("DIV");
	menuDiv.className = "outerMenu";
	menuDiv.id = chanCode + "Menu";
	menuDiv.chanCode = chanCode;
	menuDiv.offColor = (chanCode == activeTab) ? cColor : oColor;
	menuDiv.onColor = (chanCode == activeTab) ? hlActColor : actColor;
	menuDiv.style.zIndex = zInd++;
	menuDiv.style.visibility = hid;
	menuDiv.style.position = "absolute";
	addEvent (menuDiv, mOv, "menuOver");
	addEvent (menuDiv, mOt, "menuOut");
	addTopEl(menuDiv);
	positionMenu(menuDiv);
	var area = getEl(chanCode + "Area");
	area.chanCode = chanCode;
	addEvent(area, mOv, "areaOver");
	addEvent(area, mOt, "areaOut");
	return menuDiv;
}

function positionMenu(el) {
	var area = getEl(el.chanCode + "Area");
	if (area) {
		var menuTop = getTop(chanGif) + 23;
		var coords = area.coords.split(",");
		var width = 140;
		var left = ((getLeft(chanGif)) + parseInt(coords[0]));
		el.style.top = menuTop + px;
		el.style.width = width + px;
		//if (isIE) el.ieWidth = width;
		el.style.left = left + px;
	}
}

function posAllMenus() {
	for (menu in cm) {
		positionMenu(cm[menu]);
	}
	if (pCnt == 0) window.clearInterval(posLoop);
	
	pCnt--;
}

function makeEl(tagName) { return document.createElement(tagName); }
function makeTextEl (text) { return document.createTextNode(text) }
function addText (el, text) { el.appendChild( makeTextEl(text) ) }
function getEl (elName) { return document.getElementById(elName) }
function addTopEl (el) { document.body.insertBefore(el, document.body.firstChild) }
function areaExists (chanCode) { return (getEl(chanCode + "Area") ? true : false); }

function nIt ( menu, itemName, itemURL) {
	var itemDiv = makeEl("DIV");
	//itemDiv.style.backgroundColor = (menu.chanCode == activeTab) ? cColor : oColor;
	//if (isIE) itemDiv.style.width = menu.ieWidth - 1 + px;
	itemDiv.className = "item";
	addText(itemDiv, itemName);
	itemDiv.URL = itemURL;
	itemDiv.style.backgroundColor = menu.offColor;
	itemDiv.align="left";
	addEvent (itemDiv, mOv, itemOver)
	addEvent (itemDiv, mOt, itemOut)
	addEvent (itemDiv, "onclick", itemClick)
	menu.appendChild(itemDiv);
}

/*function rfrshMenuAd (chanCode) {
	var menuHierarchy247 = (adValues[chanCode] ? adValues[chanCode] : "");
	var adVars = menuHierarchy247 + "/" + (Math.random() * 1000000000000000000) + "@Top2!Top2";
	//var adVars = "chan=" + chanCode + "&sub=" + chanCode + "menu&adsize=88x31&pagepos=8&var=" + (Math.random() * 1000000000000000000);
	if (getEl(chanCode + "MenuAdLink")) getEl(chanCode + "MenuAdLink").href = "http://oascentral.businessweek.com/RealMedia/ads/click_nx.ads/businessweek.com" + adVars;
	getEl(chanCode + "MenuAdTrack").src = "http://oascentral.businessweek.com/RealMedia/ads/adstream_nx.ads/businessweek.com" + adVars;
}*/

function addAd ( menu, imgSrc, url ) {
	var adHref = makeEl("A");
	//adHref.setAttribute ("HREF", url);
	adHref.href = url;
	adHref.target = "_parent";
	adHref.id = menu.chanCode + "MenuAdLink";

	if ( imgSrc != "") {
		var adImg = makeEl("IMG");
		adImg.src = imgSrc;
		adImg.className = "menuAdImg";
		adHref.appendChild(adImg);
		menu.appendChild(adHref);

	}
}

UA = navigator.userAgent;
chanGif = getEl ("productGif");

if (//UA.indexOf("Opera") == -1 && 
	//UA.indexOf("Safari") == -1 && 
	!(UA.indexOf("MSIE") != -1 && UA.indexOf("Mac") != -1) &&
	chanGif &&
	getEl("channelMap")) {
	
	var lastTimeout;
	actMenu = "";
	actColor = "#FFFFFF";		// rollover color for regular menus
	hlActColor = "";	// rollover color for highlighed menus
	cColor = "#0079F2";	// highlighted menu item color
	oColor = "#D6DDE4";	// regular menu item bgcolor
	isIE = (UA.indexOf("MSIE") != -1) ? true : false;
	activeTab = getEl("productGif").src;
	activeTab = activeTab.substring(activeTab.lastIndexOf("/")+1, activeTab.lastIndexOf("/")+3);
	mOv = "onmouseover";
	mOt = "onmouseout";
	px = "px";
	hid = "hidden";
	vis = "visible";
	zInd = 600;
	b = "http://www.airfares.com.sg/";
	c = "http://www.cruises.com.sg/";
	
	/*adValues = new Object();
	adValues["au"] = "/autos";
	adValues["bs"] = "/bschools";
	adValues["ca"] = "/careers";
	adValues["db"] = "/topnews";
	adValues["as"] = "/globalbiz/asia";
	adValues["eu"] = "/globalbiz/europe";
	adValues["mz"] = "/magazine";
	adValues["pi"] = "/investing";
	adValues["sb"] = "/smallbiz";
	adValues["tc"] = "/tech";
	adValues["di"] = "/innovation";
	adValues["hp"] = "/home";*/
	
	cm = new Object();
	

	
	ch = "hm";
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
	nIt(cm[ch],"Home Menu",b+"index.htm");
	nIt(cm[ch],"Travel Resources",b+"TravelResources/index.htm");
	nIt(cm[ch],"Airlines Industry News",b+"flights/AirlinesAnnouncements/AirlinesIndustryNews.htm");
	nIt(cm[ch],"Tax & Fuel Surcharge",b+"flights/AirlinesAnnouncements/AirlinesFuelSurchargeAlert.htm");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Home.gif",b+"index.htm");	}	
	
ch = "fl";
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
	nIt(cm[ch],"Flights Menu",b+"flights/main.htm");
	nIt(cm[ch],"Latest Promotions",b+"flights/2_latest_airlines.htm");
	nIt(cm[ch],"Fares by Airlines",b+"airfares/3_at_airlines.htm");
	nIt(cm[ch],"Business Class Promotions",b+"flights/business_class.htm");
	nIt(cm[ch],"Low Cost Airlines",b+"flights/low_cost_airlines.htm");
	nIt(cm[ch],"Air Passes",b+"flights/Airpasses/index.htm");
	nIt(cm[ch],"Student Fares",b+"airfares/student_fare/5_at_studentfare.htm");
	nIt(cm[ch],"Maid/Worker Fares",b+"airfares/worker_fare/5_at_worker_index.htm");
	nIt(cm[ch],"Seaman Fares",b+"airfares/SeamanFares/index.htm");
	nIt(cm[ch],"Fares by Cities","http://www.airfares.com.sg/flights/Destinations.aspx");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Flights.gif",b+"flights/2_latest_airlines.htm#cx_saver");
	}
	
	ch = "ht"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Hotels Menu","../index.htm");
	nIt(cm[ch],"Hotel by Cities","http://www.hotels.com.sg/Destinations");
	nIt(cm[ch],"CX Stay-A-While","../StayAWhile/index.htm");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Hotels.gif","../StayAWhile/index.htm");
	}
	
ch = "cr"; 
if (areaExists(ch)) {
cm[ch] = newMenu(ch);
nIt(cm[ch],"Cruises Menu",c+"index.htm");
nIt(cm[ch],"Latest Promotions",c+"promotion/latest_promotions.htm");
nIt(cm[ch],"School Holiday Promotions",c+"promotion/school_holiday_promotions.htm");
nIt(cm[ch],"Star Cruises",c+"Star_Cruises/index.htm");
nIt(cm[ch],"Royal Caribbean",c+"Royal_Caribbean/index.htm");
nIt(cm[ch],"Celebrity Cruises",c+"Celebrity_Cruises/index.htm");
nIt(cm[ch],"Princess Cruises",c+"Princess_cruises/index.htm");
nIt(cm[ch],"Holland American Line",c+"Holland_America/index.htm");
nIt(cm[ch],"Norwegian Cruise Line",c+"Norwegian_Cruises/index.htm");
nIt(cm[ch],"Silversea Cruises",c+"Silversea/index.htm");
nIt(cm[ch],"MSC Cruises",c+"MSC/index.htm");
nIt(cm[ch],"More Cruise Lines",c+"cruise_lines.htm");
addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Cruises.gif" ,c+"Star_Cruises/index.htm");
}
	
	
	
	ch = "ge"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Getaways Menu",b+"getaways/index.htm");
	nIt(cm[ch],"Indonesia Getaways",b+"getaways/indonesia.htm");
	nIt(cm[ch],"Malaysia Getaways",b+"getaways/malaysia.htm");
	nIt(cm[ch],"Thailand Getaways",b+"getaways/thailand.htm");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Getaways.gif",b+"resorts/banyantree/index.htm");
	}
	
	ch = "br"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
   nIt(cm[ch],"Resorts Menu",b+"resorts/index.htm");
	nIt(cm[ch],"Anantara",b+"resorts/Anantara/index.htm");
	nIt(cm[ch],"Angsana",b+"resorts/angsana/index.htm");
	nIt(cm[ch],"Avillion",b+"resorts/avillion/index.htm");
	nIt(cm[ch],"Banyan Tree",b+"resorts/banyantree/index.htm");
	nIt(cm[ch],"Berjaya",b+"resorts/berjaya/index.htm");
	nIt(cm[ch],"Casa Del Mar",b+"resorts/CasaDelMar/index.htm");
	nIt(cm[ch],"Club Med",b+"resorts/clubmed/index.htm");
	nIt(cm[ch],"El Nido",b+"resorts/ElNido/index.htm");
	nIt(cm[ch],"Naladhu",b+"resorts/naladhu/index.htm");	
	nIt(cm[ch],"Pimalai",b+"resorts/pimalai/index.htm");		
    nIt(cm[ch],"The Chedi",b+"resorts/thechedi/index.htm");	
	nIt(cm[ch],"The Residence",b+"resorts/residence/index.htm");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Resorts.gif",b+"resorts/index.htm");
	}	

ch = "pa"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Packages Menu", b+"packages/index.htm");
	nIt(cm[ch],"Airline Packages",b+"AirlinePackages/index.htm");
    nIt(cm[ch],"Free & Easy Packages",b+"packages/index.htm");
    nIt(cm[ch],"Tour Packages",b+"packages/index.htm");
    nIt(cm[ch],"Land Packages",b+"packages/index.htm");
	nIt(cm[ch],"Spa Packages",b+"spa/index.htm");

	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Packages.gif", b+"landtours/contiki/index.htm");
	}
	
	ch = "lt"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
	nIt(cm[ch],"Land Tours Menu",b+"landtours/index.htm");
    nIt(cm[ch],"Contiki",b+"landtours/contiki/index.htm");
	nIt(cm[ch],"Trafalgar",b+"landtours/trafalgar/index.htm");
	nIt(cm[ch],"Tourmasters",b+"landtours/tourmasters/index.htm");
	nIt(cm[ch],"Insight Vacations",b+"landtours/InsightVacations/index.html");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/LandTours.gif", b+"landtours/InsightVacations/index.html");
	}
	
	
	
	ch = "ca"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
	nIt(cm[ch],"Avis",b+"CarRental/index.htm");
	nIt(cm[ch],"Book Direct Avis",b+"CarRental/Avis/BookDirect.htm");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Cars.gif",b+"CarRental/index.htm");
	}	
	
	
	
	ch = "ra"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Rail Menu",b+"rail/index.htm");
	nIt(cm[ch],"European Rail",b+"rail/eurail/index.htm");
    nIt(cm[ch],"Japan Rail Pass",b+"rail/japan/index.htm");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Rails.gif",b+"rail/japan/index.htm");	}	
	
	ch = "in"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Insurance Menu",b+"travel_insurance/TravelGuard/index.htm");
	nIt(cm[ch],"Travel Guard",b+"travel_insurance/TravelGuard/index.htm");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Insurance.gif",b+"travel_insurance/TravelGuard/index.htm");
	}	
	
	ch = "co"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
	nIt(cm[ch],"Contact Us Home",b+"storedir/contactus1.htm");
	nIt(cm[ch],"Our Address",b+"storedir/contactus1.htm#office_add");
	nIt(cm[ch],"Business Hours",b+"storedir/contactus1.htm#Our Business Hours");
	nIt(cm[ch],"Emergency Contacts",b+"storedir/contactus1.htm#Emergency Telephone Numbers (After Office Hours)");
	nIt(cm[ch],"Enquiry & Booking",b+"storedir/AllForms.htm");
	nIt(cm[ch],"FAQ",b+"storedir/faq.htm");
	nIt(cm[ch],"Account Enquiry",b+"storedir/contactus1.htm#Account Enquiries");
	nIt(cm[ch],"Travel Partners Enquiry",b+"storedir/contactus1.htm#Travel Partners Enquiries");	
	nIt(cm[ch],"Job Vancancy",b+"storedir/contactus1.htm#Job Vacancy at Misa Travel");	
	nIt(cm[ch],"Technical Support",b+"storedir/contactus1.htm#Technical Support");
	nIt(cm[ch],"Extract Permission",b+"storedir/contactus1.htm#Permission to Extract");	
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Contact.gif",b+"storedir/contactus1.htm");

	}	
	
	pCnt = 10;
	posLoop = window.setInterval("posAllMenus()", 1000);

}
