/*
 *  Ü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_your_name_field')[0];
  if(contact_name == null)
  {
     window.alert("JavaScript Fehler checkContact");
     return false;
  }
  var contact_email = window.document.getElementsByName('_ie_your_email_address_field')[0];
  if(contact_email == null)
  {
     window.alert("JavaScript Fehler checkContact");
     return false;
  }
  var contact_message = window.document.getElementsByName('_ie_contact_message_field')[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 = '#D4DDFD';
    alert('Please double-check your specified E-Mail address!\n(example me@myemail.de)');
    return false;
  }

  if (contact_name.value == "" || contact_email.value == "" || contact_message.value == "")
  {
    alert('Please check all marked boxes');
    return false;
  }
  else
    return true;
}



/*
 *  Überprüft das Kontakt Formular
 */
function checkHome()
{
  var email = window.document.getElementsByName('MERGE0')[0];
  if(email == null)
  {
     window.alert("JavaScript Fehler checkContact");
     return false;
  }

  if (email.value == "")
    email.style.backgroundColor = '#cccccc';
  else
    email.style.backgroundColor = '#ffffff';


  var email_checker = true;
  if (email.value != "")
    email_checker = checkEmailStr(email.value);

  if (email_checker == false)
  {
    email.style.backgroundColor = '#D4DDFD';
    alert('Please double-check your specified E-Mail address!\n(example me@myemail.de)');
    return false;
  }

  if (email.value == "")
  {
    alert('Please check all marked boxes');
    return false;
  }
  else
    return true;
}
