var TopApps=Class.create();Object.extend(TopApps.prototype,{initialize:function(a){this.setValueForKey("title",a);
this.setValueForKey("paidToggle",$("paidtoggle"));this.setValueForKey("freeToggle",$("freetoggle"));
this.sendReq();this.setToggles()},setValueForKey:function(a,b){this[a]=b},setToggles:function(){Event.observe(this.paidToggle,"click",this.toggleType.bindAsEventListener(this));
Event.observe(this.freeToggle,"click",this.toggleType.bindAsEventListener(this))
},toggleType:function(b){Event.stop(b);var c=this.paidToggle.up();var a=this.freeToggle.up();
c.toggleClassName("active");a.toggleClassName("active")},sendReq:function(){var a=new Ajax.Request("/autopush/us/iphone/appstore/feeds/guide.json",{method:"GET",onException:function(b,c){throw (c)
},onComplete:this.acknowledgeComplete.bind(this)})},scopedEval:function(stringValue){try{return(function(){return eval("("+stringValue+")")
})()}catch(e){alert("Error: "+e);return null}},acknowledgeComplete:function(b){var c=b.responseText;
var a=this.scopedEval(c);if(a){var d=a;d.each(function(e){if(e.title===this.title&&e.type==="Paid"){this.createList("paid",e.topics)
}if(e.title===this.title&&e.type==="Free"){this.createList("free",e.topics)}}.bind(this))
}},createList:function(a,e){var d=new Element("a",{href:e[0].iTunesURL}).update(new Element("img",{src:"/autopush/us/iphone/appstore/content/images/"+e[0].imageURL,width:36,height:36,alt:e[0].name,title:e[0].name}));
var b=new Element("ol");e.each(function(g,f){b.insert(new Element("li").update(new Element("a",{href:g.iTunesURL}).update(g.name)))
});var c=$$("."+a)[0];c.insert({bottom:d});c.insert({bottom:b})}});
