 
function slideSwitch() {
    var $active = $('#slideshow img.active');
 
    if ( $active.length == 0 ) $active = $('#slideshow img:last');
 
    var $next =  $active.next('img').length ? $active.next('img')
        : $('#slideshow img:first');
 
	var NUMS_id = $active.index();

	if(NUMS_id == '0'){
		$(".NUMS").children("div").eq(0).addClass('SEL');
	}
    $active.addClass('last-active');
	
    $next.hide();
    $next.addClass('active')
		
    $next.fadeIn(1000, function() {
	
            $active.removeClass('active');
            $active.removeClass('last-active');
			$active.hide();
			
	if(NUMS_id == '0'){
		$(".NUMS").children("div").eq(0).addClass('SEL');
	}else{
		$(".NUMS").children("div").eq(0).removeClass('SEL');
	}
	
	$(".NUMS").children("div").eq(NUMS_id+1).addClass('SEL');
	$(".NUMS").children("div").eq(NUMS_id).removeClass('SEL');
	
	if($(".NUMS").children("div.SEL").length == 0){
		$(".NUMS").children("div").eq(0).addClass('SEL');
	}

        });
}
 
$(function() {

if($.browser.webkit){
	$(window).bind('focus', function() { 	
		slide = setInterval( "slideSwitch()", 5000 );
	});	

	$(window).bind('blur', function() { 	
		clearInterval(slide);
	});		

	}
	
	$(".NUMS").children("div").eq(0).addClass('SEL');	
    slide = setInterval( "slideSwitch()", 5000 );

	$(".NUMS div").live('mouseover',function(){
		var index = $(this).index();
		if($('#slideshow img').eq(index).attr('class') != 'active'){
			$('#slideshow img').eq(index).addClass('active2');
		}
	});
	
	$(".NUMS div").live('mouseout',function(){
		//var index = $(this).index();
		//if($('#slideshow img').eq(index).attr('class') == 'active2'){
		$('#slideshow img').removeClass('active2');
		//}
	});
	
	/*
	$(".NUMS div").live('mouseover',function(){
	var index = $(this).index();
	$('#slideshow img').eq(index).css({'opacity':'1','z-index':'12'});
	});
	
	$(".NUMS div").live('mouseout',function(){
	var index = $(this).index();
	$('#slideshow img').eq(index).css({'opacity':'0','z-index':'10'});
	});
	*/
	
});

