$(document).ready(function() {
	// $.validator.addMethod("phoneUS", function(phone_number, element) {
	// 	var phone2 = /^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/; 
	// 	return phone_number.match(phone2);
	//     /*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}$/);*/
	// }, "Please specify a valid phone number");

	$("#contact-us-form").validate({
		// rules: {
		// 	entry_phone: "phoneUS"
		// },
		errorPlacement: function(error) {
			//error.hide();
		},
		highlight: function(element) {
			if ($('#entry_subject').val() == 'rent') {
				switch ( $(element).attr('id') ) {
					case 'bedrooms2': $('#custom-select-replaced-bedrooms2').css({'border': '1px solid #961711'}); break;
					case 'price2': $('#custom-select-replaced-price2').css({'border': '1px solid #961711'}); break;
					case 'move-in2': $('#custom-select-replaced-move-in2').css({'border': '1px solid #961711'}); break;
					case 'entry_state': $('#custom-select-replaced-entry_state').css({'border': '1px solid #961711'}); break;
					case 'entry_country': $('#custom-select-replaced-entry_country').css({'border': '1px solid #961711'}); break;
					default: $(element).attr('style', 'border: 1px solid #961711;'); break;
				}
			}
		},
		unhighlight: function(element) {
			if ($('#entry_subject').val() == 'rent') {
				switch ( $(element).attr('id') ) {
					case 'bedrooms2': $('#custom-select-replaced-bedrooms2').css({'border': '0px none transparent'}); break;
					case 'price2': $('#custom-select-replaced-price2').css({'border': '0px none transparent'}); break;
					case 'move-in2': $('#custom-select-replaced-move-in2').css({'border': '0px none transparent'}); break;
					case 'entry_state': $('#custom-select-replaced-entry_state').css({'border': '0px none transparent'}); break;
					case 'entry_country': $('#custom-select-replaced-entry_country').css({'border': '0px none transparent'}); break;
					default: $(element).attr('style', 'border: 0px none transparent;'); break;
				}
			}
		}
	});

	$("#contact-us-jobs-form").validate({
		errorPlacement: (function(error) {
			error.hide();
		}),
		highlight: (function(element) {
			$(element).attr('style', 'border: 1px solid #961711;');
		})
	});

	$("#contact-us-suites-form").validate({
		errorPlacement: (function(error) {
			error.hide();
		}),
		highlight: (function(element) {
			$(element).attr('style', 'border: 1px solid #961711;');
		})
	});

	$("#contact-us-partners-form").validate({
		errorPlacement: (function(error) {
			error.hide();
		}),
		highlight: (function(element) {
			$(element).attr('style', 'border: 1px solid #961711;');
		})
	});
	
	$("#entry_subject").change(function() {
		$("#content .right-flow").removeClass("rent-contact-form");
		$(".contact-subjects:not(.contact-" + $(this).val() + ")").slideUp();
		$(".contact-" + $(this).val()).show();

		// console.log($(this).val());

		$("#entry_city, #entry_state, #entry_country, #bedrooms2, #price2, #move-in2").removeClass("required");

		switch ( $(this).val() ) {
			case "testimonial": 
			$("#comments-label").html("Testimonial");
				break;
			case "rent":
//				var currentHeight = parseInt($("#content .right-flow").css("height"));
//				$("#content .right-flow").css("height", (currentHeight + 50) + "px");
				$("#content .right-flow").addClass("rent-contact-form");
				$("#entry_city, #entry_state, #entry_country, #bedrooms2, #price2, #move-in2").addClass("required");
				break;
			case "visit":	
				$("#entry_city, #entry_state, #entry_country, #bedrooms2, #price2, #move-in2").addClass("required");
				break;
				
			}

		if ($(this).val() != "testimonial") {
			$("#comments-label").html("Comments");
		}
			
	}).change();

	$('#schedule-visit-link').attr('style', 'color: #F3F1D9;')
	$('#contact-us-link').addClass('on');

//	$("#neighborhood-select-contact-form")
	$('#neighborhood-select-contact-form li.first-child').live('click', function(e) {
		$('#neighborhood-select-contact-form li:not(.first-child)').find('input').each(function(count){
				this.checked = false;$(this).next('div').removeClass('checked');
		});
	});
	$('#neighborhood-select-contact-form li:not(.first-child)').live('click', function(e){
		$('#neighborhood-select-contact-form li.first-child').find('input').each(function(count){
				this.checked = false;$(this).next('div').removeClass('checked');
		});
	});
});

