// JavaScript Document

/*
 * Carousel script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Stefan Isfeld 
 * 
 *
 */


// initalize
var panelcount = 0;		// Which panl is being displayed
var lastPanel = 2;		// How may panels are thre in total
var carouselTimer;		// Timer id

$(document).ready(function(){
	/* CONFIG */
	$(".carousel:first").css( {"display":"block"} );
	carouselTimer = setTimeout ( "nextpanel()", 3000 );
	/* CONFIG */
	
	// Carousel Button rollover
	$(".carouselB").mouseover(function() {
		$(this).css( {"border":"yellow 2px solid"} );
		whichId = parseInt( $(this).attr("id").substring( $(this).attr("id").lastIndexOf("_")+1 , $(this).attr("id").length) );
		panelcount = whichId;
		$( ".carousel" ).css( {"display":"none"} );
		$(".carousel:eq("+panelcount+")").fadeIn();
		
		clearTimeout ( carouselTimer );
		}).mouseout(function() {
			$(this).css( {"border":"#000 2px solid"} );
			carouselTimer = setTimeout ( "nextpanel()", 3000 );
			});

});

function nextpanel() {
	$( ".carousel" ).css( {"display":"none"} );
	
	if (panelcount == lastPanel) {
		lastPanel = panelcount;
		panelcount = 0;
	} else {
		panelcount = panelcount + 1;
	}
	$(".carousel:eq("+panelcount+")").fadeIn();
	carouselTimer = setTimeout ( "nextpanel()", 3000 );
}
