// mit setBIS zum setzten des Rueckdatum

function selectVON($von) {
	document.write("<select name='VON' onChange='setBIS()'>")
	if($von < 1 | $von > 330 | $von == '' ){ $von = 2; }

	for (var i=1; i<=330;i++){
		if (i==$von) document.write('<option selected ');  else document.write('<option ');
		document.write('value='+i+'>'+GetDatum(i)+'</option>')
	}
	document.write("</select>")
}

function setBIS(){
	with (document.GO){
		VonOffset = VON.selectedIndex
		Bis = Math.max(Math.min( BIS.selectedIndex + VonOffset-Von ,BIS.length-1),0);
		BIS.selectedIndex = Bis;
		Von=VonOffset
	}	
}


function selectBIS($bis){
	document.write("<select name='BIS'>")
	if($bis < 1 | $bis > 340 | $bis == '' ){ $bis = 36; }

	for (var i=4; i<=340;i++){
		if (i==$bis) document.write('<option selected ');  else document.write('<option ');
		document.write('value='+i+'>'+GetDatum(i)+'</option>')
	}
	document.write('</select>')
}

function selectRA($given){
	document.write("<select name='RA'>")
	if($given < 1 | $given > 4 | $given == '' ){ $given = 2; }
	for (var i=1; i<=4;i++){
		if (i==$given) document.write('<option selected ');  else document.write('<option ');
		if(i==1){ document.write('value="1">1 Erwachsener</option>')
		}else{
			document.write('value='+i+'>'+i+' Erwachsene</option>')
		}
	}
	document.write('</select>')
}

function selectRAflug($given){
	document.write("<select name='RA'>")
	if($given < 4 | $given > 8 | $given == '' ){ $given = 6; }
	for (var i=5; i<=8;i++){
		if (i==$given) document.write('<option selected ');  else document.write('<option ');
		if(i==5){ document.write('value="5">1 Erwachsener</option>')
		}else{
			pers = i - 4;
			document.write('value='+i+'>'+pers+' Erwachsene</option>')
		}
	}
	document.write('</select>')
}

function selectRW($abflug, $abflughafen){
	document.write("<select name='RW'>")
	for (var i in $abflughafen) {
		if(i == $abflug) document.write('<option selected ');  else document.write('<option ');
		document.write(' value='+i+'>'+$abflughafen[i]+'</option>');
	}
	document.write('</select>')
}

function selectZIEL($ziel, $zielarray){
	document.write("<select name='ZIEL'>")
	for (var i in $zielarray) {
		if(i == $ziel) document.write('<option selected ');  else document.write('<option ');
		document.write(' value='+i+'>'+$zielarray[i]+'</option>');
	}
	document.write('</select>')
}

function selectDAUER($lminlmax){
	var minmax = new Array();
	minmax["7-7"]	= "7";
	minmax["14-14"]	= "14";
	minmax["21-21"]	= "21";
	minmax["3-8"]	= "3 bis 8";
	minmax["8-15"]	= "8 bis 15";
	minmax["16-21"]	= "16 bis 21";
	minmax["21-"]	= "mehr als 21";
	document.write("<select name='DAUER'>")
	for (var i in minmax){
		if(i == $lminlmax) document.write('<option selected ');  else document.write('<option ');
		document.write(' value='+i+'>'+minmax[i]+'</option>');
	}
	document.write('</select>')
}

function selectKA($kind, $age){
	document.write("<select name='"+$kind+"'>")

	if ('-'==$age | ''==$age | '0'==$age | $age>14){ document.write('<option selected ');}else{document.write('<option ')};
	document.write("value=\"-\">-</option>")
	if ('1'==$age){ document.write('<option selected ');}else{document.write('<option ')};
	document.write("value=\"1\">&lt; 2</option>")

	for (var j=2; j<=14;j++){
		if (j==$age) document.write('<option selected ');  else document.write('<option ');
		document.write('value='+j+'> '+j+'</option>')
	}
	document.write('</select>')
}

function GetDatum(offset){
	Days = new Array("SO","Mo","Di","Mi","Do","Fr","SA","??" )
	var time = new Date()
	time.setTime( time.getTime()+offset*86400000)
	tag = time.getDate()
	if (tag < 10){ tag = '&nbsp;&nbsp;'+tag }

	monat = (1+time.getMonth())
	if (monat < 10){ monat = '0'+monat }
	return tag+'.'+monat+'.'+(2000+(time.getYear()%100))+' '+Days[time.getDay()]
}
