var isNav, isIE, is4;
if (parseInt(navigator.appVersion) >= 4) {
    if (navigator.appName == "Netscape") {
      isNav = true;
	  if (parseInt(navigator.appVersion) >= 5) is4=true;
   } else is4=true;
} else is4=false;


function get_obj(welches) {
	return (document.getElementById) ? document.getElementById(welches).style : (isNav) ? eval("document."+welches) : eval("document.all."+welches+".style");
}
function get_div(welches) {
	return (document.getElementById) ? document.getElementById(welches) : (isNav) ? eval("document."+welches) : eval("document.all."+welches);
}

function init() {
//alert(window.innerHeight+"\n"+document.body.offsetHeight+"\n"+navigator.appName)
	var x=(isNav==true) ?  window.innerHeight :document.body.offsetHeight;
	if (x<600) {
		var here =get_obj("main");
		here.top=300;
	}
}


function picSchliessen() {
	var here=get_obj("bildDiv");
	var aktion=(isNav && !is4) ? "hide" : "hidden";	
	here.visibility=aktion;	
}

function picZeigen(welches) {
	var here=get_div("bildDiv");
	//alert(picStr[welches])
	here.innerHTML=picStr[welches];
	var here=get_obj("bildDiv");
	var aktion=(isNav && !is4) ? "show" : "visible";	
	here.visibility=aktion;	
}

function DiaTextSchreiben(welches) {
	var here=get_div("diaHtml");
	//alert(picStr[welches])
	here.innerHTML=picStr[welches];
	here=get_div("diaSteuerung");
	//alert(picStr[welches])
	here.innerHTML=picInd[welches];

}
function checkLeer(was) {

	hstr1=was.replace(/\b\s\b/g," ");
	hstr1=hstr1.replace(/\s/g,"")

	if (hstr1=="") {
		return 0;
	} else {
		return 1;	
	}
}

function checkEmail(was) {

	var checkEmailrg   = /.*\@.*\.\w+/i;
	var checkEmailrg   = /^[_\.0-9a-z-]+@([0-9a-z][_0-9a-z-]+\.)+[a-z]{2,4}$/ig;	
	if (checkEmailrg.test(was) == false){
		return 0;
	} else {
		return 1;	
	}
}

function checkURL(was) {

	var checkEmailrg   = /.*\@.*\.\w+/i;
	var checkEmailrg   = /^[_\.0-9a-z-]+(\.)+[a-z]{2,4}$/ig;	
	if (checkEmailrg.test(was) == false){
		return 0;
	} else {
		return 1;	
	}
}


function checkZahl(was) {
	if (checkLeer(was)==0) return 0;
	was=parseInt(was);	
 if(isNaN(was) == true)  return 0;
 return was;
}

function checkDatum(tag,monat,jahr) {
		monat=monat-1;
	  	var Jetzt = new Date();
    	JetztP = Date.parse(Jetzt);	
		
		var vglDat =new Date(jahr,monat,tag);	
    	vglDatP = Date.parse(vglDat);
				


		if (vglDatP<Jetzt) return 0;
		return 1;
}




var fehler=new Array;
fehler["Vorname"]="Bitte geben Sie Ihren Vornamen ein";
fehler["Name"]="Bitte geben Sie Ihren Namen ein";
fehler["Email"]="Bitte geben Sie Ihre Emailadresse ein";
fehler["gbEintrag"]="Bitte geben Sie Ihren Gästebucheintrag ein";
fehler["Telefon"]="Bitte geben Sie Ihre Telefonnummer ein";
fehler["Datum"]="Bitte geben Sie ein gültiges Datum ein";
fehler["Naechte"]="Bitte geben Sie Anzahl der Nächte ein";
fehler["Personen"]="Bitte geben Sie Anzahl der Personen ein";

function check_Formular() {
	var hstr1
	var formTyp=document.Formular.formTyp.value
	if (formTyp==2) {
		var x=parseInt(document.Formular.aktionA.value)
		
		if (x==0) {
		hstr1=document.Formular.Tag.value
		if (checkZahl(hstr1)<1 || checkZahl(hstr1)>31) {
			alert(fehler["Datum"]);
			document.Formular.Tag.value="";
			document.Formular.Tag.focus();		
			return false;
		}
		hstr1=document.Formular.Monat.value
		if (checkZahl(hstr1)<1 || checkZahl(hstr1)>12) {
			alert(fehler["Datum"]);
			document.Formular.Monat.value="";
			document.Formular.Monat.focus();		
			return false;
		}
		
		hstr1=document.Formular.Jahr.value
		
		if (checkZahl(hstr1)>0) {
			hstr1=parseInt(hstr1)
	
			if (hstr1<100) {
				hstr1+=2000;
				document.Formular.Jahr.value=hstr1;
			}
			//alert(hstr1)
		}
		Jetzt = new Date();
    	var aktJahr = Jetzt.getFullYear();
		if (hstr1<aktJahr) {
			alert(fehler["Datum"]);
			document.Formular.Jahr.value="";
			document.Formular.Jahr.focus();		
			return false;
		} 
		if (checkDatum(document.Formular.Tag.value,document.Formular.Monat.value,document.Formular.Jahr.value)==0) {
			alert(fehler["Datum"]);
			document.Formular.Monat.value="";
			document.Formular.Jahr.value="";
			document.Formular.Tag.value="";
			document.Formular.Tag.focus();		
			return false;
		}
		}
		hstr1=document.Formular.Personen.value
		if (checkZahl(hstr1)<1) {
			alert(fehler["Personen"]);
			document.Formular.Personen.value="";
			document.Formular.Personen.focus();		
			return false;
		}

		
	}
	
	if (formTyp==3) {
		hstr1=document.Formular.Tag.value
		if (checkZahl(hstr1)<1 || checkZahl(hstr1)>31) {
			alert(fehler["Datum"]);
			document.Formular.Tag.value="";
			document.Formular.Tag.focus();		
			return false;
		}
		hstr1=document.Formular.Monat.value
		if (checkZahl(hstr1)<1 || checkZahl(hstr1)>12) {
			alert(fehler["Datum"]);
			document.Formular.Monat.value="";
			document.Formular.Monat.focus();		
			return false;
		}
		
	    Jetzt = new Date();
		hstr1=document.Formular.Jahr.value
		
		if (checkZahl(hstr1)>0) {
			hstr1=parseInt(hstr1)
	
			if (hstr1<100) {
				hstr1+=2000;
				document.Formular.Jahr.value=hstr1;
			}
			//alert(hstr1)
		}

    	var aktJahr = Jetzt.getFullYear();
		if (hstr1<aktJahr) {
			alert(fehler["Datum"]);
			document.Formular.Jahr.value="";
			document.Formular.Jahr.focus();		
			return false;
		} 
		
		if (checkDatum(document.Formular.Tag.value,document.Formular.Monat.value,document.Formular.Jahr.value)==0) {
			alert(fehler["Datum"]);
			document.Formular.Monat.value="";
			document.Formular.Jahr.value="";
			document.Formular.Tag.value="";
			document.Formular.Tag.focus();		
			return false;
		}
		hstr1=document.Formular.Naechte.value
		if (checkZahl(hstr1)<1) {
			alert(fehler["Naechte"]);
			document.Formular.Naechte.value="";
			document.Formular.Naechte.focus();		
			return false;
		}
		hstr1=document.Formular.Personen.value
		if (checkZahl(hstr1)<1) {
			alert(fehler["Personen"]);
			document.Formular.Personen.value="";
			document.Formular.Personen.focus();		
			return false;
		}

		
	}
	hstr1=document.Formular.Vorname.value
	if (checkLeer(hstr1)==0) {
		alert(fehler["Vorname"]);
		document.Formular.Vorname.focus();		
		return false;
	}
	hstr1=document.Formular.Name.value
	if (checkLeer(hstr1)==0) {
		alert(fehler["Name"]);
		document.Formular.Name.focus();		
		return false;
	}
	hstr1=document.Formular.Telefon.value
	if (checkLeer(hstr1)==0) {
		alert(fehler["Telefon"]);
		document.Formular.Telefon.focus();		
		return false;
	}
	hstr1=document.Formular.Email.value
	if (checkLeer(hstr1)==0) {
		alert(fehler["Email"]);
		document.Formular.Email.focus();		
		return false;
	}
	
	
	return true;
}










function check_gaestebuch() {

	hstr1=document.Formular.Name.value
	if (checkLeer(hstr1)==0) {
		alert(fehler["Name"]);
		document.Formular.Name.focus();		
		return false;
	}
	hstr1=document.Formular.Email.value
	if (checkLeer(hstr1)==0) {
		alert(fehler["Email"]);
		document.Formular.Email.focus();		
		return false;
	}
	hstr1=document.Formular.Text.value
	if (checkLeer(hstr1)==0) {
		alert(fehler["gbEintrag"]);
		document.Formular.Text.focus();		
		return false;
	}
	
	
	else return true;
}


