//-------------------------------------------------------------------------------------------------
	var moAgentChangeWindow = null;
	var moPolicyWindow = null;
	var moCreditUpdatesWindow = null;
//-------------------------------------------------------------------------------------------------
	if (document.addEventListener) {
		document.addEventListener('unload',HideAllWindows,false);
		document.addEventListener('focus',HidePolicyCreditUserWindows,false);
	}

//-------------------------------------------------------------------------------------------------
	function ShowCreditUpdates() {
		var oCtrl = document.getElementById("UserID");
		if (oCtrl!=null) {
			var sUserID = oCtrl.value.toString();
			var sURL = "CreditUpdates.asp?UserID=" + sUserID;
			var iWidth = 650;
			var iHeight = 480;
			var iLeft = ((screen.availWidth - iWidth) / 2);
			var iTop = ((screen.availHeight - iHeight) / 2);
			var sFeatures = "status=0, location=0, scrollbars=0, menubar=0, toolbar=0, ";
			sFeatures += "resizable=1, width=" + iWidth + ", height=" + iHeight;
			sFeatures += ", left=" + iLeft + ", top=" + iTop;
			moCreditUpdatesWindow = window.open(sURL,"_blank", sFeatures, false);
			if (moCreditUpdatesWindow==null) {
				window.alert("Your popup suppressor software has disabled this feature!");
			}
		}
	}
//-------------------------------------------------------------------------------------------------

	function SwitchTrans(sTransType) {
		var sTrans = (sTransType.toLowerCase()=="shuttle") ? "LuxSedan" : "Shuttle";
		var oCtrl = document.getElementById("TransType");
		if (oCtrl!=null) oCtrl.value = sTrans;
		
		var sFlds = "TransType|SessionID|SessSeqNbr|RefPage|AdultCount|UserID|UserAuth|" +
			"chkFromAirportStatus|chkToAirportStatus|Referrer|FromLocCode|ToLocCode|" +
		  "PickupDate|AgentIATA|AgentName|AgentLogin|WebPrtyCode";
		var sParms = "?"
		var saFld = sFlds.split("|");
		for (var i=0; i<saFld.length; i++) {
			oCtrl = document.getElementById(saFld[i]);
			if (oCtrl!=null) {
				if (i > 0) sParms = sParms + "&";
				var sValue = oCtrl.value.toString();
				if (sTrans=="Shuttle") {
					if (saFld[i]=="chkFromAirportStatus") sValue = "True";
					if (saFld[i]=="chkToAirportStatus") sValue = "False";
					if (saFld[i]=="FromLocCode") sValue = "100";
					if (saFld[i]=="ToLocCode") {
						if (sValue=="100") sValue = "0";
					}
				}
				if ((saFld[i]=="AdultCount") && isNaN(parseInt(sValue))) sValue = "0";
				sParms = sParms + saFld[i] + "=" + escape(sValue);
			}
		}
		var sURL = "ShutSedan.asp" + sParms;
		document.location.replace(sURL);
	}
//-------------------------------------------------------------------------------------------------

	function ContactUs() {
		window.location.href = "ContactUs.htm";
	}
	
	//-------------------------------------------------------------------------------------------------

	function Account() {
		window.location.href = "../AccountCustomers/Default.aspx";
	}
//-------------------------------------------------------------------------------------------------

	function TermsOfUse() {
		var sURL = "http://www.mearstransportation.com/pdf/TermsOfUse.pdf"; 
		var sWidth = (parseInt(screen.availWidth) * 0.8).toString() + "px";
		var sHeight = (parseInt(screen.availHeight) * 0.7).toString() + "px";
		var sLeft = ((parseInt(screen.availWidth) - parseInt(sWidth)) / 2).toString() + "px";
		var sTop = ((parseInt(screen.availHeight) - parseInt(sHeight) - 100) / 3).toString() + "px";
		var sFeatures = "status=1, location=0, scrollbars=1, menubar=0, toolbar=0, ";
		sFeatures += "resizable=1, width=" + sWidth + ", height=" + sHeight;
		sFeatures += ", left=" + sLeft + ", top=" + sTop;
		window.open(sURL, "_blank", sFeatures);
	}
//-------------------------------------------------------------------------------------------------		

	function ShowAgentChange() {
		HideAgentChangeWindow();
		var oCtrl = document.getElementById("AgentIATA");
		if (oCtrl!=null) {
			var sIATA = oCtrl.value.toString();
			var sURL = "AgentChange.asp?AgentIATA=" + sIATA;
			var iWidth = 360;
			var iHeight = 375;
			var iLeft = ((screen.availWidth - iWidth) / 2);
			var iTop = ((screen.availHeight - iHeight) / 2);
			var sFeatures = "status=0, location=0, scrollbars=0, menubar=0, toolbar=0, ";
			sFeatures += "resizable=0, width=" + iWidth + ", height=" + iHeight;
			sFeatures += ", left=" + iLeft + ", top=" + iTop;
			moAgentChangeWindow = window.open(sURL,"_blank", sFeatures, false);
			if (moAgentChangeWindow==null) {
				window.alert("Your popup suppressor software has disabled this feature!");
			}
		}
	}
//-------------------------------------------------------------------------------------------------		

	function ShowPolicy() {
		HidePolicyWindow();
		var oCtrl = document.getElementById("AgentIATA");
		if (oCtrl!=null) {
			var sIATA = oCtrl.value.toString();
			var sURL = "Policy.asp?AgentIATA=" + sIATA;
			var iWidth = 600;
			var iHeight = 375;
			var iLeft = ((screen.availWidth - iWidth) / 2);
			var iTop = ((screen.availHeight - iHeight) / 2);
			var sFeatures = "status=0, location=0, scrollbars=0, menubar=0, toolbar=0, ";
			sFeatures += "resizable=1, width=" + iWidth + ", height=" + iHeight;
			sFeatures += ", left=" + iLeft + ", top=" + iTop;
			moPolicyWindow = window.open(sURL,"_blank", sFeatures, false);
			if (moPolicyWindow==null) {
				window.alert("Your popup suppressor software has disabled this feature!");
			}
		}
	}
//-------------------------------------------------------------------------------------------------		

	function HideAgentChangeWindow() {
		var oWin = moAgentChangeWindow;
		var bVisible = false;
		if (oWin!=null) {
			try {bVisible = (oWin.closed!=true) ? true : false;} catch(e) {bVisible = false;}
			if (bVisible==true) oWin.close();
			moAgentChangeWindow = null;
		}
	}
//-------------------------------------------------------------------------------------------------		

	function HidePolicyWindow() {
		var oWin = moPolicyWindow;
		var bVisible = false;
		if (oWin!=null) {
			try {bVisible = (oWin.closed!=true) ? true : false;} catch(e) {bVisible = false;}
			if (bVisible==true) oWin.close();
			moPolicyWindow = null;
		}
	}
//-------------------------------------------------------------------------------------------------		

	function HideCreditUpdatesWindow() {
		var oWin = moCreditUpdatesWindow;
		var bVisible = false;
		if (oWin!=null) {
			try {bVisible = (oWin.closed!=true) ? true : false;} catch(e) {bVisible = false;}
			if (bVisible==true) oWin.close();
			moCreditUpdatesWindow = null;
		}
	}
//-------------------------------------------------------------------------------------------------		

	function HidePolicyCreditUserWindows() {
		HidePolicyWindow();
		HideCreditUpdatesWindow();
		HideUserWindow();
	}
//-------------------------------------------------------------------------------------------------		

	function HideAllWindows() {
		HideAgentChangeWindow();
		HidePolicyWindow();
		HideUserWindow();
	}
//-------------------------------------------------------------------------------------------------

	function UpdateAgentInfo(sHTML) {
		var oCtrl = document.getElementById("tdAgentInfo");
		if (oCtrl!=null) {
			oCtrl.innerHTML = sHTML;
		}
	}
//-------------------------------------------------------------------------------------------------
