/*
*************************************************

DM SLIDER
JavaScript Functions
Requires jQuery

Created by Dan Mall
http://danielmall.com/

*************************************************
*/


/*-------------------------------------------    
    Global Variables
-------------------------------------------*/
var TIMING = 6000;    
var _currentImage = 0;
var _totalImages;



/*-------------------------------------------    
    Initial Actions
-------------------------------------------*/

function init() {

    initSlider();

}

// this runs EVERYTHING
$(document).ready(function() { init(); });



/*-------------------------------------------    
    Custom Functions
-------------------------------------------*/

function initSlider(){
    
    _totalImages = $('#header ul li').size();
    
    //$('#header ul li .info, #header ul li .carousel-image').hide();   
    //$('#header ul li:eq(0) .info, #header ul li:eq(0) .carousel-image').show();   
    setInterval( "switchImage()", TIMING );
	
}

function switchImage(){
    
    $('#header ul li').eq(_currentImage).find('.carousel-image, .info').fadeOut('slow');
    
    if(_currentImage == (_totalImages-1)){
        _currentImage = 0;
    }else{
        _currentImage++;
    } 
    
    $('#header ul li').eq(_currentImage).find('.carousel-image, .info').fadeIn('slow');     
    
}
