$(document).ready(function(){

	setInterval( "slideSwitch()", 20000 );

	$('#hpSlides').hoverIntent( function() {
		$('#hpSlides span').animate({opacity: 1}, 1000);
	}, function() {
		$('#hpSlides span').animate({opacity: 0}, 1000);
	});
		
});

function slideSwitch() {

    var $active = $('#hpSlides li.active');
    var $next = $active.next();

    if ( $active.length == 0 ) $active = $('#hpSlides li:last');

    var $next =  $active.next().length ? $active.next()
        : $('#hpSlides li:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
        
}

