function submitForm (formObj) {
	if (!formObj) return false;

	var deepLinkParamsArr = new Array();
	deepLinkParamsArr["action"] = "encodes_load";
	flightType = formObj["param[type]"];
	for (var i=0; i<flightType.length; i++) {
		if (flightType[i].checked == true)
			var flightTypeValue = flightType[i].value;
	}

	deepLinkParamsArr["param[type]"] = flightTypeValue;
	deepLinkParamsArr["param[acc_dep]"] = formObj["param[acc_dep]"].value;
	deepLinkParamsArr["param[acc_arr]"] = formObj["param[acc_arr]"].value;
	deepLinkParamsArr["param[city_dep]"] = formObj["param[city_dep]"].value;
	deepLinkParamsArr["param[city_arr]"] = formObj["param[city_arr]"].value;

	flightNonStop = formObj["param[nonstop]"];
	deepLinkParamsArr["param[outbound_date_str]"] = formObj["param[outbound_date_day]"][formObj["param[outbound_date_day]"].selectedIndex].value + "." + formObj["param[outbound_date_month]"][formObj["param[outbound_date_month]"].selectedIndex].value + "." + formObj["param[outbound_date_year]"][formObj["param[outbound_date_year]"].selectedIndex].value;

/*		deepLinkParamsArr["param[outbound_dep_datetime]"] = formObj["param[outbound_dep_datetime]"].value; */
	deepLinkParamsArr["param[inbound_date_str]"] = formObj["param[inbound_date_day]"][formObj["param[inbound_date_day]"].selectedIndex].value + "." + formObj["param[inbound_date_month]"][formObj["param[inbound_date_month]"].selectedIndex].value + "." + formObj["param[inbound_date_year]"][formObj["param[inbound_date_year]"].selectedIndex].value;
/*		deepLinkParamsArr["param[inbound_dep_datetime]"] = formObj["param[inbound_dep_datetime]"].value; */

	var flightNonStopValue = "FALSE";
	deepLinkParamsArr["param[nonstop]"] = flightNonStopValue;
	deepLinkParamsArr["param[cabinclass]"] = formObj["param[cabinclass]"][formObj["param[cabinclass]"].selectedIndex].value;

	deepLinkParamsArr["param[dep_arl]"] = formObj["param[dep_arl]"][formObj["param[dep_arl]"].selectedIndex].value;
	deepLinkParamsArr["param[pax_adt]"] = formObj["param[pax_adt]"][formObj["param[pax_adt]"].selectedIndex].value;
	deepLinkParamsArr["param[pax_chd]"] = formObj["param[pax_chd]"][formObj["param[pax_chd]"].selectedIndex].value;
	deepLinkParamsArr["param[pax_inf]"] = formObj["param[pax_inf]"][formObj["param[pax_inf]"].selectedIndex].value;

	var deepLinkParamsStr = "";
	for (var key in deepLinkParamsArr) {
		if ( typeof deepLinkParamsArr[key] == 'string')
			deepLinkParamsStr += key + "=" + escape(deepLinkParamsArr[key]) + "&";
	}

	//var ibeUrl = "/travel/index.php?_query=preisvergleich_suche&typ=linien&deeplink=" + escape(deepLinkParamsStr);
	var ibeUrl = "<{$HOME_URL}>flight/ibe?deeplink=" + escape(deepLinkParamsStr);
	/*self.location.href = ibeUrl;*/
	return false;
}
function checkFlightDate( mode ){
	if(mode == 'complete'){
		if( typeof(radio = $('encodesTypeRtRadio'))!='undefined'){
			if( radio.checked ){
				var inboundDate  = Date.UTC($F('sFlightInput[inbound_date_year]'),$F('sFlightInput[inbound_date_month]'),$F('sFlightInput[inbound_date_day]'));
				var outboundDate = Date.UTC($F('sFlightInput[outbound_date_year]'),$F('sFlightInput[outbound_date_month]'),$F('sFlightInput[outbound_date_day]'));
				if(outboundDate > inboundDate){
					alert('Ihr Rückreisedatum liegt vor dem Hinreisedatum');
					return false;
				}
			}
		}
	}
	if(mode == 'compact'){
		if($F('sFlightInput[flightType]') == 'RT'){
			
			var inboundDate  = $F('departureDate').split(".");
			var outboundDate = $F('returnDate').split(".");
			if(Date.UTC(inboundDate[2],inboundDate[1],inboundDate[0]) > Date.UTC(outboundDate[2],outboundDate[1],outboundDate[0])){
				alert('Ihr Rückreisedatum liegt vor dem Hinreisedatum');
				return false;
			}
		}
	}
	if(mode == 'scompact'){
		if( typeof(radio = $('encodesTypeRtRadio'))!='undefined'){
			if( radio.checked ){
				var inboundMonth  	= $F('sFlightInput[inbound_date_month]').split(".");
				var outboundMonth  	= $F('sFlightInput[outbound_date_month]').split(".");
				if(Date.UTC(inboundMonth[1],inboundMonth[0],$F('sFlightInput[inbound_date_day]')) < Date.UTC(outboundMonth[1],outboundMonth[0],$F('sFlightInput[outbound_date_day]'))){
					alert('Ihr Rückreisedatum liegt vor dem Hinreisedatum');
					return false;
				}
			}
		}
	}
	return true;
}

function checkFlightData( mode ) {
	var message = '';
	var date_message = '';
	if ($('depCity').value == '') {
		message = 'den Abflughafen';
	}
	if ($('arrCity').value == '') {
		if (message != '') {
			message += ' und den Zieflughafen';
		}
		else {
			message = 'Zieflughafen';
		}
	}
	if (message != '') {
		message = 'Sie m\xFCssen ' + message + ' eingeben um Ergebnisse zu erhalten!';
		alert(message);
			
	}else {
		if(checkFlightDate( mode ))
			document.forms.sflight.submit();
	}
}


function checkAirports(){
	var message = '';
	if ($('depCity').value == '') {
		message = 'den Abflughafen';
	}
	if ($('arrCity').value == '') {
		if (message != '') {
			message += ' und den Zieflughafen';
		}
		else {
			message = 'Zieflughafen';
		}
	}
	if (message != '') {
		message = 'Sie m\xFCssen ' + message + ' eingeben um Ergebnisse zu erhalten!';
	}
	if (message != '') {
		alert(message);
	} else {
		if(checkFlightDate( 'scompact' ))
			document.forms.sflight.submit();
	}
}

function setNumPax() {
	maxPax = 9;
	elAdt = getElement('adultSelector');
	elChd = getElement('childSelector');
	elInf = getElement('infantSelector');
	adtNum = elAdt.value;
	infNum = elInf.value;
	chdNum = elChd.value;
	if(infNum > adtNum)
		infNum = adtNum;
	if((maxPax-adtNum) < chdNum)
		chdNum = maxPax-adtNum;
	while(elInf.options.length!=0) {
		elInf.options[elInf.options.length-1] = null;
	}
	while(elChd.options.length!=0) {
		elChd.options[elChd.options.length-1] = null;
	}
	elInf.options[0] = new Option('0 Babies', '0', true, true);
	for(x=1;x<=adtNum;x++) {
		if(x==1) { val=' Baby';	}else {	val=' Babies'; }
		if(infNum == x) {
			elInf.options[x] = new Option(x+val, x, true, true);
		} else {
			elInf.options[x] = new Option(x+val, x, false, false);
		}
	}
	chdMax = maxPax - adtNum;
	elChd.options[0] = new Option('0 Kinder', '0', true, true);
	for(x=1;x<=chdMax;x++) {
		if(x==1) { val=' Kind';	}else {	val=' Kinder'; }
		if(chdNum == x) {
			elChd.options[x] = new Option(x+val, x, true, true);
		} else {
			elChd.options[x] = new Option(x+val, x, false, false);
		}
	}
}

function switchDate( mode ) {
	flightType = getElement ('sFlightInput[flightType]').value;
	if (flightType == 'OW') {
		if (mode == 'compact') {
			returnDate = getElement('returnDate');
			returnDate.disabled = true;
		} else {
			returnDateDay = getElement('sFlightInput[inbound_date_day]');
			returnDateDay.disabled = true;
			returnDateMonth = getElement('sFlightInput[inbound_date_month]');
			returnDateMonth.disabled = true;
			flightArrCal.hide();
		}
		returnDatetime = getElement ('sFlightInput[inbound_time]');
		returnDatetime.disabled = true;
		returnTimeRange = getElement ('sFlightInput[arrivalTimeRange]');
		returnTimeRange.disabled = true;
		returnDateTrigg = getElement ('arrCal');
		returnDateTrigg.style.display = 'none';
	}else {
		if (mode == 'compact') {
			returnDate = getElement('returnDate');
			returnDate.disabled = false;
		} else {
			returnDateDay = getElement('sFlightInput[inbound_date_day]');
			returnDateDay.disabled = false;
			returnDateMonth = getElement('sFlightInput[inbound_date_month]');
			returnDateMonth.disabled = false;
			flightArrCal.show();
		}
		returnDatetime = getElement ('sFlightInput[inbound_time]');
		returnDatetime.disabled = false;
		returnTimeRange = getElement ('sFlightInput[arrivalTimeRange]');
		returnTimeRange.disabled = false;
		returnDateTrigg = document.getElementById('arrCal');
		returnDateTrigg.style.display = 'inline';
	}
}

