/**
Le contenu de ce fichier est placé sous le copyright de La Mire s.a.r.l.
Tous les droits sont réservés : la copie, la distribution et l'utilisation du code original ou de portions de code
sont sujets à l'autorisation écrite de La Mire s.a.r.l.

The contents of this file are subject to the copyright of  La Mire s.a.r.l.
All rights reserved : You may not copy, sell or distribute this code or parts of this code without
the written permission of La Mire s.a.r.l.

(C) 2005-2009 La Mire 
contact : info@lamire.com - http://www.lamire.com
*/
(function($){$.fn.switchBackgroud=function(a){return this.each(function(){switchBackgroud(this,a)})};switchBackgroud=function(a,b){switchBackgroud.options=jQuery.extend({switchSpeed:500,playerSpeed:10000,theme:'default',next:'.next',prev:'.prev',pause:'.pause,.play',backgrounds:[],legend:'#legend'},b);switchBackgroud.element=a;switchBackgroud.bg=switchBackgroud.options.backgrounds;switchBackgroud.cpt=0;$(switchBackgroud.options.next).live('click',function(){switchBackgroud.next()});$(switchBackgroud.options.prev).live('click',function(){switchBackgroud.prev()});$(switchBackgroud.options.pause).live('click',function(){switchBackgroud.pause(this)});switchBackgroud.init()}
switchBackgroud.init=function(){
switchBackgroud.play();switchBackgroud.start()}
switchBackgroud.start=function(){switchBackgroud.player=setInterval('switchBackgroud.play()',switchBackgroud.options.playerSpeed)}
switchBackgroud.next=function(){switchBackgroud.cptUp();switchBackgroud.switchBg();if(switchBackgroud.player!=null){clearInterval(switchBackgroud.player);switchBackgroud.start()}}
switchBackgroud.prev=function(){switchBackgroud.cptDown();switchBackgroud.switchBg();if(switchBackgroud.player!=null){clearInterval(switchBackgroud.player);switchBackgroud.start()}}
switchBackgroud.pause=function(a){if(switchBackgroud.player==null){switchBackgroud.start();$(a).removeClass('bt_play').addClass('bt_pause')}else{clearInterval(switchBackgroud.player);switchBackgroud.player=null;$(a).removeClass('bt_pause').addClass('bt_play')}}
switchBackgroud.cptUp=function(){if(switchBackgroud.cpt<switchBackgroud.bg.length-1)switchBackgroud.cpt++;else switchBackgroud.cpt=0}
switchBackgroud.cptDown=function(){if(switchBackgroud.cpt==0)switchBackgroud.cpt=switchBackgroud.bg.length-1;else switchBackgroud.cpt--}
switchBackgroud.play=function(){switchBackgroud.switchBg();switchBackgroud.cptUp()}
switchBackgroud.switchBg=function(){clone=$(switchBackgroud.element).clone();clone.hide('fast',function(){$(this).css("zIndex",5).appendTo('body');
clone.show('fast',function(){$(switchBackgroud.element).fadeOut('fast',function(){$(this).attr('src',switchBackgroud.bg[switchBackgroud.cpt][0]).fadeIn(switchBackgroud.options.switchSpeed,function(){clone.hide('fast',function(){clone.remove()})});
var a=$(switchBackgroud.options.legend);
var b=switchBackgroud.bg[switchBackgroud.cpt][2]+'#page='+switchBackgroud.bg[switchBackgroud.cpt][3];a.find('a').attr('href',b).text(switchBackgroud.bg[switchBackgroud.cpt][1])})})})}})(jQuery);
