/*
 *  Überprüft die Email
 */
function checkEmailStr(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);
}


/*
 *  Überprüft das Kontakt Formular
 */
function checkContact()
{
  var contact_name = window.document.getElementsByName('_ie_name')[0];
  if(contact_name == null)
  {
     window.alert("JavaScript Fehler checkContact");
     return false;
  }
  var contact_email = window.document.getElementsByName('_ie_email')[0];
  if(contact_email == null)
  {
     window.alert("JavaScript Fehler checkContact");
     return false;
  }
  var contact_message = window.document.getElementsByName('_ie_message')[0];
  if(contact_message == null)
  {
     window.alert("JavaScript Fehler checkContact");
     return false;
  }

  if (contact_name.value == "")
    contact_name.style.backgroundColor = '#cccccc';
  else
    contact_name.style.backgroundColor = '#ffffff';

  if (contact_email.value == "")
    contact_email.style.backgroundColor = '#cccccc';
  else
    contact_email.style.backgroundColor = '#ffffff';

  if (contact_message.value == "")
    contact_message.style.backgroundColor = '#cccccc';
  else
    contact_message.style.backgroundColor = '#ffffff';

  var email_checker = true;
  if (contact_email.value != "")
    email_checker = checkEmailStr(contact_email.value);

  if (email_checker == false)
  {
    contact_email.style.backgroundColor = '#cccccc';
    alert('Bitte überprüfe die eingegebene E-Mail auf Richtigkeit!\n(Beispiel: meine@email.de)');
    return false;
  }

  if (contact_name.value == "" || contact_email.value == "" || contact_message.value == "")
  {
    alert('Bitte überprüfe alle markierten Felder!');
    return false;
  }
  else
    return true;
}