// JavaScript Document
function toggleDisplay(tg) {
	switch(tg) {
	case 'flights':
		document.getElementById('OpodoQuickFlightSearch').style.display = 'block';
		document.getElementById('OpodoQuickHotelSearch').style.display = 'none';
		document.getElementById('OpodoQuickPackageSearch').style.display = 'none';
		break
	case 'hotel':
		document.getElementById('OpodoQuickFlightSearch').style.display = 'none';
		document.getElementById('OpodoQuickHotelSearch').style.display = 'block';
		document.getElementById('OpodoQuickPackageSearch').style.display = 'none';
		break
	case 'package':
		document.getElementById('OpodoQuickFlightSearch').style.display = 'none';
		document.getElementById('OpodoQuickHotelSearch').style.display = 'none';
		document.getElementById('OpodoQuickPackageSearch').style.display = 'block';
		break
	}
}


// ###########################################################################################################################
// HOTELSUCHE  ###############################################################################################################
// ###########################################################################################################################

//write dates to dropdown
function month(i,name) {
	var thisyear = rightnow.getFullYear();
	var nextyear = thisyear + 1;
	var a = "<option value=\"";
	(i<rightnow.getMonth()) ? a +=nextyear : a +=thisyear;
	(i<9) ? a += "0"+(i+1) : a+=(i+1);
	a += "\">"+name+" 0";
	(i<rightnow.getMonth()) ? a +=(nextyear-2000) : a +=(thisyear-2000);
	a += "</option>\n";
	this.option = a;
	
}

function hotelSubmit() {
	var f1 = document.hotel;
	var f2 = document.hotelOutput;
	monthYear = f1.checkInDateB.options[f1.checkInDateB.selectedIndex].value;
	dayVal = f1.checkInDateA.options[f1.checkInDateA.selectedIndex].value;
	monthVal= monthYear.substr(4,2);
	yearVal = monthYear.substring(0,4);
	
	numAdlts = f1.numOfAdults.options[f1.numOfAdults.selectedIndex].value;
	numRo = f1.numberOfRooms.options[f1.numberOfRooms.selectedIndex].value;
				
	secMonthYear = f1.depDateB.options[f1.depDateB.selectedIndex].value;
	secDayVal = f1.depDateA.options[f1.depDateA.selectedIndex].value;
	secMonthVal = secMonthYear.substr(4,2);
	secYearVal = secMonthYear.substring(0,4);
	
	var date = new Date(yearVal, monthVal-1, dayVal);
	var secdate = new Date(secYearVal, secMonthVal-1, secDayVal);
	var theDate = date.getDate();
	var theSecDate = secdate.getDate();
	var aCity = f2.destinationName.value;
	
	if (aCity==0) {
		alert("Bitte geben Sie den Zielort ein.");		
		document.hotelOutput.destinationName.focus()
		return false;
	}
	if (!((rightnow.valueOf() < (date.valueOf()+(86400000))) && (date.valueOf() <= secdate.valueOf()))) {
		alert("Bitte geben Sie ein gültiges Datum ein");
		return false;
	} else {
		f2.checkInDate.value = monthYear + dayVal;
		f2.checkOutDate.value = secMonthYear + secDayVal;
		f2.numOfAdults.value = numAdlts;
		f2.numberOfRooms.value = numRo;
		f2.submit();
		return false;
	}
}
	
function init_hotel() {
	var f1 = document.hotel;
	tomorrow = new Date(rightnow.getTime());
	for(d=0;d<31;d++) f1.checkInDateA[d] = new Option(d+1,((d<10)?"0"+(d+1):d+1));
	for(d=0;d<31;d++) f1.depDateA[d] = new Option(d+1,((d<10)?"0"+(d+1):d+1));
	f1.checkInDateA.selectedIndex = tomorrow.getDate()-1;
	f1.checkInDateB.selectedIndex = tomorrow.getMonth()-rightnow.getMonth();	
	then = new Date(tomorrow.getTime()+(86400000));
	f1.depDateA.selectedIndex = then.getDate()-1;
	f1.depDateB.selectedIndex = then.getMonth()-rightnow.getMonth();
}

// ###########################################################################################################################
// MIETWAGENSUCHE ############################################################################################################
// ###########################################################################################################################
rightnow = new Date();

function month_m(i,name) {
	var thisyear = rightnow.getFullYear();
	var nextyear = thisyear + 1;
	var a =	"";
    (i<rightnow.getMonth()) ? a+=nextyear : a+=thisyear;
	(i<9) ? a += "0"+(i+1) : a +=(i+1);
	var b = name+ " 0";
	(i<rightnow.getMonth()) ? b+=(nextyear-2000) : b+=(thisyear-2000);
	this.name = b;
	this.value = a;
}

rightnow = new Date();
var months_2 = new Array(new month_m(0,"Januar"), new month_m(1,"Februar"),new month_m(2,"März"),new month_m(3,"April"),new month_m(4,"Mai"), new month_m(5,"Juni"), new month_m(6,"Juli"), new month_m(7,"August"), new month_m(8,"September"), new month_m(9,"Oktober"), new month_m(10,"November"), new month_m(11,"Dezember"));
function init_mietwagen(){
	for(i=0;i<12;i++) {
		wrappedIndex = (rightnow.getMonth() + i) % 12;
		document.carSearchFormBean.pickMonth[i] = new Option (months_2[wrappedIndex].name,months_2[wrappedIndex].value);
		document.carSearchFormBean.dropMonth[i] = new Option (months_2[wrappedIndex].name,months_2[wrappedIndex].value);
	}

    for(d=0;d<31;d++) {
    	document.carSearchFormBean.dropDate[d] = new Option(d+1,((d<10)?"0"+(d+1):d+1));
    	document.carSearchFormBean.pickDate[d] = new Option(d+1,((d<10)?"0"+(d+1):d+1));
    }
	if(document.carSearchFormBean.pickUpDateForm.value=="") {
		sevendays = new Date(rightnow.getTime()+(604800000));
		document.carSearchFormBean.pickDate.selectedIndex = sevendays.getDate()-1;
		then = new Date(sevendays.getTime()+(604800000))
		document.carSearchFormBean.dropDate.selectedIndex = then.getDate()-1;
		var datum = monthLengths[sevendays.getMonth()] -7
		if(rightnow.getDate() > datum ) { document.carSearchFormBean.pickMonth.selectedIndex = document.carSearchFormBean.pickMonth.selectedIndex+1; }
		if(sevendays.getDate() > datum || rightnow.getMonth() < sevendays.getMonth()) { document.carSearchFormBean.dropMonth.selectedIndex = document.carSearchFormBean.dropMonth.selectedIndex+1; }
	} else {
		var pickup	= document.carSearchFormBean.pickUpDateForm.value;
		var drop	= document.carSearchFormBean.dropOffDateForm.value;
		var pmonth	= parseInt(pickup.slice(4,6),10);
		var pday	= parseInt(pickup.slice(6,8),10);
		var ptime	= parseInt(pickup.slice(8,10),10);
		document.carSearchFormBean.pickMonth.selectedIndex	= pmonth-1;
		document.carSearchFormBean.pickDate.selectedIndex	= pday-1;
		document.carSearchFormBean.pickHour.selectedIndex	= ptime;
		var dmonth	= parseInt(drop.slice(4,6),10);
		var dday	= parseInt(drop.slice(6,8),10);
		var dtime	= parseInt(drop.slice(8,10),10);
		document.carSearchFormBean.dropMonth.selectedIndex	= dmonth-1;
		document.carSearchFormBean.dropDate.selectedIndex	= dday-1;
		document.carSearchFormBean.dropHour.selectedIndex	= dtime;
	}

	//changeDate(document.carSearchFormBean.pickMonth, document.carSearchFormBean.pickDate);
	//changeDate(document.carSearchFormBean.dropMonth, document.carSearchFormBean.dropDate);
}
function setPickLoc() {
	document.carSearchFormBean.destination1.value = document.carSearchFormBean.searchString.value;
}
function setDropLoc() {
	document.carSearchFormBean.destination2.value = document.carSearchFormBean.searchStringDrop.value;
}
function submitCheck() {
    if (document.carSearchFormBean.age.selectedIndex!=0) {
    	var day 		= parseInt(document.carSearchFormBean.pickDate.options[document.carSearchFormBean.pickDate.selectedIndex].value,10);
    	var monthVal 	= new String(document.carSearchFormBean.pickMonth.options[document.carSearchFormBean.pickMonth.selectedIndex].value);
    	var month 		= parseInt(monthVal.slice(4),10);
    	var year 		= parseInt(monthVal.slice(0,4),10);
    	var pickupDate 	= new Date(year,month-1,day,12,0,0,0);
    	day 			= parseInt(document.carSearchFormBean.dropDate.options[document.carSearchFormBean.dropDate.selectedIndex].value,10);
    	monthVal 		= new String(document.carSearchFormBean.dropMonth.options[document.carSearchFormBean.dropMonth.selectedIndex].value);
    	month 			= parseInt(monthVal.slice(4),10);
    	year 			= parseInt(monthVal.slice(0,4),10);

		var dropoffDate = new Date(year,month-1,day,12,0,0,0);
    	if (pickupDate>dropoffDate || pickupDate<rightnow) {
			if (pickupDate>dropoffDate) {
    			alert("Bitte geben Sie ein gültiges Rückgabedatum an");
				document.getElementById("returnDate").style.color="#FF3300";
    		}
			if (pickupDate<rightnow) {
	    		alert("Bitte Ihr Übernahmedatum prüfen");
	    		document.getElementById("outboundDate").style.color="#FF3300";
	    	}
    		return false;
		} else {
			document.carSearchFormBean.pickUpDateForm.value=""+pickupDate.getFullYear()+
			(((pickupDate.getMonth()+1)<10)?"0"+(pickupDate.getMonth()+1):(pickupDate.getMonth()+1))+
				((pickupDate.getDate()<10)?"0"+pickupDate.getDate():pickupDate.getDate())+
				((pickupDate.getHours()<10)?"0"+pickupDate.getHours():pickupDate.getHours())
				+((pickupDate.getMinutes()<10)?"0"+pickupDate.getMinutes():pickupDate.getMinutes());
			document.carSearchFormBean.dropOffDateForm.value=""+dropoffDate.getFullYear()+
			(((dropoffDate.getMonth()+1)<10)?"0"+(dropoffDate.getMonth()+1):(dropoffDate.getMonth()+1))+
				((dropoffDate.getDate()<10)?"0"+dropoffDate.getDate():dropoffDate.getDate())+
				((dropoffDate.getHours()<10)?"0"+dropoffDate.getHours():dropoffDate.getHours())+
				((dropoffDate.getMinutes()<10)?"0"+dropoffDate.getMinutes():dropoffDate.getMinutes());

			if (document.carSearchFormBean.destination2.value=="") {
				document.carSearchFormBean.destination2.value = document.carSearchFormBean.destination1.value;
			}
			document.carSearchFormBean.destination1.value=escape(document.carSearchFormBean.destination1.value);
			document.carSearchFormBean.destination2.value=escape(document.carSearchFormBean.destination2.value);
			return true;
        }
    }
}

var monthLengths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

function isLeapYear(year) {
	return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}
/*
function changeDate(objMonth, objDate) {
	maxDays = monthLengths[(rightnow.getMonth() + objMonth.selectedIndex) % 12];
	if ( (objMonth.selectedIndex == 1) && (isLeapYear(objMonth.value.substring(0, 4))) ) maxDays="29";

	var oldSelect = objDate.selectedIndex;
	if (oldSelect > maxDays-1) oldSelect = maxDays-1;

	objDate.length = 0;
	for (d=0;d<maxDays;d++) objDate[d] = new Option(d+1,((d<10)?"0"+(d+1):d+1));

	objDate.selectedIndex = oldSelect;
}
*/

function validateAge() {
	var valid = (document.carSearchFormBean.age.selectedIndex != 0);
	if (valid == false) {
		alert("Bitte geben Sie das Alter des Fahrers an.");
		document.carSearchFormBean.age.focus()
	}
	return valid;
}

function validatePickup() {
	var valid = (document.carSearchFormBean.destination1.value != "");
	if (valid == false) {
		alert("Bitte geben Sie eine Anmietstation ein.");
		document.carSearchFormBean.searchString.focus()
		//document.getElementById("searchString").style.color="#FF3300";
	}
	return valid;
}

function validateForm() {
	/*document.getElementById("age").style.color="#000000";
	document.getElementById("driverAge").style.color="#000000";
	document.getElementById("pickupDest").style.color="#000000";
	document.getElementById("returnDate").style.color="#000000";
    document.getElementById("outboundDate").style.color="#000000";*/
	return ( validateAge() ) && ( validatePickup() ) && ( submitCheck() );
}

// ###########################################################################################################################
// URLAUBSREISE  #############################################################################################################
// ###########################################################################################################################

var monthDays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
rightnow = new Date();
function month(i,name) {
	var thisyear = rightnow.getFullYear();
	var nextyear = thisyear + 1;
	var a = "<option value=\"";
	(i<rightnow.getMonth()) ? a +=nextyear : a +=thisyear;
	(i<9) ? a += "0"+(i+1) : a +=(i+1);
	a += "\">"+name+" 0";
	(i<rightnow.getMonth()) ? a +=(nextyear-2000) : a +=(thisyear-2000);
	a += "</option>\n";
	this.option = a;
}
															
var months = new Array(new month(0,"Januar"), new month(1,"Febuar"),new month(2,"März"),new month(3,"April"),new month(4,"Mai"), new month(5,"Juni"), new month(6,"Juli"), new month(7,"August"), new month(8,"September"), new month(9,"Oktober"), new month(10,"November"), new month(11,"Dezember"));

function last_searchSubmit() {
	d = document.last_search2;
	d2 = document.last_search;
	
	var monthVal,dayVal,yearVal;
	var secMonthVal,secDayVal,secYearVal;
	monthYear	= d.D_Month.options[d.D_Month.selectedIndex].value;
	monthVal	= monthYear.substr(4,2);
	yearVal 	= monthYear.substring(0,4);
	dayVal 		= d.D_Day.options[d.D_Day.selectedIndex].value;
	secMonthYear= d.R_Month.options[d.R_Month.selectedIndex].value;
	secMonthVal	= secMonthYear.substr(4,2);
	secYearVal 	= secMonthYear.substring(0,4);
	secDayVal 	= d.R_Day.options[d.R_Day.selectedIndex].value;
	abf 		= d.abf.options[d.abf.selectedIndex].value;
	flu 		= d.flu.options[d.flu.selectedIndex].value;
	var date 	= new Date(yearVal, monthVal-1, dayVal);
	var secdate = new Date(secYearVal, secMonthVal-1, secDayVal);
	var theDate = date.getDate();
	var theSecDate = secdate.getDate();

	if ((rightnow > date)&&(rightnow > secdate)) {
		alert("Bitte geben Sie ein g&uuml;ltiges Abflug/Rückflug Datum ein");
		return false;
	}
	if (!((rightnow.valueOf() < date.valueOf()) && (date.valueOf() < secdate.valueOf()))) { 
		alert("Bitte geben Sie ein g&uuml;ltiges Abflug/Rückflug Datum ein");
		return false;
	} else {
		d2.termin.value = dayVal +'.'+ monthVal +'.' + yearVal;
		d2.ruecktermin.value = secDayVal +'.'+ secMonthVal +'.' + secYearVal;
		d2.abflughafen.value = abf;
		d2.flugdauer.value = flu;
		return true;
		d.submit();
	}
}
	
function init() {
	tomorrow = new Date(rightnow.getTime()+(86400000));
	document.last_search2.D_Day.selectedIndex = tomorrow.getDate()-1;
	document.last_search2.D_Month.selectedIndex = tomorrow.getMonth();
	
	then = new Date(tomorrow.getTime()+(3542400000))
	document.last_search2.R_Day.selectedIndex = then.getDate()-1;
	document.last_search2.R_Month.selectedIndex = then.getMonth();
}


<!--
var dest_abflug = new Array(["-1","beliebig"],["1000","Nord"],["1001","Süd"],["1002","West"],["1003","Ost"],["0","Altenburg-Nob."],["1","Amsterdam (NL)"],["2","Augsburg"],["3","Basel-Mulhouse (CH)"],["4","Berlin-Schönef."],["5","Berlin-Tegel"],["6","Berlin-Tempelh."],["7","Bern-Belp (CH)"],["8","Bremen"],["9","Brüssel (B)"],["10","Dortmund"],["11","Dresden"],["12","Düsseldorf"],["13","Enschede (NL)"],["14","Erfurt"],["15","Frankfurt"],["16","Frankfurt-Hahn"],["17","Friedrichshafen"],["18","Genf (CH)"],["19","Graz (A)"],["20","Hamburg"],["21","Hannover"],["22","Hof-Plauen"],["23","Innsbruck (A)"],["24","Karlsruhe"],["25","Kassel"],["26","Kiel"],["27","Klagenfurt (A)"],["28","Köln-Bonn"],["29","Leipzig-Halle"],["30","Linz (A)"],["31","Lübeck"],["32","Lüttich (B)"],["33","Luxemburg"],["34","Maastricht (NL)"],["35","Mönchengladb."],["36","München"],["37","Münster-Osnab."],	["38","Nürnberg"],["39","Paderborn"],["40","Rostock"],["41","Saarbrücken"],["42","Salzburg (A)"],["43","Schwerin"],["44","Strasbourg (F)"],["45","Stuttgart"],["46","Wien (A)"],["47","Zürich (CH)"],["48","Zweibrücken"]);

var dest_ziel = new Array(["-1","beliebig"],["0","Nahstrecke"],["1","Mittelstrecke"],["2","Fernstrecke"],["3","Mittelmeer (Ges.)"],["4","Spanien-Portugal"],["5","Griechenland"],["5","T&uuml;rkei-Zypern"],["6","Kanarische Inseln"],["7","Mallorca-Menorca"],["7","Ibiza"],["8","Karibik-Mexico"],["8","Dominikanische Rep."],["9","&Auml;gypten-Israel-VAE"],["10","Asien-Thailand"],["10","Malediven"],["11","Afrika-Mauritius"],["11","Seychellen"],["12","Tunesien-Marokko"],["13","Kroatien-Bulgarien"],["14","Bes. Tauchregionen"]);

var child1 = new Array(["-1","---"],["1","<2 Jahre"],["2","2 Jahre"],["3","3 Jahre"],["4","4 Jahre"],["5","5 Jahre"],["6","6 Jahre"],["7","7 Jahre"],["8","8 Jahre"],["9","9 Jahre"],["10","10 Jahre"],["11","11 Jahre"],["12","12 Jahre"],["13","13 Jahre"],["14","14 Jahre"],["15","15 Jahre"],["16","16 Jahre"]);
//-->

