var currentImage;
    var currentIndex = -1;
    var interval;
    var pause = false;
    function showImage(index){
        if(index < $('#brand_big_images .brand_big_image').length){
        	var indexImage = $('#brand_big_images .brand_big_image')[index]
            	if(currentImage != indexImage ){
                    $(currentImage).css('z-index',2);
                    clearTimeout(myTimer);
                    $('#brand_big_images .brand_big_image').each(function(){
                    	   $(this).stop(false,true);
                    })
                    myTimer = setTimeout("showNext()", 3000);
                    $(currentImage).fadeOut(500, function() {
					    $(this).css({'display':'none','z-index':1})
					});
                }
            $(indexImage).css({'display':'block', 'opacity':1});
            currentImage = indexImage;
            var src;
            if(currentIndex >=0){
            	   src =  $('#brand'+(currentIndex+1)).attr('src');
            	   src = src.replace('selected', 'unselected');
               $('#brand'+(currentIndex+1)).attr('src',src);
            }
            currentIndex = index;
            src = $('#brand'+(currentIndex+1)).attr('src');
            src = src.replace('unselected', 'selected');
            $('#brand'+(currentIndex+1)).attr('src',src);
        }
    }
    
    function showNext(){
    	    if(pause){
    	      	myTimer = setTimeout("showNext()", 1000);
    	      	return;
    	    }
        var len = $('#brand_big_images .brand_big_image').length;
        var next = currentIndex < (len-1) ? currentIndex + 1 : 0;
        showImage(next);
    }
    
    var myTimer;
    
    $(document).ready(function() {
     	$('#brand_big_images .brand_big_image').each(function(){
     		$(this).hover(function(){pause=true;}, function(){pause=false;});
     	});
	    myTimer = setTimeout("showNext()", 3000);
		showNext(); //loads first image
        $('#home_right_menu li').bind('mouseover',function(e){
        	var count = $(this).attr('rel');
        	showImage(parseInt(count)-1);
        });
	});
    

    

