/**
 * @compagny : Archriss, web agency & ingénérie
 * @website : www.archriss.fr
 * @author : Jean-Philippe RIVET
 * @contact : jprivet@archriss.com
 * @copyright : Tous droits réservés 
 */

(function($){var methods={ini:function(options){return this.each(function(){var $this=$(this);var data=$this.data('options');if(!data){var o={target:$this,current:0,transitionEffect:'blindHorizontal',transitionMode:'show',durationEffect:1000,durationPause:5000,textAnimation:'slide',autoPlay:true,btnTogglePlayStop_playMessage:'Stop animation',btnTogglePlayStop_stopMessage:'Play animation',btnPrev_message:'Previous',btnNext_message:'Next'};if(options){$.extend(o,options)}$(this).data('options',o);$(this).addClass('mycarousel_dataoptions')}o.inAnimation=false;o.prev=o.current;o.items=$('div.maincontent div.mycarousel_item_jq',$this);o.items.hide().eq(o.current).show();$this.mycarousel('navNumIniActive');$this.mycarousel('tempoStart');$this.mouseenter(function(){$(this).mycarousel('autoPlayStop')});$this.mouseleave(function(){$(this).mycarousel('autoPlayStart')});o.navNumItems=$('.nav_number li a',o.target);o.navNumItems.each(function(i){$(this).data('index',i)});o.navNumItems.click(function(e){e.preventDefault();var i=$(this).data('index');if(i!=o.current){$(this).mycarousel('autoPlayStop');$(this).mycarousel('tempoAnimClear');o.prev=o.current;o.current=i;$(this).mycarousel('animation')}});o.btnPrevList=$('a.btn_prev',$this);o.btnNextList=$('a.btn_next',$this);o.btnTogglePlayStopList=$('a.btn_togglePlayStop',$this);o.btnPrevList.attr('title',o.btnPrev_message).click(function(e){e.preventDefault();$(this).mycarousel('autoPlayStop');$(this).mycarousel('prev')});o.btnNextList.attr('title',o.btnNext_message).click(function(e){e.preventDefault();$(this).mycarousel('autoPlayStop');$(this).mycarousel('next')});o.btnTogglePlayStopList.attr('title',o.btnTogglePlayStop_playMessage).click(function(e){e.preventDefault();if($(this).hasClass('stop')){$(this).mycarousel('autoPlayStart')}else{$(this).mycarousel('autoPlayStop')}})})},tempoStart:function(){var o=this.mycarousel('getOptions');var pause=formGetValAndConv(o.durationPause);var duration=formGetValAndConv(o.durationEffect);if(pause<=duration){pause=duration+10}o.timeoutID=window.setTimeout(function(){o.target.mycarousel('tempoExe')},pause)},tempoExe:function(){var o=this.mycarousel('getOptions');if(!o.inAnimation){this.mycarousel('next')}},tempoClear:function(){var o=this.mycarousel('getOptions');window.clearTimeout(o.timeoutID)},animationClear:function(){var o=this.mycarousel('getOptions');o.items.e('stop',{clearQueue:true,jumpToEnd:true});if(o.mode='hide'){o.items.eq(o.prev).hide();o.items.eq(o.current).show()}o.items.children('.text').stop(true,true).show();o.inAnimation=false;this.mycarousel('navNumIniActive')},tempoAnimClear:function(){this.mycarousel('tempoClear');this.mycarousel('animationClear')},navNumIniActive:function(){var o=this.mycarousel('getOptions');as=$('.nav_number li a',o.target);as.removeClass('active').eq(o.current).addClass('active')},autoPlayStart:function(){var o=this.mycarousel('getOptions');autoPlayPrev=o.autoPlay;o.autoPlay=true;o.btnTogglePlayStopList.removeClass('stop').attr('title',o.btnTogglePlayStop_playMessage);if(!o.inAnimation&&!autoPlayPrev){this.mycarousel('next')}},autoPlayStop:function(){var o=this.mycarousel('getOptions');this.mycarousel('tempoClear');o.autoPlay=false;o.btnTogglePlayStopList.addClass('stop').attr('title',o.btnTogglePlayStop_stopMessage)},next:function(){var o=this.mycarousel('getOptions');this.mycarousel('tempoAnimClear');o.prev=o.current;o.current++;if(o.current>=o.items.length){o.current=0}this.mycarousel('animation')},prev:function(){var o=this.mycarousel('getOptions');this.mycarousel('tempoAnimClear');o.prev=o.current;o.current--;if(o.current<0){o.current=o.items.length-1}this.mycarousel('animation')},animation:function(){var o=this.mycarousel('getOptions');o.inAnimation=true;var effect=formGetValAndConv(o.transitionEffect);var mode=formGetValAndConv(o.transitionMode);var duration=formGetValAndConv(o.durationEffect);var textAnimation=formGetValAndConv(o.textAnimation);switch(effect){case'slideDefault':case'clipHorizontal':case'clipVertical':o.items.children('.img').each(function(){$(this).width($(this).parent().width());$(this).height($(this).parent().height())});break;default:o.items.children('.img').each(function(){$(this).width('100%');$(this).height('100%')});break}if(mode=='show'){o.items.eq(o.prev).css('zIndex','5');this.mycarousel('navNumIniActive');if(textAnimation=='fade'||textAnimation=='slide'){o.items.eq(o.current).find('.text').hide().css('visibility','hidden')}o.items.eq(o.current).css('zIndex','10').e(effect,{mode:'show'},duration,function(){$(this).siblings().hide();if(textAnimation=='fade'){$(this).children('.text').css('visibility','visible').fadeIn()}else if(textAnimation=='slide'){$(this).children('.text').css('visibility','visible').e('slideDown',600)}o.inAnimation=false})}else if(mode=='hide'){o.items.eq(o.prev).css('zIndex','10');o.items.eq(o.current).css('zIndex','5').show();this.mycarousel('navNumIniActive');delay=0;if(textAnimation=='fade'){o.items.eq(o.prev).children('.text').fadeOut();delay=400}else if(textAnimation=='slide'){o.items.eq(o.prev).children('.text').e('slideDown',600);delay=600}o.items.eq(o.prev).delay(delay).e(effect,{mode:'hide'},duration,function(){o.items.eq(o.current).siblings().hide().children('.text').show();o.inAnimation=false})}if(o.autoPlay){this.mycarousel('tempoStart')}},getOptions:function(){if(this.data('options')){return this.data('options')}else{return this.parents('.mycarousel_dataoptions:first').data('options')}}};$.fn.mycarousel=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof method==='object'||!method){return methods.ini.apply(this,arguments)}else{$.error('Method '+method+' does not exist on jQuery.mycarousel')}}})(jQuery);
