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);
	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')) + 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>');

		}


	});

}

function swap_video(id, flvFile) {

	$('#video-container').html('<div id="video-player"></div>');

	var flashvars = {};
	flashvars.file = flvFile;
	var params = {};
	params.wmode = "transparent";
	params.allowscriptaccess = "always";
	params.allowfullscreen = 'true';
	var attributes = {};
	attributes.id = "video-player";
	swfobject.embedSWF("http://lightboxfilms.com.au/website/mediaplayer/mediaplayer.swf", "video-player", "512", "308", "7.0.0", "swf/expressInstall.swf", flashvars, params, attributes);

	var html = '';
	$.getJSON('./json_video/' + id, function(json) {
		if(json.agent != false) {
			for(var i in json.agent) {
				html = html + '<div class="video-agent">';
				html = html + '<a href="./team/' + json.agent[i].id + '">';
				html = html + '<img src="wpdata/images/' + json.agent[i].images[0].id + '-s.jpg" class="video-agent-img">';
				html = html + '</a>';
				html = html + '<table>';
				html = html + '<tbody>';
				html = html + '<tr class="phone">';
				html = html + '<th>Phone:</th>';
				html = html + '<td>' + json.agent[i].telephone + '</td>';
				html = html + '</tr>';
				html = html + '<tr class="mobile">';
				html = html + '<th>Mobile:</th>';
				html = html + '<td>' + json.agent[i].mobile + '</td>';
				html = html + '</tr>';
				html = html + '<tr class="email">';
				html = html + '<th>Email:</th>';
				html = html + '<td><a href="mailto:' + json.agent[i].email + '">' + json.agent[i].name + '</a></td>';
				html = html + '</tr>';
				html = html + '</tbody>';
				html = html + '</table>';
				html = html + '</div>';
			}
			$('#video-container')
				.addClass('left')
			
			$('#video-agents').show();
		}  else {
			$('#video-agents').hide();
			$('#video-container')
				.removeClass('left')
				.css('margin', '0 auto')
				.width(512);
		}
		$('.video-agents').html(html);
	});

	return false;


}

