//Formularprüfung
function checkForm(strForm) {

var strMeldg = "Bitte überprüfen/ergänzen Sie folgende Angaben im Formular:<ul>";
var emailcheck = EMail(strForm.email.value);

if (!emailcheck)
	
  { if (!emailcheck) strMeldg += "<li><b>E-Mail-Adresse</b></li>";
    	    			   
	strMeldg += "</ul>";
	
	// Meldung ausgeben
    var subwin = window.open ("", "", "top=300,left=250,width=300,height=200,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0");
    subwin.focus();
	
	subwin.document.write('<html>');
	subwin.document.write('<head>');
	subwin.document.write('<title>Formularprüfung</title>');
	subwin.document.write('<link rel="stylesheet" type="text/css" href="lib/css/main.css">');
	subwin.document.write('</head>');
    subwin.document.write('<body onblur="self.close()" style="background-color:#FFFFFF" text="#003366" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">');
    subwin.document.write('<table border="0" cellpadding="10" cellspacing="10">');
    subwin.document.write('<tr valign="top"><td>'+ strMeldg +'</td></tr>');
	subwin.document.write('<tr><td align="center" height="20"><a href="javascript:self.close()" class="menu">Fenster schließen</a></td></tr>');
    subwin.document.write('</table>');
    subwin.document.write('</body>');
    subwin.document.write('</html>');
	return false;
  }
  else 
  {
	//Alle erforderlichen Eingaben wurden gemacht, das Formular wird nun gesendet!
	return true;
  }
}	

function trim(s) 
{
  // Leerzeichen am Anfang und Zeilenumbrueche entfernen
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }

  // Leerzeichen am Ende und Zeilenumbrueche entfernen
  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function noHTML(txt) 
{
  a = txt.indexOf('<');
  b = txt.indexOf('>');
  len = txt.length;
  c = txt.substring(0, a);
  if(b == -1) 
  {
    b = a;
  }
  d = txt.substring((b + 1), len);
  txt = c + d;
  cont = txt.indexOf('<');
  if (cont != -1) 
  {
    txt = noHTML(txt);
  }
  return txt;
}	

//Überprüfung der E-Mail Funktion
function EMail(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);
 }
