/*
 * jQuery Words Rotator plugin
 *
 * Copyright (c) 2013 Andrea Pace
 * licensed under MIT license.
 *
 * https://github.com/andreapace/wordsrotator
 * http://andreapace.co.uk/wordsrotator
 *
 * Version: 0.1.0
 */
 var wordsRotatorT,wordsRotatorRotate,wordsRotatorSettings;
(function($){$.fn.wordsrotator=function(options){var defaults={collegamenti:true,randomize:false,stopOnHover:false,changeOnClick:false,words:null,animationIn:"flipInY",animationOut:"flipOutY",speed:2000};wordsRotatorSettings=$.extend({},defaults,options);var listItem
var array_bak=[];return this.each(function(){var el=$(this)
$("<span id=\""+el.attr("id")+"_container\"></span>").insertAfter(el);var cont=$("#"+el.attr("id")+"_container");var array=[];if((wordsRotatorSettings.words)||(wordsRotatorSettings.words instanceof Array)){array=$.extend(true,[],wordsRotatorSettings.words);}else{el.hide();el.children("li").each(function(index){array.push($(this).html());});};if(wordsRotatorSettings.randomize)array_bak=$.extend(true,[],array);if(wordsRotatorSettings.randomize){listItem=Math.floor(Math.random()*array.length)}else{listItem=0}
cont.html(array[listItem]);wordsRotatorRotate=function(){cont.html("<span class='front'><span>"+array[listItem]+"</span></span>");if(wordsRotatorSettings.randomize){array.splice(listItem,1);if(array.length==0)array=$.extend(true,[],array_bak);listItem=Math.floor(Math.random()*array.length);}else{if(array.length==listItem+1)listItem=-1;listItem++;}
$("<span class='back'>"+array[listItem]+"</span>").appendTo(cont);cont.wrapInner("<span class='rotating' />");cont.find(".front").addClass("animated "+wordsRotatorSettings.animationOut);cont.find(".back").addClass("animated "+wordsRotatorSettings.animationIn);};wordsRotatorT=setInterval(wordsRotatorRotate,wordsRotatorSettings.speed);cont.on("click",function(){if(wordsRotatorSettings.changeOnClick){wordsRotatorRotate();return false;};});if(wordsRotatorSettings.stopOnHover){cont.hover(function(){window.clearInterval(wordsRotatorT)},function(){wordsRotatorT=setInterval(wordsRotatorRotate,wordsRotatorSettings.speed);});};});}}(jQuery));