function classwechsel(elementid)
{
  var classtauscher;
  document.getElementById(classtauscher).className='MenuItem';
  document.getElementById(elementid).className='MenuItemaktiv';
  classtauscher=document.getElementById(elementid).id;
}

//whitespace characters
var whitespace = " \t\n\r";

//--------------------------------------------------------------------
// Description: Check whether string s is empty.
//---------------------------------------------------------------------
function isEmpty(s)
{ return ((s == null) || (s.length == 0)) }
//--------------------------------------------------------------------
// Description: Check whether all characters in string are whitespaces
//---------------------------------------------------------------------
function isWhitespace (s)
{
  var i;

  //Is s empty?
  if (isEmpty(s)) return true;

  //Search through string's characters one by one
  //until we find a non-whitespace character.
  //When we do, return false; if we don't, return true.
  for(i=0;i<s.length;i++)
  {
    // Check that current character isn't whitespace.
    var c = s.charAt(i);
    if(whitespace.indexOf(c) == -1) return false;
  }
  //All characters are whitespace.
  return true;
}
//--------------------------------------------------------------------
// Description: left and right trim string
//---------------------------------------------------------------------
function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}
//--------------------------------------------------------------------
// Description: Checks the specified string for a valid email address.
//---------------------------------------------------------------------
function isValidEmail(email) {
   email = trim(email);
   
   var usr = "([a-zA-Z0-9][a-zA-Z0-9_.-]*|\"([^\\\\\x80-\xff\015\012\"]|\\\\[^\x80-\xff])+\")";
   var domain = "([a-zA-Z0-9][a-zA-Z0-9._-]*\\.)*[a-zA-Z0-9][a-zA-Z0-9._-]*\\.[a-zA-Z]{2,5}";
   var regex = "^" + usr + "\@" + domain + "$";
   var regExEmail = new RegExp(regex);
   if(regExEmail.test(email) && !isWhitespace(email))
      return true;
   else
      return false;
}

//--------------------------------------------------------------------
// Description: KiM-Anfrage ... ContactForm-Checker
//---------------------------------------------------------------------
function checkContactForm()
{
var contactForm=document.contactForm;
if (isWhitespace(contactForm.v_name.value)) //Name
{ alert ("Bitte geben Sie Ihren Namen ein!"); //Meldung wenn Fehler
contactForm.v_name.focus(); //Sprung zum Feld
return false; } //false gibt zurück wenn Fehler
if (!isValidEmail(contactForm.v_email.value)) //E-Mail
{ alert ("Bitte geben Sie eine gültige E-Mail-Adresse ein!");
contactForm.v_email.focus();
return false; }
return true;
}
