var theInt = null;
$(function(){
	t(0);
	$(".small").mouseover(function(){
		if($('.bigpic img').attr('src') == $(this).find("img").attr('src')) return;
		if(!$(this).is(':animated')){
			t($(".small").index($(this)));
		}
	})
	$("#play_next").click(function(){
		if(!$(this).is(':animated')){
			i=$(".small").index($(".greenon"));
			i++;
			if (i > $('.small').length - 1) {i = 0};
			t(i);
		}
	})
	$("#play_prev").click(function(){
		if(!$(this).is(':animated')){
			i=$(".small").index($(".greenon"));
			i--;
			if (i < 0) {i = $('.small').length - 1};
			t(i);
		}
	})
})
t = function(i){
	clearInterval(theInt);
	if( typeof i != 'undefined' )
		$(".small img").css({"opacity":"0.6"}).eq(i).css({"opacity":"1"});
		$(".small").removeClass("greenon").eq(i).addClass("greenon");
		$(".bigpic img").hide();
		$('.bigpic img').fadeIn(200).attr('src',$('.small img').eq(i).attr('src'));
	theInt = setInterval(function (){
		i++;
		if (i > $('.small').length - 1) {i = 0};
		$(".small img").css({"opacity":"0.6"}).eq(i).css({"opacity":"1"});
		$(".small").removeClass("greenon").eq(i).addClass("greenon");
		$(".bigpic img").hide();
		$('.bigpic img').fadeIn(200).attr('src',$('.small img').eq(i).attr('src'));
	},8000)
}
