$(document).ready(function(){
	/* old
	$('#slider').css({display: 'block'});
	setInterval( "slideSwitch()", 5000 );
	*/
	
	$(window).load( function() {
		$('#slider').css({display: 'block'});
		if($('#slider > img').size() > 1){
			$('#slider img:first').addClass('active');
			setTimeout("slideSwitch()", 1000);
			setTimeout("setInterval(\"slideSwitch()\", 4000 )", 1000);
		}
	});	

});

function slideSwitch() {
    var $active = $('#slider img.active');
    if ( $active.length == 0 ) $active = $('#slider img:last');
	var $next =  $active.next().length ? $active.next() : $('#slider img:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 2000, function() {
            $active.removeClass('active last-active');
    });
}
