(function(a){a.fn.ticker=function(b){var c=a.extend({},a.fn.ticker.defaults,b);var d="#"+a(this).attr("id");var e=a(this).get(0).tagName;return this.each(function(){function o(c){m();switch(c){case"prev":if(b.position==0){b.position=f(b.newsArr)-2}else if(b.position==1){b.position=f(b.newsArr)-1}else{b.position=b.position-2}a(b.dom.titleElem).html(b.newsArr["item-"+b.position].type);a(b.dom.contentID).html(b.newsArr["item-"+b.position].content);break;case"next":a(b.dom.titleElem).html(b.newsArr["item-"+b.position].type);a(b.dom.contentID).html(b.newsArr["item-"+b.position].content);break}if(b.position==f(b.newsArr)-1){b.position=0}else{b.position++}}function n(){b.play=true;b.paused=false;l()}function m(){b.play=false;a(b.dom.tickerID+","+b.dom.revealID+","+b.dom.titleID+","+b.dom.titleElem+","+b.dom.revealElem+","+b.dom.contentID).stop(true,true);a(b.dom.revealID+","+b.dom.revealElem).hide();a(b.dom.wrapperID).find(b.dom.titleID+","+b.dom.titleElem).show().end().find(b.dom.contentID).show()}function l(){if(b.play){a(b.dom.contentID).delay(c.pauseOnItems).fadeOut(c.fadeOutSpeed);if(c.displayType=="fade"){a(b.dom.contentID).fadeOut(c.fadeOutSpeed,function(){a(b.dom.wrapperID).find(b.dom.revealElem+","+b.dom.contentID).hide().end().find(b.dom.tickerID+","+b.dom.revealID).show().end().find(b.dom.tickerID+","+b.dom.revealID).removeAttr("style");j()})}else{a(b.dom.revealID).hide(0,function(){a(b.dom.contentID).fadeOut(c.fadeOutSpeed,function(){a(b.dom.wrapperID).find(b.dom.revealElem+","+b.dom.contentID).hide().end().find(b.dom.tickerID+","+b.dom.revealID).show().end().find(b.dom.tickerID+","+b.dom.revealID).removeAttr("style");j()})})}}else{a(b.dom.revealElem).hide()}}function k(){if(b.play){var d=a(b.dom.titleElem).width()+20;a(b.dom.revealID).css(c.direction,d+"px");if(c.displayType=="fade"){a(b.dom.revealID).hide(0,function(){a(b.dom.contentID).css(c.direction,d+"px").fadeIn(c.fadeInSpeed,l)})}else if(c.displayType=="scroll"){}else{a(b.dom.revealElem).show(0,function(){a(b.dom.contentID).css(c.direction,d+"px").show();animationAction=c.direction=="right"?{marginRight:distance+"px"}:{marginLeft:distance+"px"};a(b.dom.revealID).css("margin-"+c.direction,"0px").delay(20).animate(animationAction,time,"linear",l)})}}else{return false}}function j(){b.contentLoaded=true;a(b.dom.titleElem).html(b.newsArr["item-"+b.position].type);a(b.dom.contentID).html(b.newsArr["item-"+b.position].content);if(b.position==f(b.newsArr)-1){b.position=0}else{b.position++}distance=a(b.dom.contentID).width();time=distance/c.speed;k()}function i(){if(b.contentLoaded==false){if(c.ajaxFeed){if(c.feedType=="xml"){a.ajax({url:c.feedUrl,cache:false,dataType:c.feedType,async:true,success:function(a){count=0;for(var d=0;d<a.childNodes.length;d++){if(a.childNodes[d].nodeName=="rss"){xmlContent=a.childNodes[d]}}for(var e=0;e<xmlContent.childNodes.length;e++){if(xmlContent.childNodes[e].nodeName=="channel"){xmlChannel=xmlContent.childNodes[e]}}for(var h=0;h<xmlChannel.childNodes.length;h++){if(xmlChannel.childNodes[h].nodeName=="item"){xmlItems=xmlChannel.childNodes[h];var i,k=false;for(var l=0;l<xmlItems.childNodes.length;l++){if(xmlItems.childNodes[l].nodeName=="title"){i=xmlItems.childNodes[l].lastChild.nodeValue}else if(xmlItems.childNodes[l].nodeName=="link"){k=xmlItems.childNodes[l].lastChild.nodeValue}if(i!==false&&i!=""&&k!==false){b.newsArr["item-"+count]={type:c.titleText,content:'<a href="'+k+'">'+i+"</a>"};count++;i=false;k=false}}}}if(f(b.newsArr<1)){g("Couldn't find any content from the XML feed for the ticker to use!");return false}j();b.contentLoaded=true}})}else{g("Code Me!")}}else if(c.htmlFeed){if(a(d+" LI").length>0){a(d+" LI").each(function(d){b.newsArr["item-"+d]={type:c.titleText,content:a(this).html()}});j()}else{g("Couldn't find HTML any content for the ticker to use!");return false}}else{g("The ticker is set to not use any types of content! Check the settings for the ticker.");return false}}}function h(){a(b.dom.wrapperID).append('<div id="'+b.dom.tickerID.replace("#","")+'"><div id="'+b.dom.titleID.replace("#","")+'"><span><!-- --></span></div><p id="'+b.dom.contentID.replace("#","")+'"></p><div id="'+b.dom.revealID.replace("#","")+'"><span><!-- --></span></div></div>');a(b.dom.wrapperID).removeClass("no-js").addClass("has-js "+c.direction);a(b.dom.tickerElem+","+b.dom.contentID).hide();if(c.controls){a(b.dom.controlsID).live("click mouseover mousedown mouseout mouseup",function(c){var d=c.target.id;if(c.type=="click"){switch(d){case b.dom.prevID.replace("#",""):b.paused=true;a(b.dom.playPauseID).addClass("paused");o(d);break;case b.dom.nextID.replace("#",""):b.paused=true;a(b.dom.playPauseID).addClass("paused");o(d);break;case b.dom.playPauseID.replace("#",""):if(b.play==true){b.paused=true;a(b.dom.playPauseID).addClass("paused");m()}else{b.paused=false;a(b.dom.playPauseID).removeClass("paused");n()}break}}else if(c.type=="mouseover"&&a("#"+d).hasClass("controls")){a("#"+d).addClass("over")}else if(c.type=="mousedown"&&a("#"+d).hasClass("controls")){a("#"+d).addClass("down")}else if(c.type=="mouseup"&&a("#"+d).hasClass("controls")){a("#"+d).removeClass("down")}else if(c.type=="mouseout"&&a("#"+d).hasClass("controls")){a("#"+d).removeClass("over")}});a(b.dom.wrapperID).append('<ul id="'+b.dom.controlsID.replace("#","")+'"><li id="'+b.dom.playPauseID.replace("#","")+'" class="controls"></li><li id="'+b.dom.prevID.replace("#","")+'" class="controls"></li><li id="'+b.dom.nextID.replace("#","")+'" class="controls"></li></ul>')}if(c.displayType!="fade"){a(b.dom.contentID).mouseover(function(){if(b.paused==false){m()}}).mouseout(function(){if(b.paused==false){n()}})}i()}function g(a){if(c.debugMode){if(window.console&&window.console.log){window.console.log(a)}else{alert(a)}}}function f(a){var b=0,c;for(c in a){if(a.hasOwnProperty(c))b++}return b}var b={position:0,time:0,distance:0,newsArr:{},play:true,paused:false,contentLoaded:false,dom:{contentID:"#ticker-content",titleID:"#ticker-title",titleElem:"#ticker-title SPAN",tickerID:"#ticker",wrapperID:"#ticker-wrapper",revealID:"#ticker-swipe",revealElem:"#ticker-swipe SPAN",controlsID:"#ticker-controls",prevID:"#prev",nextID:"#next",playPauseID:"#play-pause"}};if(e!="UL"&&e!="OL"&&c.htmlFeed===true){g("Cannot use <"+e.toLowerCase()+"> type of element for this plugin - must of type <ul> or <ol>");return false}c.direction=="rtl"?c.direction="right":c.direction="left";h();})};a.fn.ticker.defaults={speed:.1,ajaxFeed:false,feedUrl:"",feedType:"xml",displayType:"reveal",htmlFeed:true,debugMode:true,controls:true,titleText:"Latest",direction:"ltr",pauseOnItems:3e3,fadeInSpeed:600,fadeOutSpeed:300}})(jQuery)
