function new_window( url ) {
	var w = window.open(url, 'previewWindow', 'width=840, height=800, status=1, menubar=0, toolbar=0, location=0, resizable=1, directories=0, scrollbars=1');
	w.focus();
	return false;
}

function new_video_window( url ) {
	var w = window.open(url, 'previewWindow', 'width=1069, height=505, status=1, menubar=0, toolbar=0, location=0, resizable=1, directories=0, scrollbars=1');
	w.focus();
	return false;
}

function shadows() {
	var offset = $('#container').offset();
	var width = $('#container').width();
	var height = $('#container').height();

	$('.shadow-left')
		.css('height', height)
		.css('left', offset.left - 40);
	$('.shadow-right')
		.css('height', height)
		.css('left', offset.left + width + 40);
}

function swap_images( current_img ) {
	$('.prop-image:not(' + current_img + ')').fadeOut(400);
	$( current_img +':hidden').fadeIn(400);
	return false;
}

animationAllowed = true;
function slideImages(slideValue) {

	slideValue = parseInt(slideValue, 10);
	var count = $('#property-thumb-container li').size();
	var gallery = $('#property-thumb-container ul');
	var offset = gallery.offset();

	if(gallery.not(':animated') && animationAllowed === true)  {
		targetLeft = parseInt(gallery.css('left'), 10) + slideValue;
		if(targetLeft <= 0 && targetLeft > count * 155 * -1) {
			animationAllowed = false;
			gallery.animate({left: targetLeft}, 1000, 'swing', function () { animationAllowed = true; });
		}
	}

}

function imageScroller() {

	$('#property-thumb-container').each(function () {

		var count = $('#property-thumb-container li').size();

		if(count > 4) {

			$(this)
				.height(100)
				.width(615)
				.css('position', 'relative');

			$('#property-thumb-container ul')
				.width(155 * count)
				.css('position', 'absolute')
				.css('left', 0);

			$(this).append('<div class="prev sprite scroller-btn" onclick="slideImages(\'620\')"></div><div class="next sprite scroller-btn" onclick="slideImages(\'-620\')"></div>');

		}


	});

}
