// JavaScript Document


$(document).ready(function() {
	
	document.getElementById('js').value='yes';
	document.getElementById('thecaptcha').style.display='none';
	
	$("#main_other_wrapper3").hide();
	$("#main_other_wrapper2").hide();
	$("#main_other_wrapper").hide();
	
	jQuery.validator.messages.phoneUS = "";
	jQuery.validator.messages.email = "";
	jQuery.validator.messages.required = "";
	
	jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
    phone_number = phone_number.replace(/\s+/g, ""); 
	return this.optional(element) || phone_number.length > 9 &&
		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
	}, "");

	
	if($("#form_help").length > 0){
		$("#form_help").validate({
		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				var message = errors == 1
					? 'You missed 1 field. It has been highlighted above'
					: 'You missed ' + errors + ' fields.  They have been highlighted above';
				$("div.error span").html(message);
				$("div.error").show();
			} else {
				$("div.error").hide();
			}
		}
		});
	}
	
	if($("#contact_form").length > 0){
		$("#contact_form").validate({
		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				var message = errors == 1
					? 'You missed 1 field. It has been highlighted above'
					: 'You missed ' + errors + ' fields.  They have been highlighted above';
				$("div.error span").html(message);
				$("div.error").show();
			} else {
				$("div.error").hide();
			}
		}
		});
	}
	
	$("#mydropdown").change(function(){
		if($('#other3:selected').length){
			$("#main_other_wrapper3").show();
		}
		else
		{
			$("#main_other_wrapper3").hide();
		}
		
		
	});
	
	$("#interested").change(function(){
		if($('#other2:selected').length){
			$("#main_other_wrapper2").show();
		}
		else
		{
			$("#main_other_wrapper2").hide();
		}
		
		
	});
	
	$("#like_to").change(function(){
		if($('#other:selected').length){
			$("#main_other_wrapper").show();
		}
		else
		{
			$("#main_other_wrapper").hide();
		}
		
		
	});
	
	

	
	
	
	$("#form_help #fname").focus(function(){
		if($("#form_help #fname").val() == "First Name"){
			$("#form_help #fname").val("");	
		}
	});
	
	$("#form_help #lname").focus(function(){
		if($("#form_help #lname").val() == "Last Name"){
			$("#form_help #lname").val("");	
		}
	});
	
	$("#form_help #phone").focus(function(){
		if($("#form_help #phone").val() == "Phone"){
			$("#form_help #phone").val("");	
		}
	});
	
	$("#form_help #email").focus(function(){
		if($("#form_help #email").val() == "e-Mail"){
			$("#form_help #email").val("");	
		}
	});
	
	$("#form_help #agency").focus(function(){
		if($("#form_help #agency").val() == "Agency"){
			$("#form_help #agency").val("");	
		}
	});
	
	$("#form_help #county").focus(function(){
		if($("#form_help #county").val() == "County"){
			$("#form_help #county").val("");	
		}
	});
	
	$("#form_help #state").focus(function(){
		if($("#form_help #state").val() == "State"){
			$("#form_help #state").val("");	
		}
	});
	
	$("#form_help #more").focus(function(){
		if($("#form_help #more").val() == "Tell us more:"){
			$("#form_help #more").val("");	
		}
	});
	
	
	
	
	
	$("#form_help #fname").blur(function(){
		if($("#form_help #fname").val() == ""){
			$("#form_help #fname").val("First Name");	
		}
	});
	
	$("#form_help #lname").blur(function(){
		if($("#form_help #lname").val() == ""){
			$("#form_help #lname").val("Last Name");	
		}
	});
	
	$("#form_help #phone").blur(function(){
		if($("#form_help #phone").val() == ""){
			$("#form_help #phone").val("Phone");	
		}
	});
	
	$("#form_help #email").blur(function(){
		if($("#form_help #email").val() == ""){
			$("#form_help #email").val("e-Mail");	
		}
	});
	
	$("#form_help #agency").blur(function(){
		if($("#form_help #agency").val() == ""){
			$("#form_help #agency").val("Agency");	
		}
	});
	
	$("#form_help #county").blur(function(){
		if($("#form_help #county").val() == ""){
			$("#form_help #county").val("County");	
		}
	});
	
	$("#form_help #state").blur(function(){
		if($("#form_help #state").val() == ""){
			$("#form_help #state").val("State");	
		}
	});
	
	$("#form_help #more").blur(function(){
		if($("#form_help #more").val() == ""){
			$("#form_help #more").val("Tell us more:");	
		}
	});
		
		
		
	
	
	if($("#form_help").length >0){
		$("#form_help").validate();
	}
	
	
		
	
	
});


