var ns = (navigator.appName == "Netscape") && (navigator.appVersion < "5");
var ns6= (navigator.appName == "Netscape") && (navigator.appVersion > "5");
var ie = (navigator.appName == "Microsoft Internet Explorer");
var fenster=null;

function init_datum()
{	
	htag = parseInt (parseFloat(document.flug.hdat1.value));
	hmonat = parseInt (parseFloat(document.flug.hdat2.value));
	hjahr = parseInt (parseFloat(document.flug.hdat3.value));
	rtag = parseInt (parseFloat(document.flug.rdat1.value));
	rmonat = parseInt (parseFloat(document.flug.rdat2.value));
	rjahr = parseInt (parseFloat(document.flug.rdat3.value));

	document.flug.mindatum.value = hjahr*10000 + hmonat*100 + htag;
	document.flug.maxdatum.value = (hjahr+1)*10000 + hmonat*100 + 1;
	
	s = new String(htag);
	if(s.length == 1) htag = '0' + htag;
	s = new String(hmonat);
	if(s.length == 1) hmonat = '0' + hmonat;
	strToday = htag +'.' + hmonat + '.' + hjahr;
	
	document.flug.startdatum.value = strToday;
	document.flug.mindatumt.value = strToday;
	document.flug.maxdatumt.value = '01.' + hmonat + '.' + (hjahr+1);
	document.flug.endedatum.value = document.flug.maxdatumt.value;
	
	document.lm.mindatum.value	= document.flug.mindatum.value;
	document.lm.maxdatum.value	= document.flug.maxdatum.value;
	document.lm.mindatumt.value = document.flug.mindatumt.value;
	document.lm.maxdatumt.value = document.flug.maxdatumt.value;
	document.lm.startdatum.value = document.flug.startdatum.value;	
	document.lm.endedatum.value = document.flug.endedatum.value;	
}
function lm_valid (theForm)
{
	if (theForm.aeriac.value == 0)
	{
//			alert("\nBitte wählen Sie eine Region !");
//			theForm.aeriac.focus();
//			return (false);
	}

	htag = parseInt (parseFloat(theForm.hdat1.value));
	hmonat = parseInt (parseFloat(theForm.hdat2.value));
	hjahr = parseInt (parseFloat(theForm.hdat3.value));
	rtag = parseInt (parseFloat(theForm.rdat1.value));
	rmonat = parseInt (parseFloat(theForm.rdat2.value));
	rjahr = parseInt (parseFloat(theForm.rdat3.value));

	if (! teste_datum (htag,hmonat,hjahr))
	{
		alert ("Dieses Datum gibt es nicht!");
		theForm.hdat1.focus();
		return (false);
	}
	if (! teste_datum (rtag,rmonat,rjahr))
	{
		alert ("Dieses Datum gibt es nicht!");
		theForm.rdat1.focus();
		return (false);
	}

	if (hjahr*10000+hmonat*100+htag < theForm.mindatum.value)
	{
		alert ("Sie können nicht früher als der "+theForm.mindatumt.value+" abreisen!");
		theForm.hdat1.focus();
		return (false);
	}
	if (hjahr*10000+hmonat*100+htag > theForm.maxdatum.value)
	{
		alert ("Sie können nicht später als der "+theForm.maxdatumt.value+" abreisen!");
		theForm.hdat1.focus();
		return (false);
	}
	if (rjahr*10000+rmonat*100+rtag < hjahr*10000+hmonat*100+htag)
	{
		alert ("Die Rückreise kann nur nach der Abreise erfolgen!");
		theForm.hdat1.focus();
		return (false);
	}	

	theForm.hdate1.value = htag;
	theForm.hdate2.value = hmonat;
	theForm.hdate3.value = hjahr;
	theForm.rdate1.value = rtag;
	theForm.rdate2.value = rmonat;
	theForm.rdate3.value = rjahr;

	return (true);
		
}
	
function flug_valid (theForm)
{
	if (ie) 
	{
		adult_zahl = parseInt (theForm.adult.value);
		youth_zahl = parseInt (theForm.youth.value);
		child_zahl = parseInt (theForm.child.value);
		infant_zahl = parseInt (theForm.infant.value);
	}
	else
	{
		adult_zahl = parseInt (theForm.adult.options[theForm.adult.selectedIndex].value);
		youth_zahl = parseInt (theForm.youth.options[theForm.youth.selectedIndex].value);
		child_zahl = parseInt (theForm.child.options[theForm.child.selectedIndex].value);
		infant_zahl = parseInt (theForm.infant.options[theForm.infant.selectedIndex].value);
	}

	if (theForm.destt.value == "")
	{
		alert ("Bitte geben Sie ein Reiseziel an.");
		theForm.destt.focus();
		return (false);
	}
	if (adult_zahl == 0 && youth_zahl == 0 && infant_zahl == 0 && child_zahl == 0) 
	{
		alert ("Bitte wählen Sie die Anzahl der reisenden Personen.");
		theForm.adult.focus();	
		return (false);
	}
	if (adult_zahl != 0 && youth_zahl != 0)
	{
		alert ("Erwachsene und Jugendliche können nicht gleichzeitig gebucht werden. "+
		"Bitte buchen Sie zuerst die erwachsenen Personen und anschliessend separat die Jugendlichen.");
		theForm.adult.focus();	
		return (false);
	}
	if (! adult_zahl && (child_zahl+infant_zahl))
	{
		alert ("Kinder und Kleinkinder können nur in Begleitung von Erwachsenen reisen. Pro Erwachsener kann 1 Kleinkind reisen.");
		theForm.adult.focus();	
		return (false);
	}
	if (adult_zahl && adult_zahl < infant_zahl)
	{
		alert ("Pro Erwachsener kann nur 1 Kleinkind reisen.");
		theForm.adult.focus();	
		return (false);
	}

	if (adult_zahl + youth_zahl + child_zahl + infant_zahl > 6) 
	{
		alert ("Es können maximal 6 Personen gleichzeitig gebucht werden.");
		theForm.adult.focus();	
		return (false);
	}

	htag = parseInt (parseFloat(theForm.hdat1.value));
	hmonat = parseInt (parseFloat(theForm.hdat2.value));
	hjahr = parseInt (parseFloat(theForm.hdat3.value));
	rtag = parseInt (parseFloat(theForm.rdat1.value));
	rmonat = parseInt (parseFloat(theForm.rdat2.value));
	rjahr = parseInt (parseFloat(theForm.rdat3.value));

	if (! teste_datum (htag,hmonat,hjahr))
	{
		alert ("Dieses Datum gibt es nicht!");
		theForm.hdat1.focus();
		return (false);
	}
	if (! teste_datum (rtag,rmonat,rjahr))
	{
		alert ("Dieses Datum gibt es nicht!");
		theForm.rdat1.focus();
		return (false);
	}
	if (hjahr*10000+hmonat*100+htag < theForm.mindatum.value)
	{
		alert ("Sie können nicht früher als der "+theForm.mindatumt.value+" abreisen!");
		theForm.hdat1.focus();
		return (false);
	}
	if (hjahr*10000+hmonat*100+htag > theForm.maxdatum.value)
	{
		alert ("Sie können nicht später als der "+theForm.maxdatumt.value+" abreisen!");
		theForm.hdat1.focus();
		return (false);
	}
	if (rjahr*10000+rmonat*100+rtag < hjahr*10000+hmonat*100+htag)
	{
		alert ("Die Rückreise kann nur nach der Abreise erfolgen!");
		theForm.hdat1.focus();
		return (false);
	}	

	theForm.hdate1.value = htag;
	theForm.hdate2.value = hjahr*100+hmonat;
	theForm.rdate1.value = rtag;
	theForm.rdate2.value = rjahr*100+rmonat;

	start_wartefenster ();
	
	return (true);
}


function start_wartefenster ()
{
	fenster = open ("","Anzeige", "width=260,height=260,top=175,left=250");
	fenster.document.open ();

	fenster.document.open ();

	with (fenster.document)
	{
		write ("<html>");
		write ("<title>Bitte warten Sie...</title>");
		write ('<style type="text/css">');
		write (".table {");
		write ("border-top-width: thin;");
		write ("border-right-width: thin;");
		write ("border-bottom-width: medium;");
		write ("border-left-width: thin;");
		write ("border-top-style: solid;");
		write ("border-right-style: solid;");
		write ("border-bottom-style: ridge;");
		write ("border-left-style: solid;");
		write ("border-top-color: #000099;");
		write ("border-right-color: #000099;");
		write ("border-bottom-color: #000066;");
		write ("border-left-color: #000099;");
		write ("}");
		write ("</style>");

		write ('<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">');
		write ('<table width="255" border="1 solid" align="center" class="table">');
		write ("<tr>");
		write ('<td bordercolor="#000066"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="250" height="250" align="top">');
      write ('<param name="movie" value="http://flight1.travel.ch/flightnewgif/anzeigen/warten1_d.swf" />');
		write ('<param name="quality" value="high" /><param name="SCALE" value="exactfit" />');
		write ('<embed src="http://flight1.travel.ch/flightnewgif/anzeigen/warten1_d.swf" width="250" height="250" align="top" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="exactfit"></embed>');
		write ("</object></td>");
		write ("</tr>");
		write ("</table>");
		write ("</body>");
		write ("</html>");
	}

	fenster.document.close ();
}

function ende_wartefenster ()
{
	if (fenster != null) fenster.close ();
}




function teste_datum (tag,monat,jahr)
{
	mleng = new Array(31,28,31,30,31,30,31,31,30,31,30,31)
		
	if (tag > 0 && tag <= mleng[monat-1]) return (true);
		
	if (monat == 2 && tag == 29)   //  beim Februar könnte es sich um ein Schaltjahr handeln
	{
      if (! (jahr%100) && (jahr/100)%4 ) return (false);
		if (jahr % 4) return (false);
		return (true);
	}
				
	return (false);
}