$(document).ready(function() {
	
	// external links popups
	$('#elsewhere a, .property #main .col a').click(function () {
		window.open($(this).attr('href'));
		return false;
	});

	// home slideshow
	$('#slideshow ul').innerfade({
		speed: 2000,
		timeout: 4000,
		containerheight: '440px'
	});

	// MAP
	
	// preloading images - function defined in plugins.js
	$.preLoadImages(
		"/img/map-suffolk.png",
		"/img/map-nassau.png",
		"/img/map-queens.png",
		"/img/map-kings.png",
		"/img/map-connecticut.png",
		"/img/map-weschester.png",
		"/img/map-manhattan.png",
		"/img/map-jersey.png"
	);

	$("#map area").hover(
		function () {
			// var url = ($(this).attr('href')).split('#')[1];
			var url = $(this).attr('id');
			var img = ("img/map-"+url+".png");
			$("#map img").attr("src", img);
		}, 
		function () {
			$("#map img").attr("src", "img/map.png");
		}
	);
	
	// columns on property page
	$(function(){
		$('.cols h4').addClass("dontend");
		$('.cols').columnize({width:270});
	});

	// property type filter
	$('#filter input').change(function() {
		var urlArray = new Array();
		if ($("#lease").prop("checked")) {
			urlArray.push('lease');
		}
		if ($("#sale").prop("checked")) {
			urlArray.push('sale');
		}
		if ($("#restaurant").prop("checked")) {
			urlArray.push('restaurant');
		}
		var filter = urlArray.join('-');
		var goback = $('#goback').html(); // can't use HTTP_REFERER because of IE
		location.href = 'http://sabreny.com/site/property-type/'+filter+'/'+goback;
	});
	
	
	
	
});
