(function($){$.fn.startViewer=function(nbElements,msInterval){var currentIndex=0;play();$("#transport a#previous").click(function(){previous();return false;});$("#transport a#next").click(function(){next();return false;});$("#element li").click(function(){clearInterval(g_timer);if($(this).hasClass("selected")){return true;}else{switchElement($(this).attr("id"));return false;}});function switchElement(currentItem){$("#element-viewer").fadeOut(600,function(){$("#element-viewer div.selected").removeClass("selected");$("#element-viewer div."+currentItem).addClass("selected");$("#element-viewer").fadeIn(400);});if(jQuery("#element .selected a").length){jQuery("#element .selected a").fadeOut("slow",function(){jQuery("#element .selected").removeClass("selected");jQuery("#element li.elementDescription").eq(currentIndex-1).addClass("selected");jQuery("#element .selected a").fadeIn("slow");});}else{jQuery("#element li.elementDescription").eq(currentIndex-1).addClass("selected");jQuery("#element .selected a").fadeIn("slow");}}function timerSwitchElement(){move(1);}function move(factor){currentIndex=currentIndex+factor;if(currentIndex>nbElements){currentIndex=1;}else{if(currentIndex<1){currentIndex=nbElements;}}switchElement("element"+currentIndex);}function play(){move(1);g_timer=setInterval(timerSwitchElement,msInterval);}function pause(){clearInterval(g_timer);}function previous(){pause();move(-1);}function next(){pause();move(1);}};})(jQuery);
