var IE7 = (navigator.appVersion.indexOf('MSIE 7.') != -1 );
var IE6 = (navigator.appVersion.indexOf('MSIE 6.') != -1 );
var t;
var n = 1;

$(function() {
	$("#galleryLayout span:even").addClass("thumb");
	$("#galleryLayout span:odd").addClass("image").hide();
	t = setTimeout("play()", 1000);
});

function nplus() {
	if (n>=24) { n = 1; } else { n++; }
	play();
}

function play() {

	
	$(".thumb").not('#'+"thumb"+n).stop().fadeTo(1000, 0.4).css({'background-color' : '#ffffff'}).end().filter('#'+"thumb"+n).stop().fadeTo(1000, 1.0).css({'background-color' : '#000000'});
	if (IE7 || IE6) {
		$("span.image:visible").stop().fadeOut(1000, function() {this.style.removeAttribute('filter'); });
		$('#'+"image"+n).stop().fadeIn(1000, function() {this.style.removeAttribute('filter'); });
	} else {
		$("span.image:visible").stop().fadeOut(1000);
		$('#'+"image"+n).stop().css({'opacity' : '1.0'}).fadeIn(1000);
	}
	t = setTimeout("nplus()", 3000);
}

$(function() {
	$(".thumb").hover(function() {
		clearTimeout(t);
		$(".thumb").not(this).stop().fadeTo(1000, 0.4).css({'background-color' : '#ffffff'});
		$(this).stop().fadeTo(1000, 1.0).css({'background-color' : '#000000'});
		if (IE7 || IE6) {
			$("span.image:visible").stop().fadeOut(1000, function() {this.style.removeAttribute('filter'); });
			$(this).next().stop().fadeIn(1000, function() {this.style.removeAttribute('filter'); });
		} else {
			$("span.image:visible").stop().fadeOut(1000);
			$(this).next().stop().css({'opacity' : '1.0'}).fadeIn(1000);
		}
	},function(){
		play();
	});
});
