$().ready(function() {
	// validate signup form on keyup and submit
	$('#submitbtn').click(function(){
	
		$('#surveyForm').submit();
	
		
	});
	
	$.validator.addMethod("captcha", function(value, element) {
		var key = value;
		queryparams = {"key":key};
		$.post("http://www.statanesthesia.com/survey/keycheck.php",queryparams,
			function(response){		   
			$('#ResponseVal').val(response)
		});
		var response = $('#ResponseVal').val();
		if(response == 1)
		{
			$('#errormsg').html('');
			return true;
		}
		else
		{
			$('#errormsg').html('Invalid Captcha Code!');
			return false;
		}
},"" );
	
	$("#surveyForm").validate({
		rules: {			
			Date: "required",
			Doctor_name: {
				required: true
			},
			key: "captcha"
		},
		messages: {			
			Date: "Please select date",
			Doctor_name: {
				required: "Please enter doctor name"
			},
			key: ""
		}
	});
	
	$('#typeOther').click(function(){
		$('#type_of_practitioner_other').show();
	});
	$('.typeradio').click(function(){
		$('#type_of_practitioner_other').hide();
		$('#type_of_practitioner_other').val('');
	});
	
	$('#surveyOther').click(function(){
		$('#surveyFor_other').show();
	});
	$('.surveyradio').click(function(){
		$('#surveyFor_other').hide();
		$('#surveyFor_other').val('');
	});
	
	
});
