 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.hotels.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","index.htm");
	nIt(cm[ch],"Travel Resources","TravelResources/index.htm");
	nIt(cm[ch],"Airlines Industry News","flights/AirlinesAnnouncements/AirlinesIndustryNews.htm");
	nIt(cm[ch],"Tax & Fuel Surcharge","flights/AirlinesAnnouncements/AirlinesFuelSurchargeAlert.htm");
	addAd(cm[ch],"graphic_new/brand/DropDownMenu/Home.gif","index.htm");
	}
	
	ch = "fl";
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
	nIt(cm[ch],"Flights Menu","flights/main.htm");
	nIt(cm[ch],"Latest Promotions","flights/2_latest_airlines.htm");
	nIt(cm[ch],"Fares by Airlines","airfares/3_at_airlines.htm");
	nIt(cm[ch],"First & Business Class","flights/business_class.htm");
	nIt(cm[ch],"Low Cost Airlines","flights/low_cost_airlines.htm");
	nIt(cm[ch],"Air Passes","flights/Airpasses/index.htm");
	nIt(cm[ch],"Student Fares","airfares/student_fare/5_at_studentfare.htm");
	nIt(cm[ch],"Maid/Worker Fares","airfares/worker_fare/5_at_worker_index.htm");
	nIt(cm[ch],"Seaman Fares","airfares/SeamanFares/index.htm");
	nIt(cm[ch],"Fares by Cities","http://www.airfares.com.sg/flights/Destinations.aspx");
	addAd(cm[ch],"graphic_new/brand/DropDownMenu/Flights.gif", "flights/2_latest_airlines.htm#cx_saver");
	}
	
	ch = "ht"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Hotels Menu",c+"");
	nIt(cm[ch],"Hotel by Cities","http://www.hotels.com.sg/Destinations");
	nIt(cm[ch],"CX Stay-A-While",c+"StayAWhile/index.htm");

	addAd(cm[ch],"graphic_new/brand/DropDownMenu/Hotels.gif" ,c+"StayAWhile/index.htm");
	}
	
		ch = "cr"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Cruises Menu","http://www.cruises.com.sg");
    nIt(cm[ch],"Latest Promotions","http://www.cruises.com.sg/promotion/latest_promotions.htm");
    nIt(cm[ch],"School Holiday Promotions","http://www.cruises.com.sg/promotion/school_holiday_promotions.htm");
    nIt(cm[ch],"Star Cruises","http://www.cruises.com.sg/Star_Cruises/index.htm");
    nIt(cm[ch],"Royal Caribbean","http://www.cruises.com.sg/Royal_Caribbean/index.htm");
    nIt(cm[ch],"Celebrity Cruises","http://www.cruises.com.sg/Celebrity_Cruises/index.htm");
    nIt(cm[ch],"Princess Cruises","http://www.cruises.com.sg/Princess_cruises/index.htm");
    nIt(cm[ch],"Holland American Line","http://www.cruises.com.sg/Holland_America/index.htm");
	nIt(cm[ch],"Norwegian Cruise Line","http://www.cruises.com.sg/Norwegian_Cruises/index.htm");
    nIt(cm[ch],"Silversea Cruises","http://www.cruises.com.sg/Silversea/index.htm");
    nIt(cm[ch],"MSC Cruises","http://www.cruises.com.sg/MSC/index.htm");
    nIt(cm[ch],"More Cruise Lines","http://www.cruises.com.sg/cruise_lines.htm");
    addAd(cm[ch],"graphic_new/brand/DropDownMenu/Cruises.gif" ,"http://www.cruises.com.sg/Star_Cruises/index.htm");
    }
	
	ch = "ge"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Getaways Menu","getaways/index.htm");
	nIt(cm[ch],"Indonesia Getaways","getaways/indonesia.htm");
	nIt(cm[ch],"Malaysia Getaways","getaways/malaysia.htm");
	nIt(cm[ch],"Thailand Getaways","getaways/thailand.htm");
	addAd(cm[ch],"graphic_new/brand/DropDownMenu/Getaways.gif" , "resorts/banyantree/index.htm");
	}
	
	ch = "br"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Resorts Menu","resorts/index.htm");
        nIt(cm[ch],"Anantara","resorts/Anantara/index.htm");
		nIt(cm[ch],"Angsana","resorts/angsana/index.htm");
		nIt(cm[ch],"Avillion","resorts/avillion/index.htm");
	    nIt(cm[ch],"Banyan Tree","resorts/banyantree/index.htm");
		nIt(cm[ch],"Berjaya","resorts/berjaya/index.htm");
		nIt(cm[ch],"Casa Del Mar","resorts/CasaDelMar/index.htm");
		nIt(cm[ch],"Club Med","resorts/clubmed/index.htm");
		nIt(cm[ch],"El Nido","resorts/ElNido/index.htm");
		nIt(cm[ch],"Naladhu","resorts/naladhu/index.htm");
		nIt(cm[ch],"Pimalai","resorts/pimalai/index.htm");
		nIt(cm[ch],"The Chedi","resorts/thechedi/index.htm");
		nIt(cm[ch],"The Residence","resorts/residence/index.htm");
	addAd(cm[ch],"graphic_new/brand/DropDownMenu/Resorts.gif" , "resorts/index.htm");
	}	
	
	ch = "pa"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Packages Menu","packages/index.htm");
	nIt(cm[ch],"Airline Packages ","AirlinePackages/index.htm");
    nIt(cm[ch],"Free & Easy Packages","packages/index.htm");
    nIt(cm[ch],"Tour Packages","packages/index.htm");
    nIt(cm[ch],"Land Packages","packages/index.htm");
	nIt(cm[ch],"Spa Packages","spa/index.htm");	
	addAd(cm[ch],"graphic_new/brand/DropDownMenu/Packages.gif", "landtours/contiki/index.htm");
	}	
	
	ch = "lt"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
	nIt(cm[ch],"Land Tours Menu","landtours/index.htm");
    nIt(cm[ch],"Contiki","landtours/contiki/index.htm");
	nIt(cm[ch],"Trafalgar","landtours/trafalgar/index.htm");
	nIt(cm[ch],"Tourmasters","landtours/tourmasters/index.htm");
	nIt(cm[ch],"Insight Vacations","landtours/InsightVacations/index.html");
	
	addAd(cm[ch],"graphic_new/brand/DropDownMenu/LandTours.gif", "landtours/InsightVacations/index.html");
	
	}	ch = "ca"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
	nIt(cm[ch],"Avis","CarRental/index.htm")
	nIt(cm[ch],"Book Direct Avis","CarRental/Avis/BookDirect.htm")
		addAd(cm[ch],"graphic_new/brand/DropDownMenu/Cars.gif", "CarRental/index.htm");
	
	}	ch = "ra"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Rail Menu","rail/index.htm");
	nIt(cm[ch],"European Rail","rail/eurail/index.htm");
    nIt(cm[ch],"Japan Rail Pass","rail/japan/index.htm");

addAd(cm[ch],"graphic_new/brand/DropDownMenu/Rails.gif", "rail/japan/index.htm");
	}	
	
	
	ch = "in"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Insurance Menu","travel_insurance/TravelGuard/index.htm");
	nIt(cm[ch],"Travel Guard","travel_insurance/TravelGuard/index.htm");
	addAd(cm[ch],"graphic_new/brand/DropDownMenu/Insurance.gif", "travel_insurance/TravelGuard/index.htm");
	}	
	
	ch = "co"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
	nIt(cm[ch],"Contact Us Menu","storedir/contactus1.htm");
	nIt(cm[ch],"Our Address","storedir/contactus1.htm#office_add");
	nIt(cm[ch],"Business Hours","storedir/contactus1.htm#Our Business Hours");
	nIt(cm[ch],"Emergency Contacts","storedir/contactus1.htm#Emergency Telephone Numbers (After Office Hours)");
	nIt(cm[ch],"Enquiry & Booking","storedir/AllForms.htm");
	nIt(cm[ch],"FAQ","storedir/faq.htm");
	nIt(cm[ch],"Account Enquiry","storedir/contactus1.htm#Account Enquiries");
	nIt(cm[ch],"Travel Partners Enquiry","storedir/contactus1.htm#Travel Partners Enquiries");	
	nIt(cm[ch],"Job Vacancy","storedir/contactus1.htm#Job Vacancy at Misa Travel");	
	nIt(cm[ch],"Technical Support","storedir/contactus1.htm#Technical Support");
	nIt(cm[ch],"Extract Permission","storedir/contactus1.htm#Permission to Extract");
	addAd(cm[ch],"graphic_new/brand/DropDownMenu/Contact.gif", "storedir/contactus1.htm");

	}	
	
	pCnt = 10;
	posLoop = window.setInterval("posAllMenus()", 1000);

}
