$(function(){
    $('.sliders').slidify();
   	$(".full-search .sqft-sliders").slidify({
		max:6000,
		min:1000,
		stepping:100,
		unit: 'square foot',
		units: 'square feet'
	});
	//shorten units for sidebar search
	$("#side .sqft-sliders").slidify({
		max:6000,
		min:1000,
		stepping:100,
		unit: 'sq ft',
		units: 'sq ft'
	});
	$(".acreage-sliders").slidify({
		max:100,
		stepping:1,
		unit: 'acre',
		units: 'acres'
	});
   
	$('.hidden').hide();
	$('#message').fadeOut(3500);
	$('a.new-window').click(function(){
		window.open(this.href);
		return false;
	});

	$('.toggle').click(function(){
	    $('#' + this.id + '-toggle').slideToggle();
		return false;
	});

	$('.subscribe-form').submit(function() {
		$('.subscribe-form .submit').hide();
		$('.subscribe-form p.notes').html('<img id="loading" src="'+staticURL+'/img/loading.gif" /><br />');
		input = {
		    name : $(this).find('input[name=name]').val(),
		    email : $(this).find('input[name=email]').val()
		};
		$.post(this.action, input, function(data){
			$('#loading').remove();
			if ( data == 'True') {
				$('.subscribe-form').replaceWith('<p>You have successfully subscribed. Please check your email for more details.</p>');
			}
			else {
				$('.subscribe-form p.notes').empty();
				$('.subscribe-form p.notes').append('<div class="error">There was an error entering your subscription.<br />Please be sure you have entered both your <em>name</em> and a valid <em>email</em> address</div>');
				$('.subscribe-form .submit').show();
			}
		});
		return false;
	});

	$('.check-all').click(function(){
		$(this).parents('fieldset').find('input').each(function(){
			this.checked = true;
		});
		return false;
	});
	$('.check-none').click(function(){
		$(this).parents('fieldset').find('input').each(function(){
			this.checked = false;
		});
		return false;
	});
});