

/* SITE SPECIFIC JAVASCRIPT */

$(document).ready(function() {
	 $('.datepicker').datePicker({clickInput:true,createButton:false,showYearNavigation:false});
	$('#datefrom').bind(
		'dpClosed',
		function(e, selectedDates)
		{
			var d = selectedDates[0];
			if (d) {
				d = new Date(d);
				$('#dateto').dpSetStartDate(d.addDays(0).asString());
			}
		}
	);
});


$(document).ready(function() {
	 $("label.infield").inFieldLabels({ 
	 					fadeOpacity:0.2,
	 					fadeDuration:200 
	 					}); 
});


//initialize colorbox
$(document).ready(function(){
	$("a[rel='colorbox']").colorbox();
});

//initialize pikachoose image gallery
$(document).ready(
				function (){
					$("#pikame").PikaChoose();

					$("#pikame").jcarousel({scroll:4,
						vertical:true,					
						initCallback: function(carousel) 
						{
					        $(carousel.list).find('img').click(function() {
					            carousel.scroll(parseInt($(this).parents('.jcarousel-item').attr('jcarouselindex')));
					        });
					    }
				    });

				});



				
function searchDisplaySale(){
	document.forms['search'].status.value = "sale";
	document.forms['search'].price.options.length = 0;
	document.forms['search'].price.options[0] = new Option("Any Price Range", "0", false)
	document.forms['search'].price.options[1] = new Option("0 - 100,000", "0-100000", false);
	document.forms['search'].price.options[2] = new Option("100,000 - 200,000", "100000-200000", false);
	document.forms['search'].price.options[3] = new Option("200,000 - 300,000", "200000-300000", false);
	document.forms['search'].price.options[4] = new Option("300,000 - 400,000", "300000-400000", false);
	document.forms['search'].price.options[5] = new Option("400,000 - 500,000", "400000-500000", false);
	document.forms['search'].price.options[6] = new Option("500,000 - 600,000", "500000-600000", false);
	document.forms['search'].price.options[7] = new Option("600,000 - 800,000", "600000-800000", false);
	document.forms['search'].price.options[8] = new Option("800,000 - 1,000,000", "800000-1000000", false);
	document.forms['search'].price.options[9] = new Option("1,000,000+", "1000000-100000000", false);
}

function searchDisplayRent(){
	document.forms['search'].status.value = "rent";
	document.forms['search'].price.options.length = 0;
	document.forms['search'].price.options[0] = new Option("Any Price Range", "0", false);
	document.forms['search'].price.options[1] = new Option("0 - 200", "0-200", false);
	document.forms['search'].price.options[2] = new Option("200 - 350", "200-350", false);
	document.forms['search'].price.options[3] = new Option("350 - 500", "350-500", false);
	document.forms['search'].price.options[4] = new Option("500 - 700", "500-700", false);
	document.forms['search'].price.options[5] = new Option("700 - 1,000", "700-1000", false);
	document.forms['search'].price.options[6] = new Option("1,000+", "1000-1000000000", false);

}

function updateSearchPriceOptions(){
	var pstatus = $("#status").val();

	if ( pstatus =='sale') {
		searchDisplaySale();
	}
	if ( pstatus =='rent') {
		searchDisplayRent();
	}
}

$(document).ready(function(){
	updateSearchPriceOptions();
	$('#status').change(function(){
		updateSearchPriceOptions();
	});
});
