$(function() {
  $("#price-table1 tr  :first-child p").addClass("alignleft");
  $("#price-table1 tr  :nth-child(2) p").addClass("alignright");
  $("#price-table1 tr  :nth-child(3) p").addClass("alignright");
  $("#price-table2 tr  :first-child p").addClass("alignleft");
  $("#price-table2 tr  :nth-child(2) p").addClass("alignright");
  $("#price-table2 tr  :nth-child(3) p").addClass("alignright");
  $("#price-table3 tr  :first-child p").addClass("alignleft");
  $("#price-table3 tr  :nth-child(2) p").addClass("alignright");
  $("#price-table3 tr  :nth-child(3) p").addClass("alignright");
  // etc
});

function checkEmail(str){
    var emailFilter=/^.+@.+\..{2,3}$/;
    if ((emailFilter.test(str))) {
        return true;
    }
}

function surveyvalid(){
        var gender = jQuery("input[@name='tx_surveyaddfields_pi1[gender]']:checked").val();
        if(gender=='m'|| gender =='f'){
       	     jQuery('#esurvey-gender').html('');
	     jQuery('#esurvey-gender').parent().prev('div').removeClass('text-red');	    
	  }else{
	      jQuery('#esurvey-gender').parent().prev('div').addClass('text-red');
	     jQuery('#esurvey-gender').html('<p style ="color:red;">*Bitte füllen Sie dieses Feld.</p>');
	  }	  
	var fname = jQuery('#survey-fname').val();
	if(fname == ''){
	     jQuery('#esurvey-fname').parent().prev('div').addClass('text-red');
	     jQuery('#esurvey-fname').html('<p style ="color:red;">*Bitte füllen Sie dieses Feld.</p>');
	  }else{
	     jQuery('#esurvey-fname').html('');
	     jQuery('#esurvey-fname').parent().prev('div').removeClass('text-red');
	  }	  
	var lname = jQuery('#survey-lname').val();
	if(lname == ''){
	     jQuery('#esurvey-lname').parent().prev('div').addClass('text-red');
	     jQuery('#esurvey-lname').html('<p style ="color:red;">*Bitte füllen Sie dieses Feld.</p>');
	  }else{
	     jQuery('#esurvey-lname').html('');
	     jQuery('#esurvey-lname').parent().prev('div').removeClass('text-red');
	  }	  
	var street = jQuery('#survey-streetnum').val();
	if(street == ''){
	     jQuery('#esurvey-streetnum').parent().prev('div').addClass('text-red');  
	     jQuery('#esurvey-streetnum').html('<p style ="color:red;">*Bitte füllen Sie dieses Feld.</p>');
	  }else{
  	     jQuery('#esurvey-streetnum').parent().prev('div').removeClass('text-red');  
	     jQuery('#esurvey-streetnum').html('');
	  }	  
	var zip = jQuery('#survey-zip').val();
	if(zip == ''){
     	     jQuery('#esurvey-zip').parent().prev('div').addClass('text-red');  
	     jQuery('#esurvey-zip').html('<p style ="color:red;">*Bitte füllen Sie dieses Feld.</p>');
	  }else{
  	     jQuery('#esurvey-zip').parent().prev('div').removeClass('text-red');  
	     jQuery('#esurvey-zip').html('');
	  }	  
	var city = jQuery('#survey-city').val();
	if(city == ''){
	     jQuery('#esurvey-city').parent().prev('div').addClass('text-red');  
	     jQuery('#esurvey-city').html('<p style ="color:red;">*Bitte füllen Sie dieses Feld.</p>');
	  }else{
	     jQuery('#esurvey-city').parent().prev('div').removeClass('text-red');  
             jQuery('#esurvey-city').html('');
	  }	  
	var bday = jQuery('#survey-bday').val();
	if(bday == ''){
      	     jQuery('#esurvey-bday').parent().prev('div').addClass('text-red');  
	     jQuery('#esurvey-bday').html('<p style ="color:red;">*Bitte füllen Sie dieses Feld.</p>');
	  }else{
 	     jQuery('#esurvey-bday').parent().prev('div').removeClass('text-red');  
	     jQuery('#esurvey-bday').html('');
	  }	  
	var email = jQuery('#survey-email').val();
	if (email == '') {
            jQuery('#esurvey-bday').parent().prev('div').addClass('text-red');  
	    jQuery('#esurvey-email').html('<p style ="color:red;">*Bitte füllen Sie dieses Feld.</p>');
	} else{
	    jQuery('#esurvey-bday').parent().prev('div').removeClass('text-red');  
	 jQuery('#survey-email').html('');
     }
	if(!checkEmail(email)){
	   jQuery('#esurvey-email').parent().prev('div').addClass('text-red');  
	   jQuery('#esurvey-email').html('<p style ="color:red;">*Bitte füllen Sie dieses Feld.</p>');
	}else{
	   jQuery('#esurvey-email').parent().prev('div').removeClass('text-red');  
	   jQuery('#esurvey-email').html('');
	}
	var dmail = jQuery('#survey-dmail').attr('checked');
	if(dmail == ''){
	     jQuery('#esurvey-dmail').parent().prev('div').addClass('text-red');     
	     jQuery('#esurvey-dmail').html('<p style ="color:red;">*Bitte füllen Sie dieses Feld.</p>');
	  }else{
	     jQuery('#esurvey-dmail').parent().prev('div').removeClass('text-red');   
	     jQuery('#esurvey-dmail').html('');
	  }		
       if(gender=='on'|| fname == '' || lname == '' || street == '' || zip  == '' || city  == '' || bday   == '' || email  == '' || damil == '' ||!checkEmail(email) ){
	     return false
	  }else{
        document.tt_address_form.submit();	      
	  }
}
