/*------------------------------------------*/
/* Funktion zum kontrollieren des Formulars */
/*------------------------------------------*/

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();
	}
}



/*------------------------------------------*/
/* Funktion zum loeschen des Formularfeldes */
/*------------------------------------------*/

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;
	}
}


function anfang() {
	var i;
	
	for(i = 0; i < eingabe.length; i++) {
		var feld = eingabe[i];
		document.getElementById(feld).style.color = farbepflicht;
	}
	document.formular.reset(); 
	eingabe = new Array();
	k = 0;  
}

/*-----------------------------------------------*/
/* Funktion zum kontrollieren des Formularfeldes */
/*-----------------------------------------------*/

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));
}



/*---------------------------------------------*/
/* Funktion zum kontrollieren der Emailadresse */
/*---------------------------------------------*/

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' ); 
	}


/* 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);
	}
}


/*---------------------------------------------*/
/* Funktion zum ein-/ausblenden von DIV Ebenen */
/*---------------------------------------------*/

/*Beispiel <a href="http://www.zeppelin.bz" onmouseover="aufzu('test')" onmouseout="aufzu('test')"><img src="images/navi.gif" border="0" alt=""></a>
           <div id="test" style="position: absolute; visibility: hidden;">
             Hallo!
           </div>*/

var letztes = 0;

function aufzu()
  {
  if (document.getElementById(aufzu.arguments[0]).style.visibility === 'hidden')
    {
    if (letztes !== 0)
      {
      document.getElementById(letztes).style.visibility = 'hidden';
      }
    document.getElementById(aufzu.arguments[0]).style.visibility = 'visible';
    letztes = aufzu.arguments[0];
    }
  else
    {
    document.getElementById(aufzu.arguments[0]).style.visibility = 'hidden';
    }
  return false;
  }
  
/*Beispiel <a href="http://www.zeppelin.bz" onmouseout="nurzu()"><img src="images/navi.gif" border="0" alt=""></a>
           <div id="test" style="position: absolute; visibility: hidden;">
             Hallo!
           </div>*/
  
function nurzu()
  {
  if (letztes != 0)
    {
    document.getElementById(letztes).style.visibility = 'hidden';
    clearTimeout(aktiv);
    letztes = 0;
    }
  return false;
  }

/*Beispiel <a href="http://www.zeppelin.bz" onmouseover="nurauf('test')"><img src="images/navi.gif" border="0" alt=""></a>
           <div id="test" style="position: absolute; visibility: hidden;">
             Hallo!
           </div>*/

function nurauf()
  {
  var aktuelles = nurauf.arguments[0];
  if (letztes != 0)
    {
    clearTimeout(aktiv);
    document.getElementById(letztes).style.visibility = 'hidden';
    }
  document.getElementById(nurauf.arguments[0]).style.visibility = 'visible';
  letztes = nurauf.arguments[0];
  return false;
  }
  
/*Beispiel <a href="http://www.zeppelin.bz" onmouseout="nurzutimer()"><img src="images/navi.gif" border="0" alt=""></a>
           <div id="test" style="position: absolute; visibility: hidden;">
             Hallo!
           </div>*/
  
function nurzutimer()
  {
  aktiv = setTimeout('verzoegern()',500);
  }

function verzoegern()
  {
  if (letztes != 0)
    {
    document.getElementById(letztes).style.visibility = 'hidden';
    letztes = 0;
    }
  return false;
  }

/*Beispiel <a href="http://www.zeppelin.bz" onmouseover="stop()"><img src="images/navi.gif" border="0" alt=""></a>
           <div id="test" style="position: absolute; visibility: hidden;">
             Hallo!
           </div>*/

function stop()
  {
  clearTimeout(aktiv);
  }
  