(function($){$.fn.capcarousel=function(options){var conteneur;var conteneur_height;var conteneur_width;var position_conteneur;var contenu_width;var horloge_diaporama;var xPointZero;var arrImageSize=new Array();var x;var y;var defaults={vitesse_min:1,vitesse_max:6,vitesse_rafraichisement:42,controle_sourie:1,controle_sourie_inverse:1,acceleration:1,acceleration_logarithmique:0,vitesse:2,direction:0,zoom:0,maxHeight:200,fade:0,fadeMin:30,flecheControle:0};var opts=$.extend(defaults,options);function diaporama_init(c){conteneur=c.children('DIV');if(opts.flecheControle){conteneur.width(c.width()-c.children('.fleche_droite').width()-c.children('.fleche_gauche').width())}else{conteneur.width(c.width());c.children('.fleche_gauche').hide();c.children('.fleche_droite').hide()}conteneur.mousemove(function(e){x=e.pageX;y=e.pageY});conteneur_height=conteneur.height();conteneur_width=conteneur.width();contenu_width=0;position_conteneur=conteneur.offset();xPointZero=position_conteneur.left+(conteneur_width/2);conteneur.children('.elt_carousel').each(function(){$(this).css('left',contenu_width+'px');contenu_width=contenu_width+$(this).width();$(this).css('visibility','visible')});if(contenu_width>conteneur_width){if(opts.flecheControle){c.children('.fleche_gauche').click(function(){opts.direction=1});c.children('.fleche_droite').click(function(){opts.direction=0})}diaporama_start();if(opts.controle_sourie){conteneur.mousemove(function(){if((x-position_conteneur.left)<(conteneur_width/2)){if(opts.controle_sourie_inverse){opts.direction=0}else{opts.direction=1}}else{if(opts.controle_sourie_inverse){opts.direction=1}else{opts.direction=0}}if(opts.acceleration){if(opts.acceleration_logarithmique){deltaXinv=1-Math.abs(((x-xPointZero)/(conteneur_width/2)));deltaXinv=Math.log(deltaXinv);deltaXinv=Math.abs(deltaXinv);deltaXinv=Math.round(deltaXinv*10)/10;var v=opts.vitesse_max*deltaXinv}else{deltaX=Math.abs(((x-xPointZero)/(conteneur_width/2)));var v=opts.vitesse_max*deltaX}if(v!='Infinity'){opts.vitesse=Math.round(v*1)/1;if(opts.vitesse<opts.vitesse_min){opts.vitesse=opts.vitesse_min}}}})}}}function diaporama_move(){conteneur.children('.elt_carousel').each(function(){var posXCentreImage;var thisOffsetLeft=$(this).offset().left;var intNouvellePositionLeft=thisOffsetLeft-position_conteneur.left;var itemWidth=$(this).width();if(opts.direction==1){intNouvellePositionLeft-=opts.vitesse;if(intNouvellePositionLeft+itemWidth<0){intNouvellePositionLeft=intNouvellePositionLeft+contenu_width}}else{intNouvellePositionLeft+=opts.vitesse;if(intNouvellePositionLeft>conteneur_width){intNouvellePositionLeft=intNouvellePositionLeft-contenu_width}}$(this).css('left',intNouvellePositionLeft+'px');if(opts.zoom||opts.fade){posXCentreImage=thisOffsetLeft+(itemWidth/2);if(posXCentreImage>xPointZero){posXCentreImage=xPointZero-(posXCentreImage-xPointZero)}pourc=Math.round(((posXCentreImage-position_conteneur.left)/(xPointZero-position_conteneur.left))*100);if(pourc<0){pourc=0}if(opts.zoom){image=$(this).children('IMG');if(arrImageSize[image.attr('src')]){imgWidth=arrImageSize[image.attr('src')][0];imgHeight=arrImageSize[image.attr('src')][1]}else{imgWidth=image.width();imgHeight=image.height();arrImageSize[image.attr('src')]=new Array(imgWidth,imgHeight)}coefZoom=(pourc/100);newImgHeight=imgHeight+(imgHeight*coefZoom);newImgWidth=imgWidth+(imgWidth*coefZoom);if(newImgHeight<opts.maxHeight){image.height(newImgHeight);image.width(newImgHeight);newImgTop=((conteneur_height/2))-(newImgHeight/2);$(this).css('top',newImgTop+'px')}$(this).css('z-index',pourc)}if(opts.fade){if(pourc<opts.fadeMin){opacity=opts.fadeMin/100}else{opacity=pourc/100}$(this).css('opacity',opacity)}deltaX=Math.abs(((posXCentreImage-xPointZero)/(conteneur_width/2)));deltaX=deltaX-position_conteneur.left}});horloge_diaporama=setTimeout(function(){diaporama_move()},opts.vitesse_rafraichisement)}function diaporama_start(){diaporama_move()}diaporama_init($(this));function debug($obj){if(window.console&&window.console.log)window.console.log('hilight selection count: '+$obj)};function trace($str){if(window.console&&window.console.log)window.console.log($str)};return $(this)}})(jQuery);
