//-----------------------------------------------------------------------------|
function getRadioValue( fieldName ) {

  var radioElements = document.contactForm.elements[fieldName];

  var found = false;

  var radioValue = '';

  for ( var i = 0; ( ! found ) && ( i < radioElements.length ) ; i++ ) {

    found = ( radioElements[i].checked == true );

    if ( found ) radioValue = radioElements[i].value;

  } // for

  return radioValue;

} // getRadioValue()
//-----------------------------------------------------------------------------|
function verifyRadio( displayName, fieldName ) {

  var radioElements = document.contactForm.elements[fieldName];

  var found = false;

  for ( var i = 0; ( ! found ) && ( i < radioElements.length ) ; i++ )
    found = ( radioElements[i].checked == true );

  if ( ! found )
    return displayName + ' - empty\n';

  return '';

} // verifyRadio()
//-----------------------------------------------------------------------------|
function verifySelect( displayName, fieldName ) {

  var options = document.contactForm.elements[fieldName].options;

  if ( options == null || options[ options.selectedIndex ].value == '' )
    return displayName + ' - empty\n';

  return '';

} // verifySelect()
//-----------------------------------------------------------------------------|
function verifyText( displayName, fieldName ) {
  if ( document.contactForm.elements[fieldName].value == '' )
    return displayName + ' - empty\n';

  return '';
} // verifyText()
//-----------------------------------------------------------------------------|
function emailContainsInvalidChars( email ) {

  var strInvalidChars = 'ÄBäB&BÖBöBÜBüBßB;B,B|B!B§B$B%B&B/B(B)B=B{B}B[B]';

  var invalidChars = new Array();

  var emailInvalid = 0;

  invalidChars = strInvalidChars.split( 'B' );

  for ( var j = 0 ; ! emailInvalid && ( j < invalidChars.length ) ; j++ )
    if ( email.indexOf( invalidChars[j] ) != -1 )
      emailInvalid = 1;

  return emailInvalid;

} // emailContainsInvalidChars()
//-----------------------------------------------------------------------------|
// E-mail Validation.
// Adapted by Sam Brannen from an example by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
function verifyEmail( displayName, fieldName ) {

  var str = '';

  var field = document.contactForm.elements[fieldName];

  with ( field ) {

    // if empty.
    if ( emptyValue( value ) ) str = displayName + ' - empty\n';

    // else if the e-mail contains invalid characters.
    else if ( emailContainsInvalidChars( value ) )
      str = displayName + ' - contains invalid characters\n';

    // else if valid...
    else {

      var atPos   = value.indexOf( "@" );
      var dotPos  = value.lastIndexOf( "." );
      var lastPos = value.length - 1;

      // if ( atPos < 1 || dotPos - atPos < 2 || lastPos - dotPos > 3 || lastPos - dotPos < 2 )
      if ( atPos < 1 || dotPos - atPos < 2 || lastPos - dotPos < 2 )
        str = displayName + ' - incomplete\n';

    } // else

  } // with

  return str;

} // verifyEmail()
//-----------------------------------------------------------------------------|
function emptyValue( val ) {
  return ( val == null || val == "" );
} // emptyValue()
//-----------------------------------------------------------------------------|
function submitEmailForm() {

  var str = '';

  str += verifySelect( 'Title',           'title'    );
  str += verifyText  ( 'First Name',      'fname'    );
  str += verifyText  ( 'Last Name',       'lname'    );
  // str += verifyText  ( 'Address',         'address'  );
  // str += verifyText  ( 'City',            'city'     );
  // str += verifySelect( 'Country',         'country'  );
  // str += verifyText  ( 'ZIP/Postal Code', 'zip'      );
  str += verifyEmail ( 'E-mail address',  'email'    );
  str += verifyText  ( 'Comments',        'comments' );

  if ( str != '' ) {
    alert( 'The message could not be sent as you need to fill-in \nthe fields marked with an asterisk (*).\n\n' + str );
    // return false;
  } // if

  else
    document.contactForm.submit(); // return true;

} // submitEmailForm()
//-----------------------------------------------------------------------------|