
/* Formularkontrolle __________________________________*/

function kontrolle() {
	var i, feld, alle = 1;
	
	for(i = 0; i < kontrolle.arguments.length; i++) {
		feld = kontrolle.arguments[i];
		
		if (feld == 'Privacy') {
			
			if (!document.formular.Privacy.checked) {
				alert(textprivacy);
				return;
			}
		}
		else {
			if (Trim(document.formular[feld].value) == '' || document.formular[feld].value == textpflicht) {
				document.formular[feld].value = textpflicht;
				document.getElementById(feld).style.color = farbefehlt;
				document.getElementById(feld).style.border = '1px solid ' + farbefehlt;
				alle = 0;
			}
			else {
				document.getElementById(feld).style.color = farbeeingabe;
				document.getElementById(feld).style.border = '1px solid ' + farberahmen;
				if (feld == 'Email') {
					
					if (IsEmail(document.formular[feld].value) == false) {
						document.getElementById(feld).style.color = farbefehlt;
						document.getElementById(feld).style.border = '1px solid ' + farbefehlt;
						alert(textemail);
						return;
					}
				}
			}
		}
	}
		
	if (alle == 0) {
		alert(texthinweis);
		return;
	}
	else {
		document.formular.submit();
	}
}



/* Formular faerben ___________________________________*/

var k = 0;
eingabe = new Array();

function loeschen(ort) {
	var i, j = 0;
	
	for(i = 0; i < eingabe.length; i++) {
		if (eingabe[i] == ort) {
			j = 1;
		}
	}
	
	if (j == 0) {
		eingabe[k] = ort;
		eingabe.push();
		k = k + 1;
		document.getElementById(ort).value = '';
		document.getElementById(ort).style.color = farbeeingabe;
		document.getElementById(ort).style.border = '1px solid ' + farberahmen;
		return false;
	}
}

function faerben(ort) {
	var i, j = 0;
	
	for(i = 0; i < eingabe.length; i++) {
		if (eingabe[i] == ort) {
			j = 1;
		}
	}
	
	if (j == 0) {
		eingabe[k] = ort;
		eingabe.push();
		k = k + 1;
		document.getElementById(ort).style.color = farbeeingabe;
		document.getElementById(ort).style.border = '1px solid ' + farberahmen;
		return false;
	}
}


/* Stringcheck ________________________________________*/

function LTrim(str)	{
	var whitespace = new String(" \t\n\r");
	var s = new String(str);

	if (whitespace.indexOf(s.charAt(0)) != -1) {
		var j=0, i = s.length;
		while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
			j++;
            s = s.substring(j, i);
	}
	return s;
}


function RTrim(str)	{
	var whitespace = new String(" \t\n\r");
	var s = new String(str);

	if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		var i = s.length - 1;       // Get length of string
		while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
			i--;
			s = s.substring(0, i+1);
	}
	return s;
}


function Trim(str) {
	return RTrim(LTrim(str));
}


/* Emailcheck _________________________________________*/

function IsEmail(s) {
	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);
}


/* PopUp ______________________________________________*/

function openWin( windowURL, windowName, windowFeatures ) {
	return window.open(windowURL, windowName, windowFeatures ); 
	}

function openLocal(windowURL) {
	newWindow = window.open('../popups/local-popup.asp?lPicture=' + windowURL , 'Picture', 'width=200,height=200,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' ); 
	}

function openImage(windowURL) {
	newWindow = window.open(windowURL , 'Picture', 'width=200,height=200,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0' ); 
	}

function openRoom(windowURL) {
	newWindow = window.open('../popups/info.asp?sRoom=' + windowURL , 'Rooms', 'width=590,height=350,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0' ); 
	}


/* PopUp Resize _______________________________________*/

function resize() { 
	
	var x, y;

	x = document.bild.width;
	y = document.bild.height;

	window.resizeTo(x+10,y+56);
}

function checksize() {

	if (document.bild.complete == true)	{
		resize();
	}
	else {
		window.setTimeout("checksize()", 200);
	}
}



/* Image Change _______________________________________*/

function wechseln(ort,bild) {

	if (document.images) {
		document.images[ort].src = bild;
	}
}


/* Submenu Visibility _________________________________*/

var letztes = 0;

function nurzu() {

	if (letztes != 0) {
		document.getElementById(letztes).style.display = 'none';
		clearTimeout(aktiv);
		letztes = 0;
	}
	return false;
}

function nurauf() {

	document.getElementById('hotel').style.display = 'none';
	document.getElementById('wandern').style.display = 'none';
	document.getElementById('skifahren').style.display = 'none';
	document.getElementById('genuss').style.display = 'none';
	document.getElementById('kultur').style.display = 'none';
	
	var aktuelles = nurauf.arguments[0];
	
	if (letztes != 0) {
		clearTimeout(aktiv);
		document.getElementById(letztes).style.display = 'none';
	}
	
	document.getElementById(nurauf.arguments[0]).style.display = 'block';
	letztes = nurauf.arguments[0];
	return false;
}
  
function nurzutimer() {
	aktiv = setTimeout('verzoegern()',2000);
}

function verzoegern() {

	if (letztes != 0) {
		document.getElementById(letztes).style.display = 'none';
		letztes = 0;
	}
	
	return false;
}

function stop() {
	clearTimeout(aktiv);
}
