/*
Image Navigation plugin 1.0
Hiroshi Sato,2010
http://net-king.com
*/
(function($) {

         function imageNavigationSlide(option) {
             var $active = $('.navi-image img.active', option.elem);
             if ( $active.length == 0 ) $active = $('.navi-image img:last', option.elem);
             var $next =  $active.next().length ? $active.next() : $('.navi-image img:first' ,option.elem);
             $active.addClass('last-active');
             var $active_navi = $(".navi ."+ $active.attr("rel") +"", option.elem); 
             var $next_navi = $(".navi ."+ $next.attr("rel") +"", option.elem); 

             $active_navi.removeClass("active");
             $next_navi.addClass("active");
             rolloverImage_chenge(option);
             $next.css({opacity: 0.0})
                 .addClass('active')
                 .animate({opacity: 1.0}, option.animationTime, function() {
                     $active.removeClass("active last-active");
                 });
         }
         function startInterval(option){
             if(option.autoPlay) imageNavigationID = setInterval(function(){ imageNavigationSlide(option) }, option.time );
         }

		 function rolloverImage_chenge(option){
             $(".navi img.active img.over", option.elem).stop().fadeTo(option.rolloverTime,1);
             $(".navi img:not(.active) img.over", option.elem).stop().fadeTo(option.rolloutTime,0);
         }

$.fn.imageNavigation = function(option) {
             //init
             option = $.extend({
               elem:this,
               time: 3500,
               animationTime: 1000,
               autoPlay: true,
               rolloverImage: true,
               rolloverTime: 10,
               rolloutTime: 800
             }, option);
             var $active = $('.navi-image img.active', option.elem);
             if ( $active.length == 0 ) {
               $active = $('.navi-image a:first', option.elem);
               $active.addClass("active");
               $(".navi a:first", option.elem).addClass("active");
             }

             startInterval(option);
             
             if(option.rolloverImage){
               $(".navi", option.elem).hover(function(){
               },function(){
                 //$("img.active img.over", this).stop().css({opacity: 1.0});
                 rolloverImage_chenge(option);
               });
             }
			 
}

})(jQuery);
(function($) {
 $(function(){
        $("#image-navigation").imageNavigation();
      });
})(jQuery);

