jQuery.validator.setDefaults({
	debug: false,
	success: "valid"
});


$(document).ready(function(){

    jQuery.validator.addMethod("custom_country", function(value, element) {
		 return (value == "") ? false : true;
	}, "Please make a selection");




	
    $("#f_information").validate({

  rules: {
    email: {
      required: true,
      email: true
    },
	
	firstname: {
      required: true,
      username: true
    },
	lastname: {
      required: true,
      username: true
    },
	company:{
		required: true
		
	},
	telephone: {
      required: true,
      telephone:true
    },
	request:{
		required: true,
		request:true
	},
	
	comments: {
      required: true,
      minlength:5,
	  maxlength:600
    },


	city:{
		required: true
	},
	country:{
	 custom_country: true
	},
	hearabtus:{
		required: true,
		request:true
	},
	zipcode:{
		maxlength:8
	},
	security_code:{
		required: true,
		security_code:true		

	}
  },
	submitHandler: function(form){
					var valid = validateCaptcha('/solar/check-captcha.php', "security_code");					
					if ( eval(valid) == true ) {  form.submit(); }
					else { //$(".captchaErr").show(); 
					alert("Invalid Verification Code. Please enter the code as shown in the box"); 
					$("#security_code").focus(); return "no"; }					
				}
});


function validateCaptcha (chkUrl, cCode) {
			qdata	=	$('#'+cCode).val();
			return	$.ajax({ type: 'GET', url: chkUrl, data: 'security_code='+qdata, cache: false, async: false}).responseText;
		}


   
});
