$(document).ready(function() {

var rate = 300;	
var imageWidth = 1024;
var imageHeight = 768;
	
	$(window).resize(function(){
		_resize_image();
	});
	
	_resize_image();
	_initialise_slideshow();
	
function _resize_image() { 
		var navWidth = $(window).width();
		var navHeight = $(window).height();
		var navRatio = navWidth / navHeight;
		imageRatio = imageWidth / imageHeight;
		if (navRatio > imageRatio) {
			var newHeight = (navWidth / imageWidth) * imageHeight;
			var newWidth = navWidth;
		} else {
			var newHeight = navHeight;
			var newWidth = (navHeight / imageHeight) * imageWidth;
		}	
		
		//sy = parseInt($('#slideshow').css("top").substr(0,$('#slideshow').css("top").length-2));
		newTop = 0 - ((newHeight - navHeight) / 2);
		newLeft =  0 - ((newWidth - navWidth) / 2);
		$('#slideshow').css({height: navHeight, width: navWidth});
		$('#slideshow img').css({height: Math.floor(newHeight), width: Math.floor(newWidth), top: newTop, left: newLeft});
		$('#slideshow').css({visibility:"visible", display:"block"});
	};

function _initialise_slideshow() {
	$('#slideshow img:first').fadeIn(rate, function() {	
	$('#slideshow').cycle({
		fx: 'scrollHorz',
		timeout: 0,
		speed: rate,
		containerResize: false,
		next: '.pager, .next, #slideshow', 
		prev: '.pager, .prev',
		after: _set_total_pics,
	});
	});
}	
	
});
/* document.ready End
*************************************************************/		
	
