//<!--

// convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();

// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);

// Note: Opera and WebTV spoof Navigator.  We do strict client detection.
// If you want to allow spoofing, take out the tests for opera and webtv.
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                      (agt.indexOf("; nav") != -1)) );
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_gecko = (agt.indexOf('gecko') != -1);


var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
// or if this is the first browser window opened.  Thus the
// variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
var is_aol   = (agt.indexOf("aol") != -1);
var is_aol3  = (is_aol && is_ie3);
var is_aol4  = (is_aol && is_ie4);
var is_aol5  = (agt.indexOf("aol 5") != -1);
var is_aol6  = (agt.indexOf("aol 6") != -1);

var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

var range = ""

if (is_ie || is_opera)
{
	range = "all."
}

// Convert object name string or object reference
// into a valid object reference
function getObject(obj) {
	var theObj;
	
	if (typeof obj == "string") {
		theObj = document.getElementById(obj);
		// this is bad - it works only under IE!
		//theObj = eval("document." + range + obj)

		// this works under IE 6.0 and opera 7
		//theObj = eval(obj)
	} else {
		theObj = obj
	}
	
	return theObj
} 

function getObjectByName(obj) {
	var theObjs = document.getElementsByName(obj);
	if (theObjs == null)
		return null;
	return theObjs.item(0);
}

function DelayedWindowFocuser_Timeout() {
	if (this.m_hWnd != null && !this.m_hWnd.closed) {
		this.m_hWnd.focus();
	}
}

function DelayedWindowFocuser(_hWnd) {
	this.m_hWnd = _hWnd;
}

DelayedWindowFocuser.prototype.TimeOut = DelayedWindowFocuser_Timeout;

var LoginWindowCommon = null;
var idCheckLoginWindowCommon = null;

function CheckLoginWindowCommon() {
	if (LoginWindowCommon != null && LoginWindowCommon.closed) {
		LoginWindowCommon = null;
		clearInterval(idCheckLoginWindowCommon);
		__doPostBack('AfterLogin','');
	}
}

function GetPositionY(o) {
	var OffsetTop = 0;
	if (is_nav) {
		OffsetTop = o.y;
	} else {
		while (o != null) {
			OffsetTop += o.offsetTop;
			o = o.offsetParent;
		}
	}
	return OffsetTop;
}

function showProps(o) {
	var result = "";
	count = 0;
	for (var i in o) {
		result += o + "." + i + "=" + o[i] + "\n";
		count++;
		if (count == 25) {
			alert(result);
			result = "";
			count = 0;
		}
	}
	alert(result);
} 

function SaveScrolling() {
//	showProps(document.body);
	var obj = getObjectByName("LastScrollTop");
	if (obj != null) {
		obj.value = document.body.scrollTop;
	}
}

function DoScrollablePostBack(CmdName) {
	SaveScrolling();
	__doPostBack(CmdName, '');
}

function DoScrollablePostBack2(CmdName, CmdArg) {
	SaveScrolling();
	__doPostBack(CmdName, CmdArg);
}

// restore the last known scrollTop
function RestoreScrolling() {
	var obj = getObjectByName("LastScrollTop");
	if (obj != null) {
		document.body.scrollTop = obj.value;
	}
}

var evt;
function fnTrapEnter(MyEvent, btn, OldFnc){
	if (MyEvent == null)
		MyEvent = event;
		
	if (MyEvent.keyCode == 13) {
		MyEvent.returnValue=false;
		MyEvent.cancelBubble = true;
		var xObj = getObject(btn);
		if (xObj != null) {
			if (xObj.click != null && !is_opera) {
				xObj.click();
			} else if (xObj.href.indexOf('javascript') >= 0) {
				eval(xObj.href);
				//();
			} else {
				// some dummy browser
				//xObj.click();
			}
		}
	}
	if (!MyEvent.cancelBubble && OldFnc != null) {
		OldFnc(MyEvent);
	}
	return MyEvent.returnValue;
}
function fnTrapEnterJS(MyEvent, js, OldFnc){
	if (MyEvent == null)
		MyEvent = event;
		
	if (MyEvent.keyCode == 13) {
		MyEvent.returnValue=false;
		MyEvent.cancelBubble = true;
		eval(js);
	}
	if (!MyEvent.cancelBubble && OldFnc != null) {
		OldFnc(MyEvent);
	}
	return MyEvent.returnValue;
}

function SetOnKeyDownEH(obj, NewEH) {
	if (obj == null)
		return null;
		
	var retVal = obj.onkeydown;
	obj.onkeydown = NewEH;
	return retVal;
}

function AutoResize() {
	try {
		var ScrollWidth = parseInt(document.body.scrollWidth);
		var ExtendWidth = 0;
		var ClientWidth = parseInt(document.body.clientWidth);
		ExtendWidth = ScrollWidth - ClientWidth;

		var ScrollHeight = parseInt(document.body.scrollHeight);
		var ExtendHeight = 0;
		var ClientHeight = parseInt(document.body.clientHeight);
		ExtendHeight = ScrollHeight - ClientHeight;

		self.resizeBy(ExtendWidth, ExtendHeight); 
		// self.resizeTo(screen.availWidth,screen.availHeight));
	} catch (e) {
	}
}

function AddMonth(MonthYear) {
	var Year = Number(MonthYear.substring(0, 4));
	var Month = Number(MonthYear.substring(4, 6));
	Month = Month + 1;

	if (Month == 13) {
		Month = 1;
		Year++;
	}
	var sMonth = Month.toString();
	if (Month < 10) 
		sMonth = "0" + sMonth;

	return (Year.toString() + sMonth);
}

var DayToday = null;
var Ticket2WayObj = null;
var DayDepartureObj = null;
var DayArrivalObj = null;
var MonthYearDepartureObj = null;
var MonthYearArrivalObj = null;
var ReturnDateObj = null;

function IsFlyingBack() {
	return Ticket2WayObj!=null && Ticket2WayObj.checked;
}

function DayArrivalChanged() {
	// the return day is earlier than the outbound date
	// it means that we need one month more than outbound month-year
	if (DayArrivalObj.value < DayDepartureObj.value && 
		MonthYearArrivalObj.value <= MonthYearDepartureObj.value) 
	{
		MonthYearArrivalObj.value = AddMonth(MonthYearDepartureObj.value);
	}
}

function MonthYearDepartureChanged() {
	if (!IsFlyingBack())
		return;

	if (MonthYearDepartureObj.value > MonthYearArrivalObj.value ||
		(MonthYearDepartureObj.value == MonthYearArrivalObj.value && DayDepartureObj.value > DayArrivalObj.value)) {
		MonthYearArrivalObj.value = MonthYearDepartureObj.value;
		// no time playing with leap years, etc. now, set it simply to the same date
		DayArrivalObj.value = DayDepartureObj.value;
		// not needed, since the data are simply copied
		//DayArrivalChanged();
	}
}

function DayDepartureChanged() {
	var sYear = (new Date()).getFullYear().toString();
	var Month = (new Date()).getMonth() + 1;
	var sMonth = Month.toString();
	
	if (Month < 10) 
		sMonth = "0" + sMonth;
		
	var sYearMonth = sYear + sMonth;
	if (DayDepartureObj.value >= DayToday || sYearMonth < MonthYearDepartureObj.value)
		return;

	// The day is obviously in the future, because the day < today's day
	// move the month+year to the future, if not yet
	if (MonthYearDepartureObj.selectedIndex == 0) {
		MonthYearDepartureObj.selectedIndex = 1;
		MonthYearDepartureChanged();
	}

	if (!IsFlyingBack())
		return;

	if (MonthYearDepartureObj.value > MonthYearArrivalObj.value ||
		(MonthYearDepartureObj.value == MonthYearArrivalObj.value && DayDepartureObj.value > DayArrivalObj.value)) {

		MonthYearArrivalObj.value = MonthYearDepartureObj.value;
		DayArrivalObj.value = DayDepartureObj.value;
	}
}

//-----
function DayArrivalChanged2(_DayFrom, _MonthYearFrom, _DayTo, _MonthYearTo) {
	// the return day is earlier than the outbound date
	// it means that we need one month more than outbound month-year
	if (_DayTo.value < _DayFrom.value && 
		_MonthYearTo.value <= _MonthYearFrom.value) 
	{
		var val = AddMonth(_MonthYearFrom.value);
		
		if (_MonthYearTo.value != val)
			_MonthYearTo.value = val;
	}
}

function MonthYearArrivalChanged2(_DayFrom, _MonthYearFrom, _DayTo, _MonthYearTo) {
	if (_MonthYearFrom.value > _MonthYearTo.value ||
		(_MonthYearFrom.value == _MonthYearTo.value && _DayFrom.value > _DayTo.value)) {
		
		if (_MonthYearTo.value != _MonthYearFrom.value)
			_MonthYearTo.value = _MonthYearFrom.value;
		
			// no time playing with leap years, etc. now, set it simply to the same date
		if (_DayTo.value != _DayFrom.value)
			_DayTo.value = _DayFrom.value;
		// not needed, since the data are simply copied
		//DayArrivalChanged();
	}
}

function MonthYearDepartureChanged2(_DayFrom, _MonthYearFrom, _DayTo, _MonthYearTo) {
	if (_MonthYearFrom.value > _MonthYearTo.value ||
		(_MonthYearFrom.value == _MonthYearTo.value && _DayFrom.value > _DayTo.value)) {
		
		if (_MonthYearTo.value != _MonthYearFrom.value)
			_MonthYearTo.value = _MonthYearFrom.value;
		
			// no time playing with leap years, etc. now, set it simply to the same date
		if (_DayTo.value != _DayFrom.value)
			_DayTo.value = _DayFrom.value;
		// not needed, since the data are simply copied
		//DayArrivalChanged();
	}
}

function DayDepartureChanged2(_DayFrom, _MonthYearFrom, _DayTo, _MonthYearTo) {
	DayToday = (new Date()).getDate();
	if (_DayFrom.value >= DayToday)
		return;

	// The day is obviously in the future, because the day < today's day
	// move the month+year to the future, if not yet
	if (_MonthYearFrom.selectedIndex == 0) {
		_MonthYearFrom.selectedIndex = 1;
		MonthYearDepartureChanged2(_DayFrom, _MonthYearFrom, _DayTo, _MonthYearTo);
	}

	if (_MonthYearFrom.value > _MonthYearTo.value ||
		(_MonthYearFrom.value == _MonthYearTo.value && _DayFrom.value > _DayTo.value)) {
	
		if (_MonthYearTo.value != _MonthYearFrom.value)
			_MonthYearTo.value = _MonthYearFrom.value;
			
		if (_DayTo.value != _DayFrom.value)
			_DayTo.value = _DayFrom.value;
	}
}
//-----

function HideImage(IconName) {
	document.getElementById(IconName).width = 0;
}

// Create a cookie with the specified name and value.
// The cookie expires at the end of the 20th century.
function SetCookie(sName, sValue) {
  date = new Date();
  document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString();
}

// Delete the cookie with the specified name.
function DelCookie(sName) {
	var today = new Date();
	var expired = new Date(today.getTime() - 48 * 60 * 60 * 1000); // less 2 days

	document.cookie = sName + "=null; expires=" + expired.toGMTString();
    bikky = document.cookie;
}

function SafeEnable(obj, state) {
	var theObj = null;
	if (typeof obj == "string") {
		theObj = getObject(obj);
	} else {
		theObj = obj;
	}
	if (theObj != null) {
		theObj.disabled = !state;
	}
}

function SetCheckedSafe(obj, value) {
	var theObj = null;
	if (typeof obj == "string") {
		theObj = getObject(obj);
	} else {
		theObj = obj;
	}
	if (theObj != null) {
		theObj.checked = value;
	}
}

function EnableCheckBox(theObj, bEnable) {
	theObj.disabled = !bEnable;
	if (bEnable && theObj.parentElement != null) {
		theObj.parentElement.disabled = false; // stupid SPAN around checkbox
	}
}

function OneOrTwoWayChk() {
	if (!IsFlyingBack()) {
		ReturnDateObj.style.visibility = 'hidden';
	} else {
		ReturnDateObj.style.visibility = 'visible';
	}
}

var g_AirportDest_0 = new Array(0, -1);
// var g_AirportName_2 = "Wien";
// var g_AirportDest_1 = new Array(0,4,17,18,14,6,10,12,9,21,5,8,19,16,20,7,11,2);
function OnOriginAirportChanged(o, d) {
	var destList;
	try {
		if (o.selectedIndex >= 0) {
			destList = eval("g_AirportDest_" + o.value);
		} else {
			destList = new Array();
		}
	} catch (e) {
		destList = new Array();
	}

	var OldDestination = d.value; // remember the old destionation airport
	var OldDestPresent = false;
	d.length = 0; //Remove current options
	
	// set new options length
	if (o.value == '0') {
		d.length = 1;
	} else {
		d.length = destList.length; 
	}

    //loop through the array and add all the new values ..
    var DestIX;
    for (var i = 0; i< destList.length; i++) {
		DestIX = destList[i];
		if (DestIX >= 0) {
			d[i].text = eval("g_AirportName_" + DestIX);
			d[i].value = DestIX;
			if (OldDestination == DestIX) {
				OldDestPresent = true;
			}
		}
	}
	
	if (OldDestPresent) {
		d.value = OldDestination;
		try {
			var strMinDateOD = eval("g_FlightRoutesMinDate_" + d.value + "_" + o.value);
		} catch (e) {}
		try {
			var strMinDateDO = eval("g_FlightRoutesMinDate_" + o.value + "_" + d.value);
		} catch (e) {}
		
		if(strMinDateOD != null) {
			var MinDateOD = new Date(strMinDateOD.substring(6, 10), strMinDateOD.substring(3, 5) - 1, strMinDateOD.substring(0, 2));
		}
		if(strMinDateDO != null) {
			var MinDateDO = new Date(strMinDateDO.substring(6, 10), strMinDateDO.substring(3, 5) - 1, strMinDateDO.substring(0, 2));
		}
		
		if(MinDateOD != null && MonthYearDepartureObj != null) {
			CheckFlightsMonthYear(MinDateOD, MonthYearDepartureObj);
		}
		if(MinDateDO != null && MonthYearArrivalObj != null) {
			CheckFlightsMonthYear(MinDateDO, MonthYearArrivalObj);
		}
	}
		
}

function CheckFlightsMonthYear(mindate, obj) {
	var OldValue = obj.value;
	obj.length = 0;
	
	var MaxMonth = g_MaxDepartureDate.getMonth();
	var MaxYear = g_MaxDepartureDate.getFullYear();
	var sMaxMonth = MaxMonth.toString();
	if (MaxMonth < 10) {
		sMaxMonth = "0" + sMaxMonth;
	}
	var sMaxYearMonth = MaxYear.toString() + sMaxMonth;
	
	var TodayMonth = (new Date()).getMonth();
	var TodayYear = (new Date()).getFullYear();
	var sTodayMonth = TodayMonth.toString();
	if (TodayMonth < 10) {
		sTodayMonth = "0" + sTodayMonth;
	}
	var sTodayYearMonth = TodayYear.toString() + sTodayMonth;
	
	var MinMonth = mindate.getMonth();
	var MinYear = mindate.getFullYear();
	var sMinMonth = MinMonth.toString();
	if (MinMonth < 10) {
		sMinMonth = "0" + sMinMonth;
	}
	var sMinYearMonth = MinYear.toString() + sMinMonth;
	
	var i = 0;
	
	while(Number(sMinYearMonth) <= Number(sMaxYearMonth)) {
		if(Number(sMinYearMonth) >= Number(sTodayYearMonth)) {
			var entry = document.createElement("option");
			var entrytext = g_Calendar_Months[Number(sMinYearMonth.substring(4, 6))] + " " + sMinYearMonth.substring(0, 4);
			var entryvalue = JSMonthToAspMonth(sMinYearMonth);
			entry.text = g_Calendar_Months[Number(sMinYearMonth.substring(4, 6))] + " " + sMinYearMonth.substring(0, 4);
			entry.value = JSMonthToAspMonth(sMinYearMonth);
			obj.add(entry, i);
			if(JSMonthToAspMonth(sMinYearMonth) == OldValue) {
				obj.value = JSMonthToAspMonth(sMinYearMonth);
			}
			i++;
		}
		sMinYearMonth = AddMonth(sMinYearMonth);
	}	
}

function JSMonthToAspMonth(JSMonth) {
	var Month = Number(JSMonth.substring(4, 6)) + 1;
	var sMonth = Month.toString();
	if(Month < 10) {
		var sMonth = "0" + sMonth;
	}
	return JSMonth.substring(0, 4) + sMonth;
}

/*function AspMonthToJSMonth(AspMonth) {
	var Month = Number(AspMonth.substring(4, 6)) - 1;
	var sMonth = Month.toString();
	if(Month < 10) {
		var sMonth = "0" + sMonth;
	}
	return AspMonth.substring(0, 4) + sMonth;
}*/

function CopyAirports(s, d) {
	d.length = s.length;
	for(var i=0; i<s.length;i++) {
		d[i].text = s[i].text;
		d[i].value = s[i].value;
	}
	
	d.value = s.value;
}
/*
TIMO
function CopyAirports2(s, d, x) {
	var c = s.length;
	for(var i=0; i<s.length;i++) {
		if (s[i].value == x) {
			c = s.length-1;
			break;
		}
	}
	d.length = c;
	var j = 0;
	for(var i=0; i<s.length;i++) {
		if (s[i].value != x) {
			d[j].text = s[i].text;
			d[j++].value = s[i].value;
		}
	}
	
	d.value = s.value;
}
*/

function SetWaitCursor(evt) {
	var MyEvent1 = evt;
	if (MyEvent1 == null)
		MyEvent1 = event;
		
	if (MyEvent1 != null && MyEvent1.srcElement != null) {
		if (MyEvent1.srcElement.style.WaitText != null)
			MyEvent1.srcElement.innerText = eval(MyEvent1.srcElement.style.WaitText);
		MyEvent1.srcElement.style.cursor = "wait";
	}
	document.body.style.cursor = "wait";
}

function SetWaitCursorOnClick(obj) {
	if (obj != null) 
		obj.onclick = SetWaitCursor;
}

function GetAbsolutePositionX(obj) {
	var retVal = 0;
	
	while (obj != null) {
		retVal += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return retVal;
}

function CalcOffsetLeftFromAbsoluteX(obj, X) {
	X -= obj.offsetLeft;
	obj = obj.offsetParent;
	while (obj != null) {
		X -= obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return X;
}

function CloseCurrentWindow() {
	var wnd = window;
	while (wnd.parent != null && wnd.parent != wnd) {
		wnd = wnd.parent;
	}
	wnd.close();
}

function CloseCurrentWindowRefreshOpener() {
	try {
		window.opener.__doPostBack('RefreshPage','');
	 } catch (_err) {}
			
	var wnd = window;
	while (wnd.parent != null && wnd.parent != wnd) {
		wnd = wnd.parent;
	}
	wnd.close();
}

function OpenCustomerCard(StartURL, CustomerID, URLExt, bRefreshAfterClose) {
	if (URLExt == null)
		URLExt = "";
	var wnd = window.open(StartURL + "/FBEngine.UI/AMAccountMngmt.aspx?Who=Customer&CustomerID=" + CustomerID.toString() + URLExt, "Helv_AccountMngmt_Customer_" + CustomerID.toString(), "width=850,height=600,scrollbars=yes,menubar=no,status=yes,resizable=yes");
	wnd.focus();
	if (bRefreshAfterClose) {
		LoginWindowCommon = wnd;
		idCheckLoginWindowCommon = window.setInterval(CheckLoginWindowCommon, 1000);
	}
}

function OpenBookingCard(StartURL, BookingID, URLExt) {
	if (URLExt == null)
		URLExt = "";
	var wnd = window.open(StartURL + "/FBEngine.UI/CCEditBookingFS.aspx?BId=" + BookingID.toString() + URLExt, "HelRes_EditBk_" + BookingID.toString(), 'width=850,height=600,scrollbars=yes,menubar=no,status=yes,resizable=yes');
	wnd.focus();
}

function OpenFlightCard(StartURL, FIID, URLExt) {
	var width = 1024;
	var height = 748;
	if (screen.availWidth - 20 < width)
		width = screen.availWidth - 20;
	if (screen.availHeight - 40 < height)
		height= screen.availHeight - 40;
		
	var wnd = window.open(StartURL + "/FBEngine.UI/CCFMFlightCard.aspx?FIID=" + FIID.toString() + URLExt, "HelRES_FlightCard" + FIID.toString(), "width=" + width.toString() + ",height="+ height.toString() +",scrollbars=yes,menubar=no,resizable=yes");

	wnd.focus();
}

function OpenContractCard(ContractIDToSet) {
	var width = 1024;
	var height = 870;
	if (screen.availWidth - 20 < width)
		width = screen.availWidth - 20;
	if (screen.availHeight - 40 < height)
		height= screen.availHeight - 40;

	var wnd = window.open('AAContractCard.aspx?&ContractID='+ContractIDToSet, 'Helvetic_AllotmentBooking_Contract_'+ContractIDToSet, 'width=' + width.toString() + ',height='+ height.toString() +',left=100,top=100,scrollbars=yes,menubar=no,resizable=yes');
	wnd.focus();
}

function OpenFixReservationCard(ContractID, FixResIDToSet, PageID) {
	var wnd = window.open('AAFlightCard.aspx?&ContractID='+ContractID+'&FixResID='+FixResIDToSet+'&PageID='+PageID, 'Helvetic_AllotmentBooking_FlightFixRes_'+FixResIDToSet, 'width=820,height=600,scrollbars=yes,menubar=no,resizable=yes');
	wnd.focus();
}

// for FlightSearch Destination-Combo synchronisation
function OnFlightOriginListChanged(orig, dest, destBack, origBack) {	// Hinflug Startflughafen ändert
	OnOriginAirportChanged(orig, dest);
	
	OnFlightDestinationListChanged(orig, dest, destBack, origBack);	
	
	if (origBack != null) {
		origBack.value = dest.value;
	}
	if (destBack != null) {
		destBack.value = orig.value;
	}
	
	OnFlightOriginListBackChanged(orig, dest, destBack, origBack);
}
function OnFlightOriginListBackChanged(orig, dest, destBack, origBack) {// Rückflug Startflughafen ändert
	if (origBack != null && destBack != null) {
		OnOriginAirportChanged(origBack, destBack);
	}
}
function OnFlightDestinationListChanged(orig, dest, destBack, origBack) {// Hinflug Zielflughafen ändert
	
	try {
		var strMinDateOD = eval("g_FlightRoutesMinDate_" + orig.value + "_" + dest.value);
	} catch (e) {}
	try {
		var strMinDateDO = eval("g_FlightRoutesMinDate_" + dest.value + "_" + orig.value);
	} catch (e) {}
	
	if(strMinDateOD != null) {
		var MinDateOD = new Date(strMinDateOD.substring(6, 10), strMinDateOD.substring(3, 5) - 1, strMinDateOD.substring(0, 2));
	}
	if(strMinDateDO != null) {
		var MinDateDO = new Date(strMinDateDO.substring(6, 10), strMinDateDO.substring(3, 5) - 1, strMinDateDO.substring(0, 2));
	}
	
	if(MinDateOD != null && MonthYearDepartureObj != null) {
		CheckFlightsMonthYear(MinDateOD, MonthYearDepartureObj);
	}
	if(MinDateDO != null && MonthYearArrivalObj != null) {
		CheckFlightsMonthYear(MinDateDO, MonthYearArrivalObj);
	}
	
	if (origBack != null) {
		origBack.value = dest.value;
	}
	
	OnFlightOriginListBackChanged(orig, dest, destBack, origBack);
	
	if (destBack != null) {
		destBack.value = orig.value;
	}
}
function DoFlightCopyDestToBack(orig, dest, destBack, origBack) {
	if (origBack != null) {
		origBack.value = dest.value;
	}
	if (destBack != null) {
		destBack.value = orig.value;
	}
}

//--> end hide JavaScript


// var g_AirportName_2 = "Wien";
// var g_RegionDestinations_0 = new Array(0,4,17,18,14,6,10,12,9,21,5,8,19,16,20,7,11,2);
function OnRegionChanged(r, d) {
	var destList;
	destList = eval("g_RegionDestinations_" + r.selectedIndex);

	var OldDestination = d.value; // remember the old destionation airport
	var OldDestPresent = false;
	d.length = 0; //Remove current options
	
	// set new options length
	d.length = destList.length; 

    //loop through the array and add all the new values ..
    var DestIX;
    for (var i = 0; i< destList.length; i++) {
		DestIX = destList[i];
		if (DestIX >= 0) {
			d[i].text = eval("g_AirportName_" + DestIX);
			d[i].value = DestIX;
			if (OldDestination == DestIX) {
				OldDestPresent = true;
			}
		}
	}
	if (OldDestPresent)
		d.value = OldDestination;
}

function ShowClassConditions(type) {
	if (type == "E") {
		var wnd = window.open("../EconomyCond.html","Economy Class Information","width=640,height=300,scrollbars=yes,menubar=no,resizable=yes,location=no");
		wnd.focus();
	}
	if (type == "S") {
		var wnd = window.open("../VivaSaverCond.html","Viva! Saver Information","width=640,height=300,scrollbars=yes,menubar=no,resizable=yes,location=no");
		wnd.focus();
	}
	if (type == "B") {
		var wnd = window.open("../VivaCond.html","Viva! Information","width=640,height=300,scrollbars=yes,menubar=no,resizable=yes,location=no");
		wnd.focus();
	}
}

function OpenTextTemplate(Category, PlaceHolder) {
	var wnd = window.open("TextTemplates.aspx?Category="+Category+"&PlaceHolder='"+PlaceHolder+"'", "Helvetic_TextTemplates_"+Category, "width=840,height=600,scrollbars=yes,menubar=no,resizable=yes,status=yes");
	wnd.focus();
}

