 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/";
	g = "http://www.getaways.com.sg/";
	r = "http://www.resorts.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");
	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/index.aspx");
	nIt(cm[ch],"Latest Airlines Promotions",b+"flights/LatestPromotions.aspx");
nIt(cm[ch],"Economy Class",b+"flights/EconomyClassFares.aspx");
nIt(cm[ch],"Premium Economy Class",b+"flights/PremiumEconomy/index.htm");
nIt(cm[ch],"First & Business Class",b+"flights/business_class.htm");
nIt(cm[ch],"Round The World",b+"flights/RoundTheWorld/index.htm");
nIt(cm[ch],"Air Passes",b+"flights/Airpasses/index.htm");
nIt(cm[ch],"Student Fares",b+"flights/StudentFare.aspx");
nIt(cm[ch],"Maid/Worker Fares","http://www.maidfares.com/Default.aspx");
nIt(cm[ch],"Senior Citizen Fares","http://www.seniorcitizenfares.com/Default.aspx");
nIt(cm[ch],"Seaman Fares","http://www.seamanfares.com.sg/Default.aspx");
nIt(cm[ch],"Low Cost Airlines",b+"flights/low_cost_airlines.htm");
nIt(cm[ch],"Fares by Cities",b+"airfares/3_at_city.htm");
nIt(cm[ch],"Fares by Airlines",b+"airfares/3_at_airlines.htm");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Flights.gif",b+"flights/2_latest_airlines.htm#cx_saver");
	}
		

	ch = "ht-none"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Hotels Menu",c+"index.htm");
	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],b+"graphic_new/brand/DropDownMenu/Hotels.gif",c+"StayAWhile/index.htm");
	}
	
ch = "cr"; 
if (areaExists(ch)) {
cm[ch] = newMenu(ch);
nIt(cm[ch],"Cruises Menu","index.htm");
nIt(cm[ch],"Latest Promotions","promotion/latest_promotions.htm");
nIt(cm[ch],"School Holiday Promotions","promotion/school_holiday_promotions.htm");
nIt(cm[ch],"Star Cruises","Star_Cruises/index.htm");
nIt(cm[ch],"Royal Caribbean","Royal_Caribbean/index.htm");
nIt(cm[ch],"Celebrity Cruises","Celebrity_Cruises/index.htm");
nIt(cm[ch],"Princess Cruises","Princess_cruises/index.htm");
nIt(cm[ch],"Holland American Line","Holland_America/index.htm");
nIt(cm[ch],"Norwegian Cruise Line","Norwegian_Cruises/index.htm");
nIt(cm[ch],"Silversea Cruises","Silversea/index.htm");
nIt(cm[ch],"MSC Cruises","MSC/index.htm");
nIt(cm[ch],"More Cruise Lines","cruise_lines.htm");
addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Cruises.gif" ,"Star_Cruises/index.htm");
}
	
	
	ch = "ge"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
    nIt(cm[ch],"Getaways Menu",g+"index.aspx");
	nIt(cm[ch],"Indonesia Getaways",g+"country/Indonesia");
	nIt(cm[ch],"Malaysia Getaways",g+"country/Malaysia");
	nIt(cm[ch],"Thailand Getaways",g+"country/Thailand");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Getaways.gif",r+"Banyan-Tree/HA2");
	}
	
	ch = "br"; 
if (areaExists(ch)) {
cm[ch] = newMenu(ch);
nIt(cm[ch],"Resorts Menu",r+"index.aspx");
	nIt(cm[ch],"Anantara",r+"Anantara/HB1");
	nIt(cm[ch],"Angsana",r+"Angsana/HC1");
	nIt(cm[ch],"Banyan Tree",r+"Banyan-Tree/HA2");
	nIt(cm[ch],"Chaweng / Melati",r+"Chaweng-_-Melati/HB3");
	nIt(cm[ch],"Club Med",r+"Club-Med/HH3");
	nIt(cm[ch],"Kayumanis",r+"Kayumanis/HB11");
	nIt(cm[ch],"Nirwana",r+"Nirwana/HB14");	
    nIt(cm[ch],"Universal Resorts",r+"Universal-Resorts/HA19");
addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Resorts.gif",r+"Club-Med/HH3");
}	

	
	
ch = "pa"; 
	if (areaExists(ch)) {
	cm[ch] = newMenu(ch);
   nIt(cm[ch],"Packages Menu", b+"Packages/index.aspx");
	nIt(cm[ch],"Airline Packages",b+"AirlinePackages/index.aspx");
    nIt(cm[ch],"Free & Easy Packages",b+"Free_Easy_Packages/index.aspx");
    nIt(cm[ch],"Tour Packages",b+"TourPackages/index.aspx");
    nIt(cm[ch],"Land Packages",b+"LandPackages/index.aspx");
   
	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/index.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],"Eurail Rail",b+"rail/eurail/index.htm");
    nIt(cm[ch],"BritRail Pass",b+"rail/eurail/index.htm#B");
	nIt(cm[ch],"Japan Rail Pass",b+"rail/japan/index.htm");
	nIt(cm[ch],"Korail Pass",b+"rail/Korea/Korea.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/TravelDefence/index.htm");
	nIt(cm[ch],"Travel Guard",b+"travel_insurance/TravelDefence/index.htm");
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Insurance.gif",b+"travel_insurance/TravelDefence/index.htm");
	}	
	
	ch = "co"; 
	if (areaExists(ch)) {
		
	cm[ch] = newMenu(ch);
	nIt(cm[ch],"Feedback to us","http://www.misatravel.com/feedback/index.aspx?s=w");
	nIt(cm[ch],"Visa Application",b+"storedir/apply-visa.htm");
	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");	
	nIt(cm[ch],"Subscribe our Mailimg List","http://www.airfares.com.sg/newsletter/registration.aspx");	
	addAd(cm[ch],b+"graphic_new/brand/DropDownMenu/Contact.gif",b+"storedir/contactus1.htm");

	}	
	
	pCnt = 10;
	posLoop = window.setInterval("posAllMenus()", 1000);

}

