rightnow = new Date();
//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+" ";
	(i<rightnow.getMonth()) ? a +=(nextyear) : a +=(thisyear);
	a += "</option>\n";
	this.option = a;
}														
var months = new Array(new month(0,"Januar"), new month(1,"Februar"),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"));
var mDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31)	
	function calcDay(frm,nm,nm2){
 dateVal = document.forms[frm].elements[nm].options[document.forms[frm].elements[nm].selectedIndex].value;
 monthVal = document.forms[frm].elements[nm2].options[document.forms[frm].elements[nm2].selectedIndex].value;
 var isLeapYear = (((monthVal.substr(0,4) % 4 == 0) && (monthVal.substr(0,4) % 100 != 0)) || (monthVal.substr(0,4) % 400 == 0));
 mDays[1] = (isLeapYear)?29:28;
 if(dateVal > mDays[monthVal.substr(4,2)-1]){
  setDDValue(document.forms[frm].elements[nm],mDays[monthVal.substr(4,2)-1]);
  dateVal = document.forms[frm].elements[nm].options[document.forms[frm].elements[nm].selectedIndex].value;
  }
 }
function setDDValue(oDropDown, sValue){
 for(var iIndex=0; iIndex<oDropDown.options.length; ++iIndex){
  if(oDropDown.options[iIndex].value == sValue){
   oDropDown.selectedIndex = iIndex;
   break;
   }
  }
 }

function frmCheckSubmit(){
	var f1 = document.frmCheck
	var f2 = document.frm
	monthYear = f1.outboundDateMonthYear_Control.options[f1.outboundDateMonthYear_Control.selectedIndex].value;
	dayVal = f1.outboundDateDate_Control.options[f1.outboundDateDate_Control.selectedIndex].value;
	monthVal= monthYear.substr(4,2);
	yearVal = monthYear.substring(0,4);
				
	secMonthYear = f1.returnDateMonthYear_Control.options[f1.returnDateMonthYear_Control.selectedIndex].value;
	secDayVal = f1.returnDateDate_Control.options[f1.returnDateDate_Control.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 DCity = f1.from.value;
	var ACity = f1.destination.value;
	
			if (DCity==0) {
				alert("Bitte geben Sie einen gültigen Abflugsort an");
				f1.from.focus();
				return false;
			}
			if (ACity==0) {
				alert("Bitte geben Sie einen gültigen Ankunftsort an");
				f1.destination.focus();
				return false;
			}
	
	
			if (!((rightnow.valueOf() < date.valueOf()) && (date.valueOf() < secdate.valueOf()))) {
				alert("Please enter valid return and departure dates");
				return false;			
			} else {
			f2.originInput.value =f1.from.value;
			f2.destination.value =f1.destination.value;
				f2.returnDateMonthYear.value = f1.returnDateMonthYear_Control.value;
				f2.outboundDateDate.value = f1.outboundDateDate_Control.value;
				f2.outboundDateMonthYear.value = f1.outboundDateMonthYear_Control.value;
				f2.returnDateDate.value = f1.returnDateDate_Control.value;
				f2.adult1.value =f1.adult1.value;
				f2.child1.value =f1.child1.value;
				f2.infant1.value =f1.infant1.value;
				f2.adult2.value =f1.adult2.value;
				f2.child2.value =f1.child2.value;
				f2.infant2.value =f1.infant2.value;
				f2.adult3.value =f1.adult3.value;
				f2.child3.value =f1.child3.value;
				f2.infant3.value =f1.infant3.value;
				f2.adult4.value =f1.adult4.value;
				f2.child4.value =f1.child4.value;
				f2.infant4.value =f1.infant4.value;
				f2.rooms.value =f1.rooms.value;
				
				f2.outboundTimeband.value = f1.outboundTimeband.value;
				f2.returnTimeband.value = f1.returnTimeband.value;
				f2.submit();
				return false;
	
			}
 }
	
function init() {
		var f1 = document.frmCheck
		tomorrow = new Date(rightnow.getTime()+(604800000));
		for(d=0;d<31;d++) f1.outboundDateDate_Control[d] = new Option(d+1,((d<10)?"0"+(d+1):d+1));
		for(d=0;d<31;d++) f1.returnDateDate_Control[d] = new Option(d+1,((d<10)?"0"+(d+1):d+1));
		f1.outboundDateDate_Control.selectedIndex = tomorrow.getDate()-1;
		f1.outboundDateMonthYear_Control.selectedIndex = tomorrow.getMonth();	
		then = new Date(tomorrow.getTime()+(604800000));
		f1.returnDateDate_Control.selectedIndex = then.getDate()-1;
		f1.returnDateMonthYear_Control.selectedIndex = then.getMonth();
}

function generateInfantRoomAllocation(){
	var searchForm = document.forms['frmCheck'];
	if (searchForm == null){
		searchForm = document.forms['frmCheck'];
	}
	var inputName = 'roomAllocations[0].adultQuantity';
	var infantRoomAllocation = 'roomAllocations[0].infantQuantity';
	var totalTravellers=parseInt(searchForm[inputName].value);
	generateOption(searchForm[infantRoomAllocation], parseInt(searchForm[inputName].value));
}
function generateOption(elem, num){
	var prevSelectedVal = elem.value;

	elem.length = 0;
	for (var i=0; i<=num; i++){
		var option = document.createElement('option');
		option.value = i;
		option.innerHTML = i;
		if (i==prevSelectedVal){
			option.selected = "true";
		}
		elem.appendChild(option);
		if (prevSelectedVal < elem.length){
			elem.selectedIndex = prevSelectedVal;
		} else {
			elem.selectedIndex = elem.length - 1;
		}
	}
}
function moreRooms(selectObj,objForm) {
var d=document;
	var searchResultsFrm = objForm;
	if (searchResultsFrm == null) { 
		searchResultsFrm = d.forms['frmCheck'];
	}
	if (searchResultsFrm == null) { 
		searchResultsFrm = d.forms['frmCheck'];
	}
	
	var rooms = searchResultsFrm.elements["rooms"].value;
	var room1 = d.getElementById("room1");
	var room2 = d.getElementById("room2");
	var room3 = d.getElementById("room3");
	var room4 = d.getElementById("room4");

	if (d.getElementById("rooms")) {

		//we first 'switch the rooms off' and then cascade down, switching the rooms back on
		room4.style.display='';
		room3.style.display='';
		room2.style.display='';
//		room1.style.display='';


		switch(rooms)
		{
		case '1':
			room2.style.display='none';
			//d.getElementById("adult2").selectedIndex=0;
			d.getElementById("child2").selectedIndex=0;
			d.getElementById("infant2").selectedIndex=0;

		case '2':
			room3.style.display='none';
			//d.getElementById("adult3").selectedIndex=0;
			d.getElementById("child3").selectedIndex=0;
			d.getElementById("infant3").selectedIndex=0;

		case '3':
			room4.style.display='none';
			//d.getElementById("adult4").selectedIndex=0;
			d.getElementById("child4").selectedIndex=0;
			d.getElementById("infant4").selectedIndex=0;

		case '4':


		break;
		default:
			room4.style.display='';
			room3.style.display='';
			room2.style.display='';
			room1.style.display='';
			break;
		}
	}
}

function copyDestinationName() {
    var destinationList = document.getElementById('destination');
    var destElement = document.getElementById('destinationInput');
    var toCopy = destinationList.options[destinationList.selectedIndex];
    destElement.value = toCopy.innerHTML;
}
<!--//
function newWin() {
	var win = "https://opodode.custhelp.com/cgi-bin/opodode.cfg/php/enduser/std_alp.php"
	window.open(win, 'newWin', 'width=740; height=550; scrollbars=yes');
}
//-->

