// JavaScript Document

function openit(page){
	window.open(page,"win","scrollbars=1,width=670,height=500,resizable=yes");	
}

function start(){
	parent.titel.location='sites/titel_start.htm';
	parent.content.location='sites/start.htm';
}
function restaurant(){
	parent.titel.location='sites/titel_restaurant.htm';
	parent.content.location='sites/restaurant.htm';
}
function umgebung(){
	parent.titel.location='sites/titel_umgebung.htm';
	parent.content.location='sites/umgebung.htm';
}
function hotel(){
	parent.titel.location='sites/titel_hotel.htm';
	parent.content.location='sites/hotel.htm';
}
function gallerie(){
	parent.titel.location='sites/titel_gallerie.htm';
	parent.content.location='php/galery.php';
}

function jobs(){
	parent.titel.location='sites/titel_jobs.htm';
	parent.content.location='php/jobticker.php';
}

function speisenkarte(){
	parent.titel.location='sites/titel_speisenkarte.htm';
	parent.content.location='php/speisenkarte.php';
}
function aktionen(){
	parent.titel.location='sites/titel_aktionen.htm';
	parent.content.location='php/aktionen.php';
}

function zurueck(){
	parent.titel.location='titel_restaurant.htm';
	parent.content.location='restaurant.htm';
}

function anfahrt(){
	parent.titel.location='sites/titel_anfahrt.htm';
	parent.content.location='sites/anfahrt.htm';
}
function kontakt(){
	parent.titel.location='sites/titel_kontakt.htm';
	parent.content.location='php/kontakt.php';
}
function kontakt2(){
	parent.titel.location='titel_kontakt.htm';
	parent.content.location='../php/kontakt.php';
}
function impressum(){
	parent.titel.location='sites/titel_impressum.htm';
	parent.content.location='sites/impressum.htm';
}
function datenschutz(){
	parent.titel.location='sites/titel_datenschutz.htm';
	parent.content.location='sites/datenschutz.htm';
}

function openit(pic){
	window.open(pic,"win","width=780,height=610");	
}

function sayit(tosay){
	alert(tosay);
}


//------------Überprüfung beliebiger Formularfelder auf Inhalt------------------------
function checkIt(i1,i2){
	teststring = document.forms[i1].elements[i2].value;
	if(teststring==''){		//Steht was (nix) im Feld
		return false;									//steht nix drin, schicke false zurück
	}	//end if
}	//end checkIt
//------------------------------------------------------------------------------------

function checkMail(i1,i2)
{
 s = document.forms[i1].elements[i2].value;
 var a = false;
 var res = false;
 
 if(typeof(RegExp) == 'function')
 {
  var b = new RegExp('abc');
  if(b.test('abc') == true){a = true;}
  }

 if(a == true)
 {
  reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+
                   '(\\@)([a-zA-Z0-9\\-\\.]+)'+
                   '(\\.)([a-zA-Z]{2,4})$');
  res = (reg.test(s));
 }
 else
 {
  res = (s.search('@') >= 1 &&
         s.lastIndexOf('.') > s.search('@') &&
         s.lastIndexOf('.') >= s.length-5)
 }
 return(res);
} 

//-----------------------------------------------------------------------------------------
//-------------pruefen kontaktformular-----------------------------------------------------
function KformularPruefen(){

	fehler = true;
	
	fehler = checkIt(0,0);							//Überprüfung name
	if(fehler==false){
		sayit("Bitte Name eintragen.");			//Fehlermeldung
		document.forms[0].elements[0].focus();		//Cusor in Fehlerfeld setzen
		return;
	}	//end if

	
	fehler = checkIt(0,2);							//Überprüfung betreff
	if(fehler==false){
		sayit("Bitte Betreff eintragen.");			//Fehlermeldung
		document.forms[0].elements[2].focus();		//Cusor in Fehlerfeld setzen
		return;
	}	//end if

	fehler = checkIt(0,5);						//Überprüfung Mitteilung
	if(fehler==false){
		sayit("Bitte Nachricht eintragen.");
		document.forms[0].elements[5].focus();		//Cusor in Fehlerfeld setzen
		return;
	}	//end if
	
	fehler = checkIt(0,6);						//Überprüfung Telefon
	if(fehler==false){
		sayit("Bitte Telefonnummer eintragen.");
		document.forms[0].elements[6].focus();		//Cusor in Fehlerfeld setzen
		return;
	}	//end if

	fehler = checkMail(0,8);						//Überprüfung Mail
	if(fehler==false){
		sayit("Bitte eine gültige Email-Adresse eintragen.");
		document.forms[0].elements[8].focus();		//Cusor in Fehlerfeld setzen
		return;
	}	//end if
	

	if(fehler==true){
		document.forms[0].submit();
	}	//end if
}

//-----------------------------------------------------------------------------------------
