// FTC JavaScript Library
var localurl = "";
var mnsel;
var submn;
var mninit = false;
// MISCELLANEOUS FUNCTIONS
function GE_findObj(obj, d) {
  var i, x; if (!d) d=document;
  x = d[obj]; for (i=0; !x && d.layers && i < d.layers.length; i++) x = GE_findObj(obj, d.layers[i].document);
  if (!x && d.getElementById) x = d.getElementById(obj); return x;
}
function GE_showHideLayers() {
  var i, x, v, a=GE_showHideLayers.arguments;
  for (i=0; i<(a.length-1); i+=2) if ((x=GE_findObj(a[i])) != null) {
      v = a[i+1]; if (x.style) { x = x.style; v = (v == 'show') ? 'visible' : ((v == 'hide') ? 'hidden' : v); }
      x.visibility = v; }
}
function GE_preloadImages() {
  var d=document; if (d.images) { if (!d.ge_p) d.ge_p = new Array();
    var i, j=d.ge_p.length, a=GE_preloadImages.arguments;
    for (i=0; i<a.length; i++) if (a[i].indexOf("#")!=0) {
      d.ge_p[j] = new Image; d.ge_p[j++].src = a[i]; } }
}
function thisURL(url) {
  s = window.location.pathname;
	if (s.slice(0, localurl.length) != localurl)
		return url;
	else {
		if (url.indexOf("/") == 0)		// relative to root
			s = localurl;
		else {												// relative to current directory
			s = s.slice(0, s.lastIndexOf("/") + 1);
			while (url.indexOf("../") == 0) {
				url = url.slice(3, url.length);
				if (s.lastIndexOf("/", s.length-2) >= localurl.length)
					s = s.slice(0, s.lastIndexOf("/", s.length-2) + 1);
			}
		}
		return ("http://" + window.location.host + s + url);
	}
}
// MENU FUNCTIONS
function moveMenus() {
	width = GE_findObj("widthspace").width;
	left = (width - 778) / 2;
	left = (left > 0) ? left : 0;
	obj = GE_findObj("submn1");
	obj.style.left = left + 0 + "px";
	obj = GE_findObj("submn9");
	obj.style.left = left + 603 + "px";
	mninit = true;
}
function menuover(obj) {
	if (!mninit)
		return;
	for (i=1; i<10; i++) {
		if ("mn" + i != obj.id)
			GE_showHideLayers("submn" + i, "hide");
	}
	hideAllSelect();
	GE_showHideLayers("sub" + obj.id, "show");
	if (obj.style != null) {
		obj.style.color = "#FFFF00";
		obj.style.backgroundColor = "#000000";
	}
	mnsel = obj.id;
	submn = true;
}
function menuout(obj) {
	if (!mninit)
		return;
	setTimeout("menuout2('" + obj.id + "')", 100);
	submn = false;
}
function menuout2(mn) {
	if (mn != mnsel || !submn) {
		GE_showHideLayers("sub" + mn, "hide");
		obj = GE_findObj(mn);
		if (obj.style != null) {
			obj.style.color = "#000000";
			obj.style.backgroundColor = "#F4E500";
		}
	}
	if (!submn) {
		for (i=1; i<=10; i++)
			GE_showHideLayers("submn" + i, "hide");
		showAllSelect();
	}
}
function submenuover() {
	submn = true;
}
function submenuout() {
	submn = false;
	setTimeout("menuout2('" + mnsel + "')", 100);
}
function highlight(obj) {
	if (obj.style != null)
		obj.style.backgroundColor = "#000000";
	obj = GE_findObj(obj.id + "b");
	if (obj != null && obj.style != null) {
		obj.style.color = "#FFFFFF";
		obj.style.backgroundColor = "#000000";
	}
}
function dehighlight(obj) {
	if (obj.style != null)
		obj.style.backgroundColor = "#FFFFFF";
	obj = GE_findObj(obj.id + "b");
	if (obj != null && obj.style != null) {
		obj.style.color = "#000000";
		obj.style.backgroundColor = "#FFFFFF";
	}
}
function gotoLink(obj) {
	obj = GE_findObj(obj.id + "b");
	window.location = obj.href;
}
function hideAllSelect() {
	// hide all select objects in all forms
	for (i=0; document.forms[i] != null; i++) {
		if (document.forms[i] != null)
			for (j=0; j<document.forms[i].elements.length; j++) {
				sel = document.forms[i].elements[j];
				if (sel.type == "select-one" || sel.type == "select-multiple")
					sel.style.display = "none";
			}
	}
}
function showAllSelect() {
	// hide all select objects in all forms
	for (i=0; document.forms[i] != null; i++) {
		if (document.forms[i] != null)
			for (j=0; j<document.forms[i].elements.length; j++) {
				sel = document.forms[i].elements[j];
				if (sel.type == "select-one" || sel.type == "select-multiple")
					sel.style.display = "inline";
			}
	}
}
//
function tbl_highlight(obj) {
	obj.style.backgroundColor = "#000000";
}
function tbl_dehighlight(obj) {
	obj.style.backgroundColor = "#CCCCCC";
}
// Calendar
function popCalendar(form, field, date) {
	if (date == undefined)
		date = "";
	url = "../utils/calendar.php?form=" + form + "&field=" + field + "&date=" + date;
	swin = window.open(thisURL(url), "Calendar", "width=500,height=215,scrollbars=no,dependent=no");
	swin.moveTo((screen.width-500)/2, (screen.height-235)/2);
	swin.focus();
}
// IMap
function popIMap(location) {
	url = "/map/imap.php";
	swin = window.open(thisURL(url), "IMap", "width=350,height=370,scrollbars=no,dependent=no");
	swin.moveTo((screen.width-350)/2, (screen.height-370)/2);
	swin.focus();
}
// Shotcuts
function bookmarkPage() {
	javascript:window.external.AddFavorite(window.location, document.title);
}
function preload() {
	GE_preloadImages(thisURL("/images/icn_printable2.gif"));
}

// Domestic Flight Search Functions
function goSearchDomFS() {
	if (document.frmSearchDomFS.route1.value == "") {
		alert("Please select location you want to leave from.");
		return;
	}
	if (document.frmSearchDomFS.route2.value == "") {
		alert("Please select location you want to go to.");
		return;
	}
	document.frmSearchDomFS.submit();
}
function noFlexSearchDomFS() {
	document.frmSearchDomFS.flexible[0].checked = false;
	document.frmSearchDomFS.flexible[1].checked = true;
}

// Flight Info
function popFlightInfo(id) {
	url = "/tickets/flight_info_pop.php?id=" + id;
	swin = window.open(thisURL(url), "Info", "width=450,height=420,scrollbars=yes,dependent=no");
	swin.moveTo((screen.width-450)/2, (screen.height-420)/2);
	swin.focus();
}
function popFareInfo(id, roundtrip) {
	url = "/tickets/fare_info_pop.php?id=" + id + "&roundtrip=" + roundtrip;
	swin = window.open(thisURL(url), "Info", "width=580,height=400,scrollbars=yes,dependent=no");
	swin.moveTo((screen.width-580)/2, (screen.height-400)/2);
	swin.focus();
}
function popAffiliateFareInfo(affiliate, id, roundtrip) {
	url = "http://ticketservice.com.ph/" + affiliate + "/fare_info_pop.php?id=" + id + "&roundtrip=" + roundtrip;
	swin = window.open(url, "Info", "width=450,height=300,scrollbars=yes,dependent=no");
	swin.moveTo((screen.width-450)/2, (screen.height-300)/2);
	swin.focus();
}

