(function($) {
    
    $.fn.slideShow = function(opts) {
        
        if (opts) {$.extend(conf, opts);}
        
        var showcaseItems = $('li','#slides', this);                
            currentIndex = 0,
            showcaseItemsLength = showcaseItems.length,
            nav = '',
            obj = this;
        
        //add pagination
        for(i=0; i<showcaseItemsLength; i++) {
            nav += '<li><a href="#">item' + i + '</a></li>\n';
        }        
        $(this).prepend('<ul id="slide-nav">' + nav + '</ul>');
        
        //set opacity
	// if(!($('html').hasClass('lt-ie9'))){
	// 	    $(this).fadeTo(0, .75);
	// 	}
        // $(this).hover(
        //             function() {
        //                 $(this).fadeTo(0, .75);        
        //             },
        //             function() {
        //                 $(this).fadeTo(0, 1);
        //             }
        //         );
            
        var triggerTimer = function() {
            if((currentIndex + 1) >= showcaseItemsLength) currentIndex = -1;            
            $('a', '#slide-nav').eq(currentIndex + 1).click();
        };
        
        var timer = setInterval(triggerTimer, 12000);    
       
        $('a', '#slide-nav').click(function() {
            
            clearTimeout(timer);
            timer = setInterval(triggerTimer, 12000);
            
            $('a', '#slide-nav').eq(currentIndex).removeClass('active');
            
            currentIndex = $(this).parent().index();            
            $(this).addClass('active');
           
            var showcaseItem = showcaseItems.eq(currentIndex);
                color = showcaseItem.data('color');
            
            showcaseItems.stop(true, true).hide();
            showcaseItem.stop(true, true).fadeIn();
        }).first().click();
    };
    
})(this.jQuery);
