
 function CheckOfficeEing() {
	
 //Sind es Zahlen?   
    if (isNaN(document.office_anfrage.von_vorwahl.value))
    {
     alert("Bitte geben Sie nur Zahlen in das Feld Vorwahl ein!");
     document.office_anfrage.von_vorwahl.focus();
     return false;
    }
       if (isNaN(document.office_anfrage.von_tel.value))
    {
     alert("Bitte geben Sie nur Zahlen in das Feld Telefon ein!");
     document.office_anfrage.von_tel.focus();
     return false;
    }
    
 // Hauptdaten     
   if (document.office_anfrage.von_nachname.value <= " ")
    {
     alert("Bitte geben Sie Ihren Namen an.");
     document.office_anfrage.von_nachname.focus();
     return false;
    }
    	
    if (document.office_anfrage.von_vorwahl.value <= " ")
    {
     alert("Bitte geben Sie Ihre Vorwahl an.");
     document.office_anfrage.von_vorwahl.focus();
     return false;
    }
   
   if (document.office_anfrage.von_tel.value <= " ")
    {
     alert("Bitte geben Sie Ihre Telefonnummer an.");
     document.office_anfrage.von_tel.focus();
     return false;
    }
    
   if (document.office_anfrage.von_mail.value <= " ")
    {
     alert("Bitte geben Sie Ihre E-Mail an.");
     document.office_anfrage.von_mail.focus();
     return false;
    } 
    
    if (document.office_anfrage.von_mail.value != " ")
    {
     if ( ! checkEmail( document.office_anfrage.von_mail.value, true ) ) {	
     alert("Bitte tragen Sie eine gültige E-Mail Adresse ein!\n");
     document.office_anfrage.von_mail.focus();
     return false;
     } 
    }
    
    
    
  else {
     return true;
    }
  }
  
  

  function checkEmailAdr( address )
  {
    var status = true;
    var username = "";
    var hostname = "";

    if ( address.length < 8 )
      return false;

    var seperate = address.lastIndexOf("@");
    if ( seperate == -1 )
      return false;

    username = address.substring(0, seperate );
    if ( ! checkUsername( username, "<>()[],;:@\" " ) )
      return false;

    hostname = address.substring(seperate+1, address.length );
    if ( ! checkHostname( hostname ) )
      return false;

    return true;
  }


function checkEmail( email, allowFullname )
  {
    var existFullname = false;
    var status = true;
    var fullname = "";
    var adress = "";
    if ( email.length < 8 )
      return false;
    var emailBegin = email.indexOf("<");
    var emailEnd = email.lastIndexOf(">");

    if ( (emailBegin == -1) && (emailEnd == -1) )
      return checkEmailAdr( email );

    if ( ( (emailBegin == -1) && (emailEnd != -1) )
        || ( (emailBegin != -1) && (emailEnd == -1) ) )
      return false;

    adress = email.substring( emailBegin+1, emailEnd );

    if ( ! checkEmailAdr( adress ) )
      return false;

    if ( email.length == adress.length + 2 )
      return true;
    else
      if ( ! allowFullname )
        return false;

    if ( emailEnd == email.length - 1 )
    {
      if ( emailBegin == 0 )
        return true;
      if ( email.charAt( emailBegin -1 ) != ' ' )
        return false;
      fullname = email.substring( 0, emailBegin-1 );
      return checkUsername ( fullname, "<>()[],;:@\"" );
    }

    return false ;
  }