



	function ChangeOperator(operatorId){
		var op = document.getElementById('operatorId');
		for (i = 0; i < op.length; i++){
			if(op.options[i].value=='op_'+operatorId){
				op.options[i].selected=true;
			}
		}
	}
	
	function PrintDocument(div){
		var text = document.getElementById(div).innerHTML;
		var printWindow = window.open('','printWindow','menubar=no,scrollbars=no,width=600px,height=500px');
		printWindow.document.write(text);
		
		printWindow.print();
	}
	
	
	function SendRequest(){
		var form = document.getElementById('SendRequest');
		if(form){
			if(form.operatorId.selectedIndex<=0 || form.departure.value == '' || form.arrival.value == ''){
				alert('Bitte wählen Sie einen Flughafen, sowie ein Abflug- und Ankunftdatum aus.');
				return;
			}
			var today = new Date();
			var todayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate());
			// Nur Tage miteinander vergleichen 
			
			if(GetDate(form.departure.value) < todayDate){
				alert('Sie können keine Reservierung in der Vergangenheit tätigen!');
				return;
			}
			if(GetDate(form.arrival.value) < GetDate(form.departure.value)){
				alert('Das Ankunftdatum liegt vor dem Abflugdatum!');
				return;
			}
			
			form.submit();
		}
	}
	
	function GetDate(dt){
		var dateTimeArray = dt.split(' ');
		var ary = dateTimeArray[0].split('.');
		if(ary.length==3){
			dt = new Date(ary[2], ary[1]-1, ary[0]);
			return dt;
		}
		return null;
	}
	
	
	function ShowResultBox(id){
		$('div[id^="result"]').hide();
		$('#result'+id).show();		
	}
	
	function ShowButton(id,inp){
		$('#choosenParkingType').html($(inp).closest('tr').children().first().html());
		$('#choosenParkingTypePrice').html($(inp).next().html());
		
		$('#PaymentInformation').hide();
		if(id=="pay") {$('#PaymentInformation').show();}
		$('#book').hide();
		$('#pay').hide();
		$('#'+id).show();		
	}
	
	function SetMaxPaxCount(count){
		$('#pax_count_max').val(count);
		$('#MaxCountInfo').html('');
		if(count>0){
			$('#MaxCountInfo').html('(maximale Anzahl: '+count+')');
		}
	}
	
	function CheckStep(step){		
		switch(step){
			case '1':
				if($('#parkingtypetable :radio').is(':checked')) {
					return true;
				}
				
				alert('Bitte wählen Sie ein Parkplatztyp aus.');
				return false;			
				break;
			case '2':
				if($('#parkingarrival_hour')[0].selectedIndex<=0 || $('#parkingarrival_min')[0].selectedIndex<=0 || $('#pax_count').val()=="" ||
						$('#arrival_flight_nr').val()=="" || $('#arrival_to').val()=="" || $('#return_flight_nr').val()=="" || $('#return_from').val()=="") {
					alert('Bitte füllen Sie alle Felder aus, die mit einem * gekennzeichnet sind.');
					return false;
				}
				
				if(isNaN($('#pax_count').val())){
					alert('Die Angabe zu der Anzahl von Personen muss eine Zahl sein.');
					return false;
				}
				
				if(parseInt($('#pax_count_max').val()) != 0 && parseInt($('#pax_count').val()) > parseInt($('#pax_count_max').val())){
					alert('Die maximale Anzahl von Personen ist überschritten.');
					return false;
				}
				
				if($('#reference').val() != "" && $('#reference').val().length != 8){
					alert('Bitte füllen Sie das Feld für den Provisionspartner mit einem Code aus, der das richtige Format ("RF123ABC") aufweist.');
					return false;
				}
				break;
			case '3':		
				if($('#salutation')[0].selectedIndex<=0 || $('#firstname').val()=="" || $('#lastname').val()=="" || $('#telephone').val()=="" || $('#email').val()=="") {
					alert('Bitte füllen Sie alle Felder aus, die mit einem * gekennzeichnet sind.');
					return false;
				}
				if(!document.getElementById('widerruf').checked){	
					alert('Bitte nehmen Sie vor der Buchung das Widerrufsrecht zur Kenntnis.');
					return false;
				}
				if(!document.getElementById('agb').checked){	
					alert('Bitte lesen Sie vor der Buchung die allgemeinen Geschäftsbedingungen des Anbieters durch.');
					return false;
				}
				//Validierung
				$.post("validation.php", $("#booking").serialize(), function(data) {	
					if(data=='OK\n'){
						$("#booking").submit();
					}else{							
						$('#ValidationResult').html(data);
					}
				});
				return false;
				
				break;
		}
		return true;
	}
		















