/*
***************************************************************************
**  Splash.js
**  TJ OConnor
**  08/06/2010
***************************************************************************
*/

/* Number of seconds for each panel */
var intSeconds = 6;



var intRotator = 0;
$(function(){
	
	// DOM is ready
	$('#splash-counter').val(-1);
    showPanel(1);
    rotate_start();
	
});

function nextPanel() {
    var maxNum = Number($('#splash-total').val());    
    var n = Number($('#splash-counter').val());    
    if (n == maxNum)    
        showPanel(1);
    else {        
        showPanel(n + 1);
    }
}
function rotate_start() {
    intRotator = setInterval(nextPanel, intSeconds * 1000);
}
function rotate_stop() {
    clearInterval(intRotator);
}
function clickPanel(pNum) {
    rotate_stop();
    showPanel(pNum);
}
function showPanel(pNum){
    if ($('#splash-counter').val() != pNum) {

		// Update counter
        $('#splash-counter').val(pNum);							
		
		// Hide panels
		$('#splash-panels > div').hide();
		
		// Remove selected links
		$('#splash-links > a').removeClass('selected');
		
		// Show panel
		$("#splash-" + pNum).fadeIn("slow");
		
		// Add selected link
		$("#splash-link-" + pNum).addClass('selected');	
	}
}