if( document.addEventListener ) document.addEventListener( 'DOMContentLoaded', cmxform, false );

function cmxform(){
  // Hide forms
  $( 'form.cmxform' ).hide().end();
  
  // Processing
  $( 'form.cmxform' ).find( 'li/label' ).not( '.nocmx' ).each( function( i ){
    var labelContent = this.innerHTML;
    var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
    var labelSpan = document.createElement( 'span' );
        labelSpan.style.display = 'block';
        labelSpan.style.width = labelWidth;
        labelSpan.innerHTML = labelContent;
    this.style.display = '-moz-inline-box';
    this.innerHTML = null;
    this.appendChild( labelSpan );
  } ).end();
  
  // Show forms
  $( 'form.cmxform' ).show().end();
}

//function to check empty fields

function isEmpty() {

strfield1 = document.forms[1].name.value 
strfield2 = document.forms[1].email.value

    if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
    {
    alert("Bitte geben Sie Ihren Namen ein!")
    return false;
    }

    if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
    {
    alert("Bitte geben Sie eine gueltige Email-Adresse ein!")
    return false;
    }
	
    return true;
}

//function to check valid email address
function isValidEmail(){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.forms[1].email.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      alert('Die Email-Adresse ist ungueltig.\nBitte versuchen Sie es noch einmal!');
      return false;
    } 
    return true; 
}
//function that performs all functions, defined in the onsubmit event handler

function check(form){
if (isEmpty(form.name)){
		if (isValidEmail(form.email)){
		  return true;
		}
	}
	return false;
}

