(function($){$.fn.newsTicker=$.fn.newsticker=function(delay){delay=delay||4000;initTicker=function(el){stopTicker(el);el.items=$("li",el);el.currentitem=0;var itemLgth=$(el.items).length;var btnhtml="";for(var zz=0;zz<itemLgth;zz++){btnhtml+='<li><img src="img/circle.gif" width="14" height="14" alt="O" /></li>';}$("#newsbuttons").html(btnhtml);el.buttons=$("#newsbuttons li");$("#newsbuttons li").each(function(item){$(this).hover(function(){showItem(el,item);pauseTicker(el);},function(){resumeTicker(el);});});$("#newsbuttons li").each(function(item){$(this).click(function(){var elem=$(el.items[el.currentitem]).children("a");if(elem.length>0){document.location=elem[0].href;}});});$(el.items[el.currentitem]).fadeIn();$(el.buttons[el.currentitem]).addClass("active");startTicker(el);};showItem=function(el,item){$(el.buttons[el.currentitem]).removeClass("active");$(el.items[el.currentitem]).hide();el.currentitem=item;$(el.items[el.currentitem]).show();$(el.buttons[el.currentitem]).addClass("active");};startTicker=function(el){el.tickfn=setInterval(function(){doTick(el);},delay);};stopTicker=function(el){clearInterval(el.tickfn);};pauseTicker=function(el){el.pause=true;};resumeTicker=function(el){el.pause=false;};doTick=function(el){if(el.pause){return ;}el.pause=true;$(el.items[el.currentitem]).fadeOut("slow",function(){$(this).hide();$(el.buttons[el.currentitem]).removeClass("active");el.currentitem=++el.currentitem%(el.items.size());$(el.buttons[el.currentitem]).addClass("active");$(el.items[el.currentitem]).fadeIn("slow",function(){el.pause=false;});});};this.each(function(){if(this.nodeName.toLowerCase()!="ul"){return ;}initTicker(this);}).addClass("newsticker").hover(function(){pauseTicker(this);},function(){resumeTicker(this);});return this;};})(jQuery);
