$(document).ready(function(){



	$('#send').click(function(){
				
		var captcha=$('#recaptcha_response_field').val();
		var challenge = $('#recaptcha_challenge_field').val();
		var lname=$('#lname').val();
		var fname=$('#fname').val();
		var message=$('#message').val();
		var mail=$('#mail').val(),
			vmail = $('#vmail').val();
		var count = 0,
			atime = $('#atime').val(),
			dtime = $('#dtime').val(),
			date = $('#date').val();
		
		
		if (date==""){
		$('#date1').html("<font color='#FF0000'><strong>Can't be empty</strong> </font>");
		count++;
		}else{
		$('#date1').html("");
		}
		
		if (atime==""){
		$('#atime1').html("<font color='#FF0000'><strong>Can't be empty</strong> </font>");
		count++;
		}else{
		$('#atime1').html("");
		}
		
		if (dtime==""){
		$('#dtime1').html("<font color='#FF0000'><strong>Can't be empty</strong> </font>");
		count++;
		}else{
		$('#dtime1').html("");
		}
		
		if (lname==""){
		$('#name2').html("<font color='#FF0000'><strong>Can't be empty</strong> </font>");
		count++;
		}else{
		$('#name2').html("");
		}
		
		if (fname==""){
		$('#name1').html("<font color='#FF0000'><strong>Can't be empty</strong> </font>");
		count++;
		}else{
		$('#name1').html("");
		}
		
		if (message==""){
		$('#message1').html("<font color='#FF0000'><strong>Can't be empty</strong> </font>");
		count++;
		}else{
		$('#message1').html("");
		}
		
		if (mail==""){
		$('#mail1').html("<font color='#FF0000'><strong>Can't be empty</strong> </font>");
		count++;
		}else{
		$('#mail1').html("");
		}
		
		if (vmail==""){
		$('#vmail1').html("<font color='#FF0000'><strong>Can't be empty</strong> </font>");
		count++;
		}
		
		if (captcha==""){
		$('#check').html("<font color='#FF0000'><strong>Can't be empty</strong> </font>");
		count++;
		}else{
		$('#check').html("");
		}
		
		if (mail!=""){
			if (validate('mail') != false){
				if (vmail!=""){
					if (vmail!=mail){
					$('#vmail1').html("<font color='#FF0000'><strong>Doesn't match your email</strong> </font>");
					count++;
					}else{
					$('#vmail1').html("");
					}
				} else {
					$('#vmail1').html("<font color='#FF0000'><strong>Can't be empty</strong> </font>");
					count++;
				}
			} else {
				$('#mail1').html("<font color='#FF0000'><strong>Please type a valid e-mail address.</strong> </font>");
				count++;
			}
		}else{
			$('#mail1').html("<font color='#FF0000'><strong>Can't be empty</strong> </font>");
			count++;
		}
		
		
		

	
	if (count==0){
		
		$.post("verify.php",{captcha:captcha, challenge:challenge},function(data){
		//alert(data)
			if (data==1)
				$("form:first").submit();
			else
				$('#check').html("<font color='#FF0000'><strong>Wrong! Try again!!</strong> </font>");	
		});
		//$("form:first").submit();
	}
	
	return false;
	});

});

function validate(email) {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = $('#'+email).val();
   if(reg.test(address) == false) {
      return false;
   }
}


