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 = HOME_URL + "flight/ibe?deeplink=" + escape(deepLinkParamsStr);
	return false;
}

function checkAirports(){
	var message = '';
	if ($('depCity').value == '') {
		message = 'den Abflughafen';
	}
	if ($('arrCity').value == '') {
		if (message != '') {
			message += ' und den Zieflughafen';
		}
		else {
			message = 'den Zielflughafen';
		}
	}
	if (message != '') {
		message = 'Sie m&uuml;ssen ' + message + ' eingeben um Ergebnisse zu erhalten!<br />';
	}
	if (typeof flightDepCal == 'object' && typeof flightArrCal == 'object') {
		if (flightDepCal.date.getTime() > flightArrCal.date.getTime()) {
			message += 'Das R&uuml;ckflugdatum liegt vor dem Hinflugdatum!';
		}
	}
	if (message != '') {
		$('errorMessageRow').style.display = 'block';
		$('errorMessage').innerHTML = message;
	} else {
		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( flightType ) {
	if (flightType == 'OW') {
		jQuery('#returnDate, #flightRetVal').datepicker('disable');
		jQuery('#sFlightInput\\[inbound_time\\], #sFlightInput\\[returnTimeRange\\], #flightRetVal, #sFlightInput\\[inbound_date_month\\], #sFlightInput\\[inbound_date_day\\], #returnDate').attr("disabled", true);
		jQuery('#arrCal, #flightArrCal').hide();
	}
	else {
		jQuery('#returnDate, #flightRetVal').datepicker('enable');
		jQuery('#sFlightInput\\[inbound_time\\], #sFlightInput\\[returnTimeRange\\], #flightRetVal, #sFlightInput\\[inbound_date_month\\], #sFlightInput\\[inbound_date_day\\], #returnDate').removeAttr("disabled"); 
		jQuery('#arrCal, #flightArrCal').show();
	}
}

function switchRoute( mode ) {
	flightType = jQuery('#sFlightInput\\[flightType\\]').is(':checked');
	if (flightType == true) {
		jQuery('#returnDate, #flightRetVal').datepicker('disable');
		jQuery('#sFlightInput\\[inbound_time\\], #sFlightInput\\[returnTimeRange\\], #flightRetVal, #sFlightInput\\[inbound_date_month\\], #sFlightInput\\[inbound_date_day\\], #returnDate').attr("disabled", true);
		jQuery('#arrCal, #flightArrCal').hide();
	}
	else {
		jQuery('#returnDate, #flightRetVal').datepicker('enable');
		jQuery('#sFlightInput\\[inbound_time\\], #sFlightInput\\[returnTimeRange\\], #flightRetVal, #sFlightInput\\[inbound_date_month\\], #sFlightInput\\[inbound_date_day\\], #returnDate').removeAttr("disabled"); 
		jQuery('#arrCal, #flightArrCal').show();
	}
}

String.prototype.leftPad = function (l, c) { return new Array(l - this.length + 1).join(c || '0') + this; }

function changeReturnDate() {
	if(jQuery('#departureDate').length) {
	    var sStr = jQuery('#departureDate').val().split(".");
	    var oDate = new Date(sStr[2],(parseInt(sStr[1],10) - 1),sStr[0]);
	    var sDate = oDate.getTime() + 604800000;
	    oDate.setTime(sDate);
	    jQuery('#returnDate').val((oDate.getDate()).toString().leftPad(2, '0') + '.' + (parseInt(oDate.getMonth(),10) + 1).toString().leftPad(2, '0')  + '.' + oDate.getFullYear());
	}
}

/*http://jacwright.com/projects/javascript/date_format*/
Date.prototype.format=function(a){var b='';var c=Date.replaceChars;for(var i=0;i<a.length;i++){var d=a.charAt(i);if(c[d]){b+=c[d].call(this)}else{b+=d}}return b};Date.replaceChars={shortMonths:['Jan','Feb','Mar','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'],longMonths:['Januar','Februar','M&auml;rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember'],shortDays:['So','Mo','Di','Mi','Do','Fr','Sa'],longDays:['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'],d:function(){return(this.getDate()<10?'0':'')+this.getDate()},D:function(){return Date.replaceChars.shortDays[this.getDay()]},j:function(){return this.getDate()},l:function(){return Date.replaceChars.longDays[this.getDay()]},N:function(){return this.getDay()+1},S:function(){return(this.getDate()%10==1&&this.getDate()!=11?'st':(this.getDate()%10==2&&this.getDate()!=12?'nd':(this.getDate()%10==3&&this.getDate()!=13?'rd':'th')))},w:function(){return this.getDay()},z:function(){return"Not Yet Supported"},W:function(){return"Not Yet Supported"},F:function(){return Date.replaceChars.longMonths[this.getMonth()]},m:function(){return(this.getMonth()<11?'0':'')+(this.getMonth()+1)},M:function(){return Date.replaceChars.shortMonths[this.getMonth()]},n:function(){return this.getMonth()+1},t:function(){return"Not Yet Supported"},L:function(){return"Not Yet Supported"},o:function(){return"Not Supported"},Y:function(){return this.getFullYear()},y:function(){return(''+this.getFullYear()).substr(2)},a:function(){return this.getHours()<12?'am':'pm'},A:function(){return this.getHours()<12?'AM':'PM'},B:function(){return"Not Yet Supported"},g:function(){return this.getHours()%12||12},G:function(){return this.getHours()},h:function(){return((this.getHours()%12||12)<10?'0':'')+(this.getHours()%12||12)},H:function(){return(this.getHours()<10?'0':'')+this.getHours()},i:function(){return(this.getMinutes()<10?'0':'')+this.getMinutes()},s:function(){return(this.getSeconds()<10?'0':'')+this.getSeconds()},e:function(){return"Not Yet Supported"},I:function(){return"Not Supported"},O:function(){return(this.getTimezoneOffset()<0?'-':'+')+(this.getTimezoneOffset()/60<10?'0':'')+(this.getTimezoneOffset()/60)+'00'},T:function(){return"Not Yet Supported"},Z:function(){return this.getTimezoneOffset()*60},c:function(){return"Not Yet Supported"},r:function(){return this.toString()},U:function(){return this.getTime()/1000}};
var JSON=JSON||{};(function(){function f(n){return n<10?'0'+n:n}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()}}var e=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(b){escapable.lastIndex=0;return escapable.test(b)?'"'+b.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+b+'"'}function str(a,b){var i,k,v,length,mind=gap,partial,value=b[a];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(a)}if(typeof rep==='function'){value=rep.call(b,a,value)}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null'}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null'}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v)}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(a,b,c){var i;gap='';indent='';if(typeof c==='number'){for(i=0;i<c;i+=1){indent+=' '}}else if(typeof c==='string'){indent=c}rep=b;if(b&&typeof b!=='function'&&(typeof b!=='object'||typeof b.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':a})}}if(typeof JSON.parse!=='function'){JSON.parse=function(c,d){var j;function walk(a,b){var k,v,value=a[b];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return d.call(a,b,value)}e.lastIndex=0;if(e.test(c)){c=c.replace(e,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(c.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+c+')');return typeof d==='function'?walk({'':j},''):j}throw new SyntaxError('JSON.parse');}}}());