var totalImages		= 16;
var currentImage	= 0;
var slideShowSpeed	= 1000 * 8;
var imgPath			= 'images/gallery/';
var timer;


function changeImage() {
	if (currentImage >= totalImages) {
		currentImage = 0;
	}
	$('#img' + (currentImage+1)).trigger('mouseover');
}

$(document).ready(function(){
	
	$("#sbr_image_thumbs a").mouseover(function(){
		
		$("#gallPlaceholder img").hide().attr({"src": imgPath + $(this).attr("rel"), "title": $("> img", this).attr("title")});
		currentImage = parseInt(this.id.replace('img',''));
		
		$("#sbr_image_thumbs a").removeClass('imgSelected');
		$(this).addClass('imgSelected');
		
		clearTimeout(timer);
		timer = setTimeout('changeImage();', slideShowSpeed);
		
		return false;
	}); 

	$("#gallPlaceholder>img").load(function(){$("#gallPlaceholder>img:hidden").fadeIn("slow")});
	
	changeImage();
});