var Ticker=new Class({initialize:function(a,c,b){this.moContainer=$(a);this.moContainer.getElement("ul").empty();this.mbWide=this.moContainer.hasClass("wide");this.miItemsPerRow=b||4;(new Request.JSON({url:c,method:"get",onComplete:this.build.bind(this)})).send()},build:function(a){if(!(!$type(a)||a.length===0)){this.mbWide===true&&this.moContainer.getElement("div.list").adopt(new Element("ul"));this.moContainer.removeClass("loading");var c=0;$A(a).each(function(b,e){if(this.mbWide===true&&e>=this.miItemsPerRow&&
c===0)c+=1;new Asset.image(b.image);var d=new Element("li");e=new Element("a",{href:$type(b.window)!==false?"#":b.link,title:b.title,html:b.title});if($type(b.window)!==false&&b.window.match(/^\d+x\d+$/)!==null){var f=b.window.match(/^(\d+)x(\d+)$/);e.addEvent("click",function(g){g.stop();window.open(b.link,"","width="+f[1]+",height="+f[2])})}d.adopt(e);this.moContainer.getElements("div.list ul")[c].adopt(d);d.data=b;d.addEvent("mouseenter",function(){this.selectItem(d,true)}.bind(this)).addEvent("mouseleave",
function(){this.deSelectItem(d)}.bind(this))},this);this.nextItem();this.startLooping()}},nextItem:function(){if($type(this.miCurrentItem)===false||this.miCurrentItem<0||this.miCurrentItem>=this.moContainer.getElements("li").length)this.miCurrentItem=0;this.selectItem(this.moContainer.getElements("li")[this.miCurrentItem]);this.miCurrentItem+=1},selectItem:function(a,c){$type(c)!==false&&c===true&&this.stopLooping();var b=new Element("a",{html:a.data.title,"class":"title "+a.data.section,title:a.data.title,
href:$type(a.data.window)!==false?"#":a.data.link});c=new Element("a",{text:(a.data.comments>0?a.data.comments+" "+(a.data.comments==1?a.data.text.comment:a.data.text.comments)+" | ":"")+a.data.text.more,"class":"comments",href:$type(a.data.window)!==false?"#":a.data.link});if($type(a.data.window)!==false&&a.data.window.match(/^\d+x\d+$/)!==null){var e=a.data.window.match(/^(\d+)x(\d+)$/);b.addEvent("click",function(f){f.stop();window.open(a.data.link,"","width="+e[1]+",height="+e[2])});c.addEvent("click",
function(f){f.stop();window.open(a.data.link,"","width="+e[1]+",height="+e[2])})}var d=this.moContainer.getElement("div.teaser");d.empty();d.adopt(b);d.adopt(new Element("img",{src:a.data.image}));b=new Element("div",{html:"<p>"+a.data.teaser+"</p><hr>","class":"body"});b.adopt(c);d.adopt(b);this.moContainer.getElements("li").each(function(f){f.set("class","")});a.addClass("active").addClass(a.data.section)},deSelectItem:function(){this.miCurrentItem-=1;this.nextItem();this.startLooping()},stopLooping:function(){$clear(this.moLoopEvent)},
startLooping:function(){this.moLoopEvent=this.nextItem.periodical(5E3,this)}});

