function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress); }

$(document).ready(function(){
	$('#professionalfrm').submit(function(){
								 //alert('dsfa');
		var email = $('#email').val();
		//var iamlogin;
		//alert(iamlogin);
		
	     if(jQuery.trim($('#pro_name').val()).length==0)
		 {
			alert('Please Enter your name ');
			$('#pro_name').focus();
			return false;
		 }
	    else if(jQuery.trim($('#pro_username').val()).length==0)
		 {
			alert('Please Enter your username ');
			$('#pro_username').focus();
			return false;
		 }
		 else if(jQuery.trim($('#pro_password').val()).length==0)
		 {
			alert('Please give your password ');
			$('#pro_password').focus();
			return false;
		 }
		  else if(jQuery.trim($('#pro_password2').val()).length==0)
		 {
			alert('Please re type your password ');
			$('#pro_password2').focus();
			return false;
		 }
		 else if($('#pro_password').val()!=$('#pro_password2').val())
		 {
			alert('Password and Re-enter Password is not matching.');
			$('#pro_password').focus();
			return false;
		 }
		 else if($('#pro_question_id').val()==0)
		 {
			//alert($('#pro_question_id').val());
			alert('Please choose security question ');
			$('#pro_question_id').focus();
			return false;
		 }
		 else if(jQuery.trim($('#pro_answer').val()).length==0)
		 {
			alert('Please Enter answer ');
			$('#pro_answer').focus();
			return false;
		 }
		 else if($('.t76:checked').length==0)
		 {
			alert('Please Select Type ');
			$('#t76').focus();
			return false;
		 }
		 else if(jQuery.trim($('#pro_address1').val()).length==0)
		 {
			alert('Please Enter address1 ');
			$('#pro_address1').focus();
			return false;
		 }
		 else if(jQuery.trim($('#town').val()).length==0)
		 {
			alert('Please Enter town ');
			$('#town').focus();
			return false;
		 }
		 else if($('#county_id').val()==0)
		 {
			  alert($('#county_id').val());
			alert('Please select County ');
			$('#county_id').focus();
			return false;
		 }
		 else if(jQuery.trim($('#post_code').val()).length==0)
		 {
			alert('Please Enter post code ');
			$('#post_code').focus();
			return false;
		 }
		 else if(jQuery.trim($('#tel').val()).length==0)
		 {
			alert('Please Enter telphone ');
			$('#tel').focus();
			return false;
		 }
		  else if(jQuery.trim($('#email').val()).length==0)
		 {
			alert('Please Enter email ');
			$('#email').focus();
			return false;
		 }
		 else if(!isValidEmailAddress(email))
			{
				alert('Please Enter valid email address ');
		 	    $('#email').focus();
			   return false;
			}
         else if($('.terms:checked').length==0 && iamlogin!='neXt')
		 {
			alert('Please accept Terms and conditions to creata a account.');
			$('#terms').focus();
			return false;
		 }
		 else
		 {
			 return true;
		 }
	});
});
