// JavaScript Document
function imageRotator() {
	$('div#home_image > img').css({"position" : "absolute","opacity" : "0.0", "z-index" : "0"});
	$('div#home_image > img:first').css({"opacity" : "1.0", "z-index" : "1"}).addClass('show');
	$("div#strip img:first").addClass("selected");
	$("div#strip h1").text($("div#strip img:first").attr("alt"));
	$("div#strip a").text($("div#strip img:first").attr("name"));
	$("div#strip a").attr("href",$("div#strip img:first").attr("id"));
	setInterval('rotate()',6000);
}
function rotate() {	
	var current = ($('div#home_image > img.show') ?  $('div#home_image > img.show') : $('div#home_image > img:first'));
 	var next = ((current.next("img").length) ? ((current.next("img").hasClass('show')) ? $('div#home_image > img:first') : current.next()) : $('div#home_image > img:first'));	
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 3000);
 	current.animate({opacity: 0.0}, 3000)
	.removeClass('show').dequeue();
	var current = ($('div#strip > img.selected') ?  $('div#strip > img.selected') : $('div#strip > img:first'));
 	var next = ((current.next("img").length) ? ((current.next("img").hasClass('selected')) ? $('div#strip > img:first') : current.next()) : $('div#strip > img:first'));
	current.removeClass("selected");
	next.addClass("selected");
	$("div#strip h1").css({opacity: 0.0}).text(next.attr("alt")).animate({opacity: 1.0}, 1000);
	$("div#strip a").css({opacity: 0.0}).text(next.attr("name")).animate({opacity: 1.0}, 1000);
	$("div#strip a").attr("href",next.attr("id"));
};
$(function() {		
	$('div#strip').css({"z-index" : "2"});
	imageRotator();
	$("div#strip img").click(function(){
		$('div#home_image > img').css({"position" : "absolute","opacity" : "0.0", "z-index" : "0"}).removeClass('show').stop();
		$("div#strip img").removeClass("selected");
		$(this).addClass("selected");
		$("div#strip h1").css({opacity: 0.0}).text($(this).attr("alt")).animate({opacity: 1.0}, 1000);
		$("div#strip a").css({opacity: 0.0}).text($(this).attr("name")).animate({opacity: 1.0}, 1000);
		$("div#strip a").attr("href",$(this).attr("id"));
		$("div#home_image > img[alt$='"+$(this).attr("alt")+"']").css({"position" : "absolute","opacity" : "1.0", "z-index" : "1"}).addClass('show');
	});
});
