/* ap-mambot.gallery-display.js (ap-mambot.gallery-display.js) compressed and outputted: Mon, 03 Sep 2007 18:31:08 EDT */


if(typeof apdom=='undefined')var apdom={};if(typeof debug=='undefined')var debug=true;ApMambot.interactive=function(elm){$(elm).innerHTML='<img id="tab-loading" src="'+this.staticRoute('images/v5/bits/loading.gif')+'" alt="Fetching Data..."/>';}
ApModules.isParam=function(elm,container){var s={params:{},str:$(elm).readAttribute('rev'),id:$(elm).readAttribute('rel'),type:$F('gallery-display-type'),uid:$F('gallery-display-uid'),pid:$F('gallery-display-pid'),pars:this.parameters,handler:'http://www.animepaper.net/source/gallery/gallery-handler.php',methods:'get'};if(!s.str)
return;s.rev=s.str.split(':');if(isFirebug&&debug)
console.log(s.rev);if(!s.id)
s.id=$(ApMambot.localID(elm));ApMambot.interactive(s.id);if(typeof s.rev[0]!='undefined'){if((s.rev[0]!='similar')&&(s.type=='wallpapers'||s.type=='scans')){s.url=s.handler+'?moreuser='+s.uid;s.params.thistype=s.type;s.params.oby=s.rev[0];s.params.oasc=s.rev[1];s.params.needcat=1;}else if(s.rev[0]=='similar'){s.url=s.handler+'?similar='+s.pid;s.params.thistype=s.type;}}
this.tabUpdate(s);}
ApMambot.localID=function(elm){return elm.href.match(/#(\w.+)/)[1];}
ApModules.tabUpdate=function(o){new Ajax.Updater(o.id,o.url,{method:o.methods,parameters:o.params});}
var Apsortmenu=Class.create();Apsortmenu.prototype={initialize:function(element){this.selector=$$(element);this.act=this.activate.bindAsEventListener(this);this.selector.each(this.hook.bind(this));},hook:function(elm){var nodelist=$A(elm.getElementsByTagName('a'));nodelist.each(this.setup.bind(this));},setup:function(elm){Event.observe(elm,'click',this.act,false);elm.onclick=function(){return false};},activate:function(trace){var link=Event.findElement(trace,"a");Event.stop(trace)
ApModules.isParam(link);}}
ApModules.initTabs=function(objArray){objArray.each(function(element){if($(element))
new Fabtabs(element);});}
ApModules.sortMenu=function(classname){var nodes=$$(classname);new Apsortmenu(classname);}
ApModules.activateTab=function(){this.initTabs(['gallery-tabs']);this.sortMenu('.sortmenu');}
var Fabtabs=Class.create();Fabtabs.prototype={initialize:function(element){this.element=$(element);var options=Object.extend({},arguments[1]||{});this.menu=$A(this.element.getElementsByTagName('a'));this.show(this.getInitialTab());this.menu.each(this.setupTab.bind(this));},setupTab:function(elm){Event.observe(elm,'click',this.activate.bindAsEventListener(this),false)},activate:function(ev){var elm=Event.findElement(ev,"a");Event.stop(ev);this.show(elm);this.menu.without(elm).each(this.hide.bind(this));elm.onclick=function(){return false};return false;},hide:function(elm){$(elm).up(0).removeClassName('active-tab');$(this.tabID(elm)).removeClassName('active-tab-body');},show:function(elm){$(elm).up(0).addClassName('active-tab');$(this.tabID(elm)).addClassName('active-tab-body');ApModules.isParam(elm);},tabID:function(elm){return elm.href.match(/#(\w.+)/)[1];},getInitialTab:function(){if(document.location.href.match(/#(\w.+)/)){var loc=RegExp.$1;var elm=this.menu.find(function(value){return value.href.match(/#(\w.+)/)[1]==loc;});return elm||this.menu.first();}else{return this.menu.first();}}}
ApModules.activateTab();