var MooTools={"version":"1.2dev","build":"1.2b2"};
var Native=function(_1){
_1=_1||{};
var _2=_1.afterImplement||function(){
};
var _3=_1.generics;
_3=(_3!==false);
var _4=_1.legacy;
var _5=_1.initialize;
var _6=_1.protect;
var _7=_1.name;
var _8=_5||_4;
_8.constructor=Native;
_8.$family={name:"native"};
if(_4&&_5){
_8.prototype=_4.prototype;
}
_8.prototype.constructor=_8;
if(_7){
var _9=_7.toLowerCase();
_8.prototype.$family={name:_9};
Native.typize(_8,_9);
}
var _a=function(_b,_c,_d,_e){
if(!_6||_e||!_b.prototype[_c]){
_b.prototype[_c]=_d;
}
if(_3){
Native.genericize(_b,_c,_6);
}
_2.call(_b,_c,_d);
return _b;
};
_8.implement=function(a1,a2,a3){
if(typeof a1=="string"){
return _a(this,a1,a2,a3);
}
for(var p in a1){
_a(this,p,a1[p],a2);
}
return this;
};
_8.alias=function(_13,_14,_15){
_13=this.prototype[_13];
if(_13){
_a(this,_14,_13,_15);
}
return this;
};
return _8;
};
Native.implement=function(_16,_17){
for(var i=0,l=_16.length;i<l;i++){
_16[i].implement(_17);
}
};
Native.genericize=function(_1a,_1b,_1c){
if((!_1c||!_1a[_1b])&&typeof _1a.prototype[_1b]=="function"){
_1a[_1b]=function(){
var _1d=Array.prototype.slice.call(arguments);
return _1a.prototype[_1b].apply(_1d.shift(),_1d);
};
}
};
Native.typize=function(_1e,_1f){
if(!_1e.type){
_1e.type=function(_20){
return ($type(_20)===_1f);
};
}
};
(function(_21){
for(var _22 in _21){
Native.typize(_21[_22],_22.toLowerCase());
}
})({"Boolean":Boolean,"Native":Native,"Object":Object});
(function(_23){
for(var _24 in _23){
new Native({name:_24,initialize:_23[_24],protect:true});
}
})({"String":String,"Function":Function,"Number":Number,"Array":Array,"RegExp":RegExp,"Date":Date});
(function(_25,_26){
for(var i=0,l=_26.length;i<l;i++){
Native.genericize(_25,_26[i],true);
}
return arguments.callee;
})(Array,["pop","push","reverse","shift","sort","splice","unshift","concat","join","slice","toString","valueOf","indexOf","lastIndexOf"])(String,["charAt","charCodeAt","concat","indexOf","lastIndexOf","match","replace","search","slice","split","substr","substring","toLowerCase","toUpperCase","valueOf"]);
function $chk(obj){
return !!(obj||obj===0);
};
function $clear(_2a){
clearTimeout(_2a);
clearInterval(_2a);
return null;
};
function $defined(obj){
return (obj!=undefined);
};
function $empty(){
};
function $arguments(i){
return function(){
return arguments[i];
};
};
function $lambda(_2d){
return (typeof _2d=="function")?_2d:function(){
return _2d;
};
};
function $extend(_2e,_2f){
for(var key in (_2f||{})){
_2e[key]=_2f[key];
}
return _2e;
};
function $unlink(_31){
var _32=null;
switch($type(_31)){
case "object":
_32={};
for(var p in _31){
_32[p]=$unlink(_31[p]);
}
break;
case "array":
_32=[];
for(var i=0,l=_31.length;i<l;i++){
_32[i]=$unlink(_31[i]);
}
break;
default:
return _31;
}
return _32;
};
function $merge(){
var mix={};
for(var i=0,l=arguments.length;i<l;i++){
var _39=arguments[i];
if($type(_39)!="object"){
continue;
}
for(var key in _39){
var op=_39[key],mp=mix[key];
mix[key]=(mp&&$type(op)=="object"&&$type(mp)=="object")?$merge(mp,op):$unlink(op);
}
}
return mix;
};
function $pick(){
for(var i=0,l=arguments.length;i<l;i++){
if($defined(arguments[i])){
return arguments[i];
}
}
return null;
};
function $random(min,max){
return Math.floor(Math.random()*(max-min+1)+min);
};
function $splat(obj){
var _42=$type(obj);
return (_42)?((_42!="array"&&_42!="arguments")?[obj]:obj):[];
};
var $time=Date.now||function(){
return new Date().getTime();
};
function $try(fn,_44,_45){
try{
return fn.apply(_44,$splat(_45));
}
catch(e){
return false;
}
};
function $type(obj){
if(obj==undefined){
return false;
}
if(obj.$family){
return (obj.$family.name=="number"&&!isFinite(obj))?false:obj.$family.name;
}
if(obj.nodeName){
switch(obj.nodeType){
case 1:
return "element";
case 3:
return (/\S/).test(obj.nodeValue)?"textnode":"whitespace";
}
}else{
if(typeof obj.length=="number"){
if(obj.callee){
return "arguments";
}else{
if(obj.item){
return "collection";
}
}
}
}
return typeof obj;
};
var Hash=new Native({name:"Hash",initialize:function(_47){
if($type(_47)=="hash"){
_47=$unlink(_47.getClean());
}
for(var key in _47){
if(!this[key]){
this[key]=_47[key];
}
}
return this;
}});
Hash.implement({getLength:function(){
var _49=0;
for(var key in this){
if(this.hasOwnProperty(key)){
_49++;
}
}
return _49;
},forEach:function(fn,_4c){
for(var key in this){
if(this.hasOwnProperty(key)){
fn.call(_4c,this[key],key,this);
}
}
},getClean:function(){
var _4e={};
for(var key in this){
if(this.hasOwnProperty(key)){
_4e[key]=this[key];
}
}
return _4e;
}});
Hash.alias("forEach","each");
function $H(_50){
return new Hash(_50);
};
Array.implement({forEach:function(fn,_52){
for(var i=0,l=this.length;i<l;i++){
fn.call(_52,this[i],i,this);
}
}});
Array.alias("forEach","each");
function $A(_55){
if($type(_55)=="collection"){
var _56=[];
for(var i=0,l=_55.length;i<l;i++){
_56[i]=_55[i];
}
return _56;
}
return Array.prototype.slice.call(_55);
};
function $each(_59,fn,_5b){
var _5c=$type(_59);
((_5c=="arguments"||_5c=="collection"||_5c=="array")?Array:Hash).each(_59,fn,_5b);
};
var Browser=new Hash({Engine:{name:"unknown",version:""},Platform:{name:(navigator.platform.match(/mac|win|linux|nix/i)||["other"])[0].toLowerCase()},Features:{xhr:!!(window.XMLHttpRequest),xpath:!!(document.evaluate),air:!!(window.runtime)}});
if(window.opera){
Browser.Engine.name="presto";
}else{
if(window.ActiveXObject){
Browser.Engine={name:"trident",version:(Browser.Features.xhr)?5:4};
}else{
if(!navigator.taintEnabled){
Browser.Engine={name:"webkit",version:(Browser.Features.xpath)?420:419};
}else{
if(document.getBoxObjectFor!=null){
Browser.Engine.name="gecko";
}
}
}
}
Browser.Engine[Browser.Engine.name]=Browser.Engine[Browser.Engine.name+Browser.Engine.version]=true;
Browser.Platform[Browser.Platform.name]=true;
function $exec(_5d){
if(!_5d){
return _5d;
}
if(window.execScript){
window.execScript(_5d);
}else{
var _5e=document.createElement("script");
_5e.setAttribute("type","text/javascript");
_5e.text=_5d;
document.head.appendChild(_5e);
document.head.removeChild(_5e);
}
return _5d;
};
Native.UID=0;
var Window=new Native({name:"Window",legacy:window.Window,initialize:function(win){
if(!win.Element){
win.Element=$empty;
if(Browser.Engine.webkit){
win.document.createElement("iframe");
}
win.Element.prototype=(Browser.Engine.webkit)?window["[[DOMElement.prototype]]"]:{};
}
win.uid=Native.UID++;
return $extend(win,Window.Prototype);
},afterImplement:function(_60,_61){
window[_60]=Window.Prototype[_60]=_61;
}});
Window.Prototype={$family:{name:"window"}};
new Window(window);
var Document=new Native({name:"Document",legacy:window.Document,initialize:function(doc){
doc.head=doc.getElementsByTagName("head")[0];
doc.html=doc.getElementsByTagName("html")[0];
doc.window=doc.defaultView||doc.parentWindow;
if(Browser.Engine.trident4){
$try(function(){
doc.execCommand("BackgroundImageCache",false,true);
});
}
doc.uid=Native.UID++;
return $extend(doc,Document.Prototype);
},afterImplement:function(_63,_64){
document[_63]=Document.Prototype[_63]=_64;
}});
Document.Prototype={$family:{name:"document"}};
new Document(document);
Array.implement({every:function(fn,_66){
for(var i=0,l=this.length;i<l;i++){
if(!fn.call(_66,this[i],i,this)){
return false;
}
}
return true;
},filter:function(fn,_6a){
var _6b=[];
for(var i=0,l=this.length;i<l;i++){
if(fn.call(_6a,this[i],i,this)){
_6b.push(this[i]);
}
}
return _6b;
},clean:function(){
return this.filter($arguments(0));
},indexOf:function(_6e,_6f){
var len=this.length;
for(var i=(_6f<0)?Math.max(0,len+_6f):_6f||0;i<len;i++){
if(this[i]===_6e){
return i;
}
}
return -1;
},map:function(fn,_73){
var _74=[];
for(var i=0,l=this.length;i<l;i++){
_74[i]=fn.call(_73,this[i],i,this);
}
return _74;
},some:function(fn,_78){
for(var i=0,l=this.length;i<l;i++){
if(fn.call(_78,this[i],i,this)){
return true;
}
}
return false;
},associate:function(_7b){
var obj={},_7d=Math.min(this.length,_7b.length);
for(var i=0;i<_7d;i++){
obj[_7b[i]]=this[i];
}
return obj;
},link:function(_7f){
var _80={};
for(var i=0,l=this.length;i<l;i++){
for(var key in _7f){
if(_7f[key](this[i])){
_80[key]=this[i];
delete _7f[key];
break;
}
}
}
return _80;
},contains:function(_84,_85){
return this.indexOf(_84,_85)!=-1;
},extend:function(_86){
for(var i=0,j=_86.length;i<j;i++){
this.push(_86[i]);
}
return this;
},getLast:function(){
return (this.length)?this[this.length-1]:null;
},getRandom:function(){
return (this.length)?this[$random(0,this.length-1)]:null;
},include:function(_89){
if(!this.contains(_89)){
this.push(_89);
}
return this;
},merge:function(_8a){
for(var i=0,l=_8a.length;i<l;i++){
this.include(_8a[i]);
}
return this;
},remove:function(_8d){
for(var i=this.length;i--;i){
if(this[i]===_8d){
this.splice(i,1);
}
}
return this;
},empty:function(){
this.length=0;
return this;
},flatten:function(){
var _8f=[];
for(var i=0,l=this.length;i<l;i++){
var _92=$type(this[i]);
if(!_92){
continue;
}
_8f=_8f.concat((_92=="array"||_92=="collection"||_92=="arguments")?Array.flatten(this[i]):this[i]);
}
return _8f;
},hexToRgb:function(_93){
if(this.length!=3){
return null;
}
var rgb=this.map(function(_95){
if(_95.length==1){
_95+=_95;
}
return _95.toInt(16);
});
return (_93)?rgb:"rgb("+rgb+")";
},rgbToHex:function(_96){
if(this.length<3){
return null;
}
if(this.length==4&&this[3]==0&&!_96){
return "transparent";
}
var hex=[];
for(var i=0;i<3;i++){
var bit=(this[i]-0).toString(16);
hex.push((bit.length==1)?"0"+bit:bit);
}
return (_96)?hex:"#"+hex.join("");
}});
Function.implement({extend:function(_9a){
for(var _9b in _9a){
this[_9b]=_9a[_9b];
}
return this;
},create:function(_9c){
var _9d=this;
_9c=_9c||{};
return function(_9e){
var _9f=_9c.arguments;
_9f=$defined(_9f)?$splat(_9f):Array.slice(arguments,(_9c.event)?1:0);
if(_9c.event){
_9f=[_9e||window.event].extend(_9f);
}
var _a0=function(){
return _9d.apply(_9c.bind||null,_9f);
};
if(_9c.delay){
return setTimeout(_a0,_9c.delay);
}
if(_9c.periodical){
return setInterval(_a0,_9c.periodical);
}
if(_9c.attempt){
return $try(_a0);
}
return _a0();
};
},pass:function(_a1,_a2){
return this.create({"arguments":_a1,"bind":_a2});
},attempt:function(_a3,_a4){
return this.create({"arguments":_a3,"bind":_a4,"attempt":true})();
},bind:function(_a5,_a6){
return this.create({"bind":_a5,"arguments":_a6});
},bindWithEvent:function(_a7,_a8){
return this.create({"bind":_a7,"event":true,"arguments":_a8});
},delay:function(_a9,_aa,_ab){
return this.create({"delay":_a9,"bind":_aa,"arguments":_ab})();
},periodical:function(_ac,_ad,_ae){
return this.create({"periodical":_ac,"bind":_ad,"arguments":_ae})();
},run:function(_af,_b0){
return this.apply(_b0,$splat(_af));
}});
Number.implement({limit:function(min,max){
return Math.min(max,Math.max(min,this));
},round:function(_b3){
_b3=Math.pow(10,_b3||0);
return Math.round(this*_b3)/_b3;
},times:function(fn,_b5){
for(var i=0;i<this;i++){
fn.call(_b5,i,this);
}
},toFloat:function(){
return parseFloat(this);
},toInt:function(_b7){
return parseInt(this,_b7||10);
}});
Number.alias("times","each");
(function(_b8){
var _b9={};
_b8.each(function(_ba){
if(!Number[_ba]){
_b9[_ba]=function(){
return Math[_ba].apply(null,[this].concat($A(arguments)));
};
}
});
Number.implement(_b9);
})(["abs","acos","asin","atan","atan2","ceil","cos","exp","floor","log","max","min","pow","sin","sqrt","tan"]);
String.implement({test:function(_bb,_bc){
return ((typeof _bb=="string")?new RegExp(_bb,_bc):_bb).test(this);
},contains:function(_bd,_be){
return (_be)?(_be+this+_be).indexOf(_be+_bd+_be)>-1:this.indexOf(_bd)>-1;
},trim:function(){
return this.replace(/^\s+|\s+$/g,"");
},clean:function(){
return this.replace(/\s+/g," ").trim();
},camelCase:function(){
return this.replace(/-\D/g,function(_bf){
return _bf.charAt(1).toUpperCase();
});
},hyphenate:function(){
return this.replace(/[A-Z]/g,function(_c0){
return ("-"+_c0.charAt(0).toLowerCase());
});
},capitalize:function(){
return this.replace(/\b[a-z]/g,function(_c1){
return _c1.toUpperCase();
});
},escapeRegExp:function(){
return this.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1");
},toInt:function(_c2){
return parseInt(this,_c2||10);
},toFloat:function(){
return parseFloat(this);
},hexToRgb:function(_c3){
var hex=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
return (hex)?hex.slice(1).hexToRgb(_c3):null;
},rgbToHex:function(_c5){
var rgb=this.match(/\d{1,3}/g);
return (rgb)?rgb.rgbToHex(_c5):null;
},stripScripts:function(_c7){
var _c8="";
var _c9=this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,function(){
_c8+=arguments[1]+"\n";
return "";
});
if(_c7===true){
$exec(_c8);
}else{
if($type(_c7)=="function"){
_c7(_c8,_c9);
}
}
return _c9;
}});
Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(_ca){
for(var key in this){
if(this.hasOwnProperty(key)&&this[key]===_ca){
return key;
}
}
return null;
},hasValue:function(_cc){
return (Hash.keyOf(this,_cc)!==null);
},extend:function(_cd){
Hash.each(_cd,function(_ce,key){
Hash.set(this,key,_ce);
},this);
return this;
},merge:function(_d0){
Hash.each(_d0,function(_d1,key){
Hash.include(this,key,_d1);
},this);
return this;
},remove:function(key){
if(this.hasOwnProperty(key)){
delete this[key];
}
return this;
},get:function(key){
return (this.hasOwnProperty(key))?this[key]:null;
},set:function(key,_d6){
if(!this[key]||this.hasOwnProperty(key)){
this[key]=_d6;
}
return this;
},empty:function(){
Hash.each(this,function(_d7,key){
delete this[key];
},this);
return this;
},include:function(key,_da){
var k=this[key];
if(!$defined(k)){
this[key]=_da;
}
return this;
},map:function(fn,_dd){
var _de=new Hash;
Hash.each(this,function(_df,key){
_de.set(key,fn.call(_dd,_df,key,this));
},this);
return _de;
},filter:function(fn,_e2){
var _e3=new Hash;
Hash.each(this,function(_e4,key){
if(fn.call(_e2,_e4,key,this)){
_e3.set(key,_e4);
}
},this);
return _e3;
},every:function(fn,_e7){
for(var key in this){
if(this.hasOwnProperty(key)&&!fn.call(_e7,this[key],key)){
return false;
}
}
return true;
},some:function(fn,_ea){
for(var key in this){
if(this.hasOwnProperty(key)&&fn.call(_ea,this[key],key)){
return true;
}
}
return false;
},getKeys:function(){
var _ec=[];
Hash.each(this,function(_ed,key){
_ec.push(key);
});
return _ec;
},getValues:function(){
var _ef=[];
Hash.each(this,function(_f0){
_ef.push(_f0);
});
return _ef;
},toQueryString:function(){
var _f1=[];
Hash.each(this,function(_f2,key){
$splat(_f2).each(function(val){
_f1.push(key+"="+encodeURIComponent(val));
});
});
return _f1.join("&");
}});
Hash.alias("keyOf","indexOf").alias("hasValue","contains").alias("remove","erase");
var Event=new Native({name:"Event",initialize:function(_f5,win){
win=win||window;
_f5=_f5||win.event;
if(_f5.$extended){
return _f5;
}
this.$extended=true;
var _f7=_f5.type;
var _f8=_f5.target||_f5.srcElement;
while(_f8&&_f8.nodeType==3){
_f8=_f8.parentNode;
}
if(_f7.match(/DOMMouseScroll|mousewheel/)){
var _f9=(_f5.wheelDelta)?_f5.wheelDelta/120:-(_f5.detail||0)/3;
}else{
if(_f7.test(/key/)){
var _fa=_f5.which||_f5.keyCode;
var key=Event.Keys.keyOf(_fa);
if(_f7=="keydown"){
var _fc=_fa-111;
if(_fc>0&&_fc<13){
key="f"+_fc;
}
}
key=key||String.fromCharCode(_fa).toLowerCase();
}else{
if(_f7.match(/(click|mouse|menu)/i)){
var _fd={x:_f5.pageX||_f5.clientX+win.document.documentElement.scrollLeft,y:_f5.pageY||_f5.clientY+win.document.documentElement.scrollTop};
var _fe={x:_f5.pageX?_f5.pageX-win.pageXOffset:_f5.clientX,y:_f5.pageY?_f5.pageY-win.pageYOffset:_f5.clientY};
var _ff=(_f5.which==3)||(_f5.button==2);
var _100=null;
if(_f7.match(/over|out/)){
switch(_f7){
case "mouseover":
_100=_f5.relatedTarget||_f5.fromElement;
break;
case "mouseout":
_100=_f5.relatedTarget||_f5.toElement;
}
if((function(){
while(_100&&_100.nodeType==3){
_100=_100.parentNode;
}
}).create({attempt:Browser.Engine.gecko})()===false){
_100=false;
}
}
}
}
}
return $extend(this,{event:_f5,type:_f7,page:_fd,client:_fe,rightClick:_ff,wheel:_f9,relatedTarget:_100,target:_f8,code:_fa,key:key,shift:_f5.shiftKey,control:_f5.ctrlKey,alt:_f5.altKey,meta:_f5.metaKey});
}});
Event.Keys=new Hash({"enter":13,"up":38,"down":40,"left":37,"right":39,"esc":27,"space":32,"backspace":8,"tab":9,"delete":46});
Event.implement({stop:function(){
return this.stopPropagation().preventDefault();
},stopPropagation:function(){
if(this.event.stopPropagation){
this.event.stopPropagation();
}else{
this.event.cancelBubble=true;
}
return this;
},preventDefault:function(){
if(this.event.preventDefault){
this.event.preventDefault();
}else{
this.event.returnValue=false;
}
return this;
}});
var Class=new Native({name:"Class",initialize:function(_101){
_101=_101||{};
var _102=function(){
for(var _103 in this){
this[_103]=$unlink(this[_103]);
}
this.parent=null;
["Implements","Extends"].each(function(_104){
if(!this[_104]){
return;
}
Class[_104](this,this[_104]);
delete this[_104];
},this);
this.constructor=_102;
var self=(arguments[0]!==$empty&&this.initialize)?this.initialize.apply(this,arguments):this;
if(this.options&&this.options.initialize){
this.options.initialize.call(this);
}
return self;
};
$extend(_102,this);
_102.constructor=Class;
_102.prototype=_101;
return _102;
}});
Class.implement({implement:function(){
Class.Implements(this.prototype,Array.slice(arguments));
return this;
}});
Class.Implements=function(self,_107){
$splat(_107).each(function(_108){
$extend(self,($type(_108)=="class")?new _108($empty):_108);
});
};
Class.Extends=function(self,_10a){
_10a=new _10a($empty);
for(var _10b in _10a){
var kp=_10a[_10b];
var sp=self[_10b];
self[_10b]=(function(_10e,_10f){
if($defined(_10f)&&_10e!=_10f){
var type=$type(_10f);
if(type!=$type(_10e)){
return _10f;
}
switch(type){
case "function":
return function(){
_10f.parent=self.parent=_10e.bind(this);
var _111=_10f.apply(this,arguments);
self.parent=_10f.parent;
return _111;
};
case "object":
return $merge(_10e,_10f);
default:
return _10f;
}
}
return _10e;
})(kp,sp);
}
};
Class.prototype.extend=function(_112){
_112.Extends=this;
return new Class(_112);
};
var Chain=new Class({chain:function(){
this.$chain=(this.$chain||[]).extend(arguments);
return this;
},callChain:function(){
if(this.$chain&&this.$chain.length){
this.$chain.shift().apply(this,arguments);
}
return this;
},clearChain:function(){
if(this.$chain){
this.$chain.empty();
}
return this;
}});
var Events=new Class({addEvent:function(type,fn,_115){
if(fn!=$empty){
this.$events=this.$events||{};
this.$events[type]=this.$events[type]||[];
this.$events[type].include(fn);
if(_115){
fn.internal=true;
}
}
return this;
},addEvents:function(_116){
for(var type in _116){
this.addEvent(type,_116[type]);
}
return this;
},fireEvent:function(type,args,_11a){
if(!this.$events||!this.$events[type]){
return this;
}
this.$events[type].each(function(fn){
fn.create({"bind":this,"delay":_11a,"arguments":args})();
},this);
return this;
},removeEvent:function(type,fn){
if(!this.$events||!this.$events[type]){
return this;
}
if(!fn.internal){
this.$events[type].remove(fn);
}
return this;
},removeEvents:function(type){
for(var e in this.$events){
if(type&&type!=e){
continue;
}
var fns=this.$events[e];
for(var i=fns.length;i--;i){
this.removeEvent(e,fns[i]);
}
}
return this;
}});
var Options=new Class({setOptions:function(){
this.options=$merge.run([this.options].extend(arguments));
if(!this.addEvent){
return this;
}
for(var _122 in this.options){
if($type(this.options[_122])!="function"||!(/^on[A-Z]/).test(_122)){
continue;
}
this.addEvent(_122,this.options[_122]);
delete this.options[_122];
}
return this;
}});
Document.implement({newElement:function(tag,_124){
if(Browser.Engine.trident&&_124){
["name","type","checked"].each(function(_125){
if(!_124[_125]){
return;
}
tag+=" "+_125+"=\""+_124[_125]+"\"";
if(_125!="checked"){
delete _124[_125];
}
});
tag="<"+tag+">";
}
return $.element(this.createElement(tag)).set(_124);
},newTextNode:function(text){
return this.createTextNode(text);
},getDocument:function(){
return this;
},getWindow:function(){
return this.defaultView||this.parentWindow;
}});
var Element=new Native({name:"Element",legacy:window.Element,initialize:function(tag,_128){
var _129=Element.Constructors.get(tag);
if(_129){
return _129(_128);
}
if(typeof tag=="string"){
return document.newElement(tag,_128);
}
return $(tag).set(_128);
},afterImplement:function(key,_12b){
if(!Array[key]){
Elements.implement(key,Elements.multi(key));
}
Element.Prototype[key]=_12b;
}});
Element.Prototype={$family:{name:"element"}};
Element.Constructors=new Hash;
var IFrame=new Native({name:"IFrame",generics:false,initialize:function(){
Native.UID++;
var _12c=Array.link(arguments,{properties:Object.type,iframe:$defined});
var _12d=_12c.properties||{};
var _12e=$(_12c.iframe)||false;
var _12f=_12d.onload||$empty;
delete _12d.onload;
_12d.id=_12d.name=$pick(_12d.id,_12d.name,_12e.id,_12e.name,"IFrame_"+Native.UID);
((_12e=_12e||new Element("iframe"))).set(_12d);
var _130=function(){
var host=$try(function(){
return _12e.contentWindow.location.host;
});
if(host&&host==window.location.host){
_12e.window=_12e.contentWindow;
var win=new Window(_12e.window);
var doc=new Document(_12e.window.document);
$extend(win.Element.prototype,Element.Prototype);
}
_12f.call(_12e.contentWindow);
};
(!window.frames[_12d.id])?_12e.addListener("load",_130):_130();
return _12e;
}});
var Elements=new Native({initialize:function(_134,_135){
_135=$extend({ddup:true,cash:true},_135);
_134=_134||[];
if(_135.ddup||_135.cash){
var _136={};
var _137=[];
for(var i=0,l=_134.length;i<l;i++){
var el=$.element(_134[i],!_135.cash);
if(_135.ddup){
if(_136[el.uid]){
continue;
}
_136[el.uid]=true;
}
_137.push(el);
}
_134=_137;
}
return (_135.cash)?$extend(_134,this):_134;
}});
Elements.implement({filterBy:function(_13b){
if(!_13b){
return this;
}
return new Elements(this.filter((typeof _13b=="string")?function(item){
return item.match(_13b);
}:_13b));
}});
Elements.multi=function(_13d){
return function(){
var _13e=[];
var _13f=true;
for(var i=0,j=this.length;i<j;i++){
var _142=this[i][_13d].apply(this[i],arguments);
_13e.push(_142);
if(_13f){
_13f=($type(_142)=="element");
}
}
return (_13f)?new Elements(_13e):_13e;
};
};
Window.implement({$:function(el,_144){
if(el&&el.$attributes){
return el;
}
var type=$type(el);
return ($[type])?$[type](el,_144,this.document):null;
},$$:function(_146){
if(arguments.length==1&&typeof _146=="string"){
return this.document.getElements(_146);
}
var _147=[];
var args=Array.flatten(arguments);
for(var i=0,l=args.length;i<l;i++){
var item=args[i];
switch($type(item)){
case "element":
item=[item];
break;
case "string":
item=this.document.getElements(item,true);
break;
default:
item=false;
}
if(item){
_147.extend(item);
}
}
return new Elements(_147);
},getDocument:function(){
return this.document;
},getWindow:function(){
return this;
}});
$.string=function(id,_14d,doc){
id=doc.getElementById(id);
return (id)?$.element(id,_14d):null;
};
$.element=function(el,_150){
el.uid=el.uid||[Native.UID++];
if(!_150&&Garbage.collect(el)&&!el.$family){
$extend(el,Element.Prototype);
}
return el;
};
$.textnode=$.window=$.document=$arguments(0);
$.number=function(uid){
return Garbage.Elements[uid]||null;
};
Native.implement([Element,Document],{getElement:function(_152,_153){
return $(this.getElements(_152,true)[0]||null,_153);
},getElements:function(tags,_155){
tags=tags.split(",");
var _156=[];
var ddup=(tags.length>1);
tags.each(function(tag){
var _159=this.getElementsByTagName(tag.trim());
(ddup)?_156.extend(_159):_156=_159;
},this);
return new Elements(_156,{ddup:ddup,cash:!_155});
}});
Element.Storage={get:function(uid){
return (this[uid]=this[uid]||{});
}};
Element.Inserters=new Hash({before:function(_15b,_15c){
if(_15c.parentNode){
_15c.parentNode.insertBefore(_15b,_15c);
}
},after:function(_15d,_15e){
if(!_15e.parentNode){
return;
}
var next=_15e.nextSibling;
(next)?_15e.parentNode.insertBefore(_15d,next):_15e.parentNode.appendChild(_15d);
},bottom:function(_160,_161){
_161.appendChild(_160);
},top:function(_162,_163){
var _164=_163.firstChild;
(_164)?_163.insertBefore(_162,_164):_163.appendChild(_162);
}});
Element.Inserters.inside=Element.Inserters.bottom;
Element.Inserters.each(function(_165,key){
var Key=key.capitalize();
Element.implement("inject"+Key,function(el){
Element.Inserters[key](this,$(el,true));
return this;
});
Element.implement("grab"+Key,function(el){
Element.Inserters[key]($(el,true),this);
return this;
});
});
Element.implement({getDocument:function(){
return this.ownerDocument;
},getWindow:function(){
return this.ownerDocument.getWindow();
},getElementById:function(id,_16b){
var el=this.ownerDocument.getElementById(id);
if(!el){
return null;
}
for(var _16d=el.parentNode;_16d!=this;_16d=_16d.parentNode){
if(!_16d){
return null;
}
}
return $.element(el,_16b);
},set:function(prop,_16f){
switch($type(prop)){
case "object":
for(var p in prop){
this.set(p,prop[p]);
}
break;
case "string":
var _171=Element.Properties.get(prop);
(_171&&_171.set)?_171.set.apply(this,Array.slice(arguments,1)):this.setProperty(prop,_16f);
}
return this;
},get:function(prop){
var _173=Element.Properties.get(prop);
return (_173&&_173.get)?_173.get.apply(this,Array.slice(arguments,1)):this.getProperty(prop);
},erase:function(prop){
var _175=Element.Properties.get(prop);
(_175&&_175.erase)?_175.erase.apply(this,Array.slice(arguments,1)):this.removeProperty(prop);
return this;
},match:function(tag){
return (!tag||Element.get(this,"tag")==tag);
},inject:function(el,_178){
Element.Inserters.get(_178||"bottom")(this,$(el,true));
return this;
},wraps:function(el,_17a){
el=$(el,true);
return this.replaces(el).grab(el);
},grab:function(el,_17c){
Element.Inserters.get(_17c||"bottom")($(el,true),this);
return this;
},appendText:function(text,_17e){
return this.grab(this.getDocument().newTextNode(text),_17e);
},adopt:function(){
Array.flatten(arguments).each(function(_17f){
this.appendChild($(_17f,true));
},this);
return this;
},dispose:function(){
return this.parentNode.removeChild(this);
},clone:function(_180){
var temp=new Element("div").grab(this.cloneNode(_180!==false));
Array.each(temp.getElementsByTagName("*"),function(_182){
if(_182.id){
_182.removeAttribute("id");
}
});
return new Element("div").set("html",temp.innerHTML).getFirst();
},replaces:function(el){
el=$(el,true);
el.parentNode.replaceChild(this,el);
return this;
},hasClass:function(_184){
return this.className.contains(_184," ");
},addClass:function(_185){
if(!this.hasClass(_185)){
this.className=(this.className+" "+_185).clean();
}
return this;
},removeClass:function(_186){
this.className=this.className.replace(new RegExp("(^|\\s)"+_186+"(?:\\s|$)"),"$1").clean();
return this;
},toggleClass:function(_187){
return this.hasClass(_187)?this.removeClass(_187):this.addClass(_187);
},getComputedStyle:function(_188){
var _189=null;
if(this.currentStyle){
_189=this.currentStyle[_188.camelCase()];
}else{
var _18a=this.getWindow().getComputedStyle(this,null);
if(_18a){
_189=_18a.getPropertyValue([_188.hyphenate()]);
}
}
return _189;
},empty:function(){
var _18b=$A(this.getElementsByTagName("*"));
_18b.each(function(_18c){
$try(Element.prototype.dispose,_18c);
});
Garbage.trash(_18b);
$try(Element.prototype.set,this,["html",""]);
return this;
},destroy:function(){
Garbage.kill(this.empty().dispose());
return null;
},toQueryString:function(){
var _18d=[];
this.getElements("input, select, textarea",true).each(function(el){
var name=el.name,type=el.type,_191=Element.get(el,"value");
if(_191===false||!name||el.disabled){
return;
}
$splat(_191).each(function(val){
_18d.push(name+"="+encodeURIComponent(val));
});
});
return _18d.join("&");
},getProperty:function(_193){
var EA=Element.Attributes,key=EA.Props[_193];
var _196=(key)?this[key]:this.getAttribute(_193);
return (EA.Bools[_193])?!!_196:_196;
},getProperties:function(){
var args=$A(arguments);
return args.map(function(attr){
return this.getProperty(attr);
},this).associate(args);
},setProperty:function(_199,_19a){
var EA=Element.Attributes,key=EA.Props[_199],_19d=$defined(_19a);
if(key&&EA.Bools[_199]){
_19a=(_19a||!_19d)?true:false;
}else{
if(!_19d){
return this.removeProperty(_199);
}
}
(key)?this[key]=_19a:this.setAttribute(_199,_19a);
return this;
},setProperties:function(_19e){
for(var _19f in _19e){
this.setProperty(_19f,_19e[_19f]);
}
return this;
},removeProperty:function(_1a0){
var EA=Element.Attributes,key=EA.Props[_1a0],_1a3=(key&&EA.Bools[_1a0]);
(key)?this[key]=(_1a3)?false:"":this.removeAttribute(_1a0);
return this;
},removeProperties:function(){
Array.each(arguments,this.removeProperty,this);
return this;
}});
(function(){
var walk=function(_1a5,walk,_1a7,_1a8,all,_1aa){
var el=_1a5[_1a7||walk];
var _1ac=[];
while(el){
if(el.nodeType==1&&Element.match(el,_1a8)){
_1ac.push(el);
if(!all){
break;
}
}
el=el[walk];
}
return (all)?new Elements(_1ac,{ddup:false,cash:!_1aa}):$(_1ac[0],_1aa);
};
Element.implement({getPrevious:function(_1ad,_1ae){
return walk(this,"previousSibling",null,_1ad,false,_1ae);
},getAllPrevious:function(_1af,_1b0){
return walk(this,"previousSibling",null,_1af,true,_1b0);
},getNext:function(_1b1,_1b2){
return walk(this,"nextSibling",null,_1b1,false,_1b2);
},getAllNext:function(_1b3,_1b4){
return walk(this,"nextSibling",null,_1b3,true,_1b4);
},getFirst:function(_1b5,_1b6){
return walk(this,"nextSibling","firstChild",_1b5,false,_1b6);
},getLast:function(_1b7,_1b8){
return walk(this,"previousSibling","lastChild",_1b7,false,_1b8);
},getParent:function(_1b9,_1ba){
return walk(this,"parentNode",null,_1b9,false,_1ba);
},getParents:function(_1bb,_1bc){
return walk(this,"parentNode",null,_1bb,true,_1bc);
},getChildren:function(_1bd,_1be){
return walk(this,"nextSibling","firstChild",_1bd,true,_1be);
},hasChild:function(el){
if(!(el=$(el,true))){
return false;
}
return Element.getParents(el,this.get("tag"),true).contains(this);
}});
})();
Element.alias("dispose","remove").alias("getLast","getLastChild");
Element.Properties=new Hash;
Element.Properties.style={set:function(_1c0){
this.style.cssText=_1c0;
},get:function(){
return this.style.cssText;
},erase:function(){
this.style.cssText="";
}};
Element.Properties.value={get:function(){
switch(Element.get(this,"tag")){
case "select":
var _1c1=[];
Array.each(this.options,function(_1c2){
if(_1c2.selected){
_1c1.push(_1c2.value);
}
});
return (this.multiple)?_1c1:_1c1[0];
case "input":
if(["checkbox","radio"].contains(this.type)&&!this.checked){
return false;
}
default:
return $pick(this.value,false);
}
}};
Element.Properties.tag={get:function(){
return this.tagName.toLowerCase();
}};
Element.Properties.html={set:function(){
return this.innerHTML=Array.flatten(arguments).join("");
}};
Element.implement({getText:function(){
return this.get("text");
},setText:function(text){
return this.set("text",text);
},setHTML:function(){
return this.set("html",arguments);
},getHTML:function(){
return this.get("html");
},getTag:function(){
return this.get("tag");
}});
Native.implement([Element,Window,Document],{addListener:function(type,fn){
if(this.addEventListener){
this.addEventListener(type,fn,false);
}else{
this.attachEvent("on"+type,fn);
}
return this;
},removeListener:function(type,fn){
if(this.removeEventListener){
this.removeEventListener(type,fn,false);
}else{
this.detachEvent("on"+type,fn);
}
return this;
},retrieve:function(_1c8,dflt){
var _1ca=Element.Storage.get(this.uid);
var prop=_1ca[_1c8];
if($defined(dflt)&&!$defined(prop)){
prop=_1ca[_1c8]=dflt;
}
return $pick(prop);
},store:function(_1cc,_1cd){
var _1ce=Element.Storage.get(this.uid);
_1ce[_1cc]=_1cd;
return this;
},eliminate:function(_1cf){
var _1d0=Element.Storage.get(this.uid);
delete _1d0[_1cf];
return this;
}});
Element.Attributes=new Hash({Props:{"html":"innerHTML","class":"className","for":"htmlFor","text":(Browser.Engine.trident)?"innerText":"textContent"},Bools:["compact","nowrap","ismap","declare","noshade","checked","disabled","readonly","multiple","selected","noresize","defer"],Camels:["value","accessKey","cellPadding","cellSpacing","colSpan","frameBorder","maxLength","readOnly","rowSpan","tabIndex","useMap"]});
(function(EA){
var EAB=EA.Bools,EAC=EA.Camels;
EA.Bools=EAB=EAB.associate(EAB);
Hash.extend(Hash.merge(EA.Props,EAB),EAC.associate(EAC.map(function(v){
return v.toLowerCase();
})));
EA.remove("Camels");
})(Element.Attributes);
var Garbage={Elements:{},ignored:{object:1,embed:1,OBJECT:1,EMBED:1},collect:function(el){
if(el.$attributes){
return true;
}
if(Garbage.ignored[el.tagName]){
return false;
}
Garbage.Elements[el.uid]=el;
el.$attributes={};
return true;
},trash:function(_1d6){
for(var i=_1d6.length,el;i--;i){
Garbage.kill(_1d6[i]);
}
},kill:function(el){
if(!el||!el.$attributes){
return;
}
delete Garbage.Elements[el.uid];
if(el.retrieve("events")){
el.removeEvents();
}
for(var p in el.$attributes){
el.$attributes[p]=null;
}
if(Browser.Engine.trident){
for(var d in Element.Prototype){
el[d]=null;
}
}
el.$attributes=el.uid=null;
},empty:function(){
for(var uid in Garbage.Elements){
Garbage.kill(Garbage.Elements[uid]);
}
}};
window.addListener("beforeunload",function(){
window.addListener("unload",Garbage.empty);
if(Browser.Engine.trident){
window.addListener("unload",CollectGarbage);
}
});
Element.Properties.events={set:function(_1dd){
this.addEvents(_1dd);
}};
Native.implement([Element,Window,Document],{addEvent:function(type,fn){
var _1e0=this.retrieve("events",{});
_1e0[type]=_1e0[type]||{"keys":[],"values":[]};
if(_1e0[type].keys.contains(fn)){
return this;
}
_1e0[type].keys.push(fn);
var _1e1=type,_1e2=Element.Events.get(type),_1e3=fn,self=this;
if(_1e2){
if(_1e2.onAdd){
_1e2.onAdd.call(this,fn);
}
if(_1e2.condition){
_1e3=function(_1e5){
if(_1e2.condition.call(this,_1e5)){
return fn.call(this,_1e5);
}
return false;
};
}
_1e1=_1e2.base||_1e1;
}
var defn=function(){
return fn.call(self);
};
var _1e7=Element.NativeEvents[_1e1]||0;
if(_1e7){
if(_1e7==2){
defn=function(_1e8){
_1e8=new Event(_1e8,self.getWindow());
if(_1e3.call(self,_1e8)===false){
_1e8.stop();
}
};
}
this.addListener(_1e1,defn);
}
_1e0[type].values.push(defn);
return this;
},removeEvent:function(type,fn){
var _1eb=this.retrieve("events");
if(!_1eb||!_1eb[type]){
return this;
}
var pos=_1eb[type].keys.indexOf(fn);
if(pos==-1){
return this;
}
var key=_1eb[type].keys.splice(pos,1)[0];
var _1ee=_1eb[type].values.splice(pos,1)[0];
var _1ef=Element.Events.get(type);
if(_1ef){
if(_1ef.onRemove){
_1ef.onRemove.call(this,fn);
}
type=_1ef.base||type;
}
return (Element.NativeEvents[type])?this.removeListener(type,_1ee):this;
},addEvents:function(_1f0){
for(var _1f1 in _1f0){
this.addEvent(_1f1,_1f0[_1f1]);
}
return this;
},removeEvents:function(type){
var _1f3=this.retrieve("events");
if(!_1f3){
return this;
}
if(!type){
for(var _1f4 in _1f3){
this.removeEvents(_1f4);
}
_1f3=null;
}else{
if(_1f3[type]){
while(_1f3[type].keys[0]){
this.removeEvent(type,_1f3[type].keys[0]);
}
_1f3[type]=null;
}
}
return this;
},fireEvent:function(type,args,_1f7){
var _1f8=this.retrieve("events");
if(!_1f8||!_1f8[type]){
return this;
}
_1f8[type].keys.each(function(fn){
fn.create({"bind":this,"delay":_1f7,"arguments":args})();
},this);
return this;
},cloneEvents:function(from,type){
from=$(from);
var _1fc=from.retrieve("events");
if(!_1fc){
return this;
}
if(!type){
for(var _1fd in _1fc){
this.cloneEvents(from,_1fd);
}
}else{
if(_1fc[type]){
_1fc[type].keys.each(function(fn){
this.addEvent(type,fn);
},this);
}
}
return this;
}});
Element.NativeEvents={"click":2,"dblclick":2,"mouseup":2,"mousedown":2,"contextmenu":2,"mousewheel":2,"DOMMouseScroll":2,"mouseover":2,"mouseout":2,"mousemove":2,"selectstart":2,"selectend":2,"keydown":2,"keypress":2,"keyup":2,"focus":2,"blur":2,"change":2,"reset":2,"select":2,"submit":2,"load":1,"unload":1,"beforeunload":1,"resize":1,"move":1,"DOMContentLoaded":1,"readystatechange":1,"error":1,"abort":1,"scroll":1};
(function(){
var _1ff=function(_200){
var _201=_200.relatedTarget;
if(!_201){
return true;
}
return ($type(this)!="document"&&_201!=this&&_201.prefix!="xul"&&!this.hasChild(_201));
};
Element.Events=new Hash({mouseenter:{base:"mouseover",condition:_1ff},mouseleave:{base:"mouseout",condition:_1ff},mousewheel:{base:(Browser.Engine.gecko)?"DOMMouseScroll":"mousewheel"}});
})();
Element.Properties.styles={set:function(_202){
this.setStyles(_202);
}};
Element.Properties.opacity={set:function(_203,_204){
if(!_204){
if(_203==0){
if(this.style.visibility!="hidden"){
this.style.visibility="hidden";
}
}else{
if(this.style.visibility!="visible"){
this.style.visibility="visible";
}
}
}
if(!this.currentStyle||!this.currentStyle.hasLayout){
this.style.zoom=1;
}
if(Browser.Engine.trident){
this.style.filter=(_203==1)?"":"alpha(opacity="+_203*100+")";
}
this.style.opacity=_203;
this.store("opacity",_203);
},get:function(){
return this.retrieve("opacity",1);
}};
Element.implement({setOpacity:function(_205){
return this.set("opacity",_205,true);
},getOpacity:function(){
return this.get("opacity");
},setStyle:function(_206,_207){
switch(_206){
case "opacity":
return this.set("opacity",parseFloat(_207));
case "float":
_206=(Browser.Engine.trident)?"styleFloat":"cssFloat";
}
_206=_206.camelCase();
if($type(_207)!="string"){
var map=(Element.Styles.get(_206)||"@").split(" ");
_207=$splat(_207).map(function(val,i){
if(!map[i]){
return "";
}
return ($type(val)=="number")?map[i].replace("@",Math.round(val)):val;
}).join(" ");
}else{
if(_207==String(Number(_207))){
_207=Math.round(_207);
}
}
this.style[_206]=_207;
return this;
},getStyle:function(_20b){
switch(_20b){
case "opacity":
return this.get("opacity");
case "float":
_20b=(Browser.Engine.trident)?"styleFloat":"cssFloat";
}
_20b=_20b.camelCase();
var _20c=this.style[_20b];
if(!$chk(_20c)){
_20c=[];
for(var _20d in Element.ShortStyles){
if(_20b!=_20d){
continue;
}
for(var s in Element.ShortStyles[_20d]){
_20c.push(this.getStyle(s));
}
return _20c.join(" ");
}
_20c=this.getComputedStyle(_20b);
}
if(_20c){
_20c=String(_20c);
var _20f=_20c.match(/rgba?\([\d\s,]+\)/);
if(_20f){
_20c=_20c.replace(_20f[0],_20f[0].rgbToHex());
}
}
if(Browser.Engine.presto||(Browser.Engine.trident&&!$chk(parseInt(_20c)))){
if(_20b.test(/^(height|width)$/)){
var _210=(_20b=="width")?["left","right"]:["top","bottom"],size=0;
_210.each(function(_212){
size+=this.getStyle("border-"+_212+"-width").toInt()+this.getStyle("padding-"+_212).toInt();
},this);
return this["offset"+_20b.capitalize()]-size+"px";
}
if(Browser.Engine.presto&&String(_20c).test("px")){
return _20c;
}
if(_20b.test(/(border(.+)Width|margin|padding)/)){
return "0px";
}
}
return _20c;
},setStyles:function(_213){
for(var _214 in _213){
this.setStyle(_214,_213[_214]);
}
return this;
},getStyles:function(){
var _215={};
Array.each(arguments,function(key){
_215[key]=this.getStyle(key);
},this);
return _215;
}});
Element.Styles=new Hash({width:"@px",height:"@px",left:"@px",top:"@px",bottom:"@px",right:"@px",maxWidth:"@px",maxHeight:"@px",backgroundColor:"rgb(@, @, @)",backgroundPosition:"@px @px",color:"rgb(@, @, @)",fontSize:"@px",letterSpacing:"@px",lineHeight:"@px",clip:"rect(@px @px @px @px)",margin:"@px @px @px @px",padding:"@px @px @px @px",border:"@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)",borderWidth:"@px @px @px @px",borderStyle:"@ @ @ @",borderColor:"rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)",zIndex:"@","zoom":"@",fontWeight:"@",textIndent:"@px",opacity:"@"});
Element.ShortStyles={"margin":{},"padding":{},"border":{},"borderWidth":{},"borderStyle":{},"borderColor":{}};
["Top","Right","Bottom","Left"].each(function(_217){
var _218=Element.ShortStyles;
var All=Element.Styles;
["margin","padding"].each(function(_21a){
var sd=_21a+_217;
_218[_21a][sd]=All[sd]="@px";
});
var bd="border"+_217;
_218.border[bd]=All[bd]="@px @ rgb(@, @, @)";
var bdw=bd+"Width",bds=bd+"Style",bdc=bd+"Color";
_218[bd]={};
_218.borderWidth[bdw]=_218[bd][bdw]=All[bdw]="@px";
_218.borderStyle[bds]=_218[bd][bds]=All[bds]="@";
_218.borderColor[bdc]=_218[bd][bdc]=All[bdc]="rgb(@, @, @)";
});
(function(){
function $body(el){
return el.tagName.toLowerCase()=="body";
};
Element.implement({positioned:function(){
if($body(this)){
return true;
}
return (Element.getComputedStyle(this,"position")!="static");
},getOffsetParent:function(){
if($body(this)){
return null;
}
if(!Browser.Engine.trident){
return $(this.offsetParent);
}
var el=this;
while((el=el.parentNode)){
if(Element.positioned(el)){
return $(el);
}
}
return null;
},getSize:function(){
if($body(this)){
return this.getWindow().getSize();
}
return {x:this.offsetWidth,y:this.offsetHeight};
},getScrollSize:function(){
if($body(this)){
return this.getWindow().getScrollSize();
}
return {x:this.scrollWidth,y:this.scrollHeight};
},getScroll:function(){
if($body(this)){
return this.getWindow().getScroll();
}
return {x:this.scrollLeft,y:this.scrollTop};
},scrollTo:function(x,y){
if($body(this)){
return this.getWindow().scrollTo(x,y);
}
this.scrollLeft=x;
this.scrollTop=y;
return this;
},getPosition:function(_224){
if($body(this)){
return {x:0,y:0};
}
var el=this,_226={x:0,y:0};
while(el){
_226.x+=el.offsetLeft;
_226.y+=el.offsetTop;
el=el.offsetParent;
}
var rpos=(_224)?$(_224).getPosition():{x:0,y:0};
return {x:_226.x-rpos.x,y:_226.y-rpos.y};
},getCoordinates:function(_228){
if($body(this)){
return this.getWindow().getCoordinates();
}
var _229=this.getPosition(_228),size=this.getSize();
var obj={"top":_229.y,"left":_229.x,"width":size.x,"height":size.y};
obj.right=obj.left+obj.width;
obj.bottom=obj.top+obj.height;
return obj;
},getRelativePosition:function(){
return this.getPosition(this.getOffsetParent());
},computePosition:function(obj){
return {left:obj.x-(this.getComputedStyle("margin-left").toInt()||0),top:obj.y-(this.getComputedStyle("margin-top").toInt()||0)};
},position:function(obj){
return this.setStyles(this.computePosition(obj));
}});
})();
Native.implement([Window,Document],{getSize:function(){
var body=this.getDocument().body,html=this.getDocument().documentElement;
if(Browser.Engine.webkit419){
return {x:this.innerWidth,y:this.innerHeight};
}
return {x:html.clientWidth,y:html.clientHeight};
},getScroll:function(){
var html=this.getDocument().documentElement;
return {x:$pick(this.pageXOffset,html.scrollLeft),y:$pick(this.pageYOffset,html.scrollTop)};
},getScrollSize:function(){
var html=this.getDocument().documentElement,body=this.getDocument().body;
if(Browser.Engine.trident){
return {x:Math.max(html.clientWidth,html.scrollWidth),y:Math.max(html.clientHeight,html.scrollHeight)};
}
if(Browser.Engine.webkit){
return {x:body.scrollWidth,y:body.scrollHeight};
}
return {x:html.scrollWidth,y:html.scrollHeight};
},getPosition:function(){
return {x:0,y:0};
},getCoordinates:function(){
var size=this.getSize();
return {top:0,left:0,height:size.y,width:size.x,bottom:size.y,right:size.x};
}});
Native.implement([Window,Document,Element],{getHeight:function(){
return this.getSize().y;
},getWidth:function(){
return this.getSize().x;
},getScrollTop:function(){
return this.getScroll().y;
},getScrollLeft:function(){
return this.getScroll().x;
},getScrollHeight:function(){
return this.getScrollSize().y;
},getScrollWidth:function(){
return this.getScrollSize().x;
},getTop:function(){
return this.getPosition().y;
},getLeft:function(){
return this.getPosition().x;
}});
Element.Events.domready={onAdd:function(fn){
if(Browser.loaded){
return fn.call(this);
}
var self=this,win=this.getWindow(),doc=this.getDocument();
var _238=function(){
if(!arguments.callee.done){
arguments.callee.done=true;
fn.call(self);
}
return true;
};
var _239=(Browser.Engine.webkit)?["loaded","complete"]:"complete";
var _23a=function(_23b){
if(_239.contains(_23b.readyState)){
return _238();
}
return false;
};
if(doc.readyState&&Browser.Engine.webkit){
(function(){
if(!_23a(doc)){
arguments.callee.delay(50);
}
})();
}else{
if(doc.readyState&&Browser.Engine.trident){
var _23c=$("ie_domready");
if(!_23c){
var src=(win.location.protocol=="https:")?"//:":"javascript:void(0)";
doc.write("<script id=\"ie_domready\" defer src=\""+src+"\"></script>");
_23c=$("ie_domready");
}
if(!_23a(_23c)){
_23c.addEvent("readystatechange",_23a.pass(_23c));
}
}else{
win.addEvent("load",_238);
doc.addEvent("DOMContentLoaded",_238);
}
}
return null;
}};
window.addEvent("domready",function(){
Browser.loaded=true;
});
var JSON=new Hash({encode:function(obj){
switch($type(obj)){
case "string":
return "\""+obj.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+"\"";
case "array":
return "["+String(obj.map(JSON.encode).filter($defined))+"]";
case "object":
case "hash":
var _23f=[];
Hash.each(obj,function(_240,key){
var json=JSON.encode(_240);
if(json){
_23f.push(JSON.encode(key)+":"+json);
}
});
return "{"+String(_23f)+"}";
case "number":
case "boolean":
return String(obj);
case false:
return "null";
}
return null;
},$specialChars:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\"":"\\\"","\\":"\\\\"},$replaceChars:function(chr){
return JSON.$specialChars[chr]||"\\u00"+Math.floor(chr.charCodeAt()/16).toString(16)+(chr.charCodeAt()%16).toString(16);
},decode:function(_244,_245){
if($type(_244)!="string"||!_244.length){
return null;
}
if(_245&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(_244.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,""))){
return null;
}
return eval("("+_244+")");
}});
Native.implement([Hash,Array,String,Number],{toJSON:function(){
return JSON.encode(this);
}});
var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{},async:true,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false},getXHR:function(){
return (window.XMLHttpRequest)?new XMLHttpRequest():((window.ActiveXObject)?new ActiveXObject("Microsoft.XMLHTTP"):false);
},initialize:function(_246){
if(!(this.xhr=this.getXHR())){
return;
}
this.setOptions(_246);
this.options.isSuccess=this.options.isSuccess||this.isSuccess;
this.headers=new Hash(this.options.headers).extend({"X-Requested-With":"XMLHttpRequest","Accept":"text/javascript, text/html, application/xml, text/xml, */*"});
},onStateChange:function(){
if(this.xhr.readyState!=4||!this.running){
return;
}
this.running=false;
this.status=0;
$try(function(){
this.status=this.xhr.status;
},this);
if(this.options.isSuccess.call(this,this.status)){
this.response={text:this.xhr.responseText,xml:this.xhr.responseXML};
this.success(this.response.text,this.response.xml);
}else{
this.response={text:null,xml:null};
this.failure();
}
this.xhr.onreadystatechange=$empty;
},isSuccess:function(){
return ((this.status>=200)&&(this.status<300));
},processScripts:function(text){
if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){
return $exec(text);
}
return text.stripScripts(this.options.evalScripts);
},success:function(text,xml){
this.onSuccess(this.processScripts(text),xml);
},onSuccess:function(){
this.fireEvent("onComplete",arguments).fireEvent("onSuccess",arguments).callChain();
},failure:function(){
this.onFailure();
},onFailure:function(){
this.fireEvent("onComplete").fireEvent("onFailure",this.xhr);
},setHeader:function(name,_24b){
this.headers.set(name,_24b);
return this;
},getHeader:function(name){
return $try(function(){
return this.getResponseHeader(name);
},this.xhr)||null;
},check:function(){
if(!this.running){
return true;
}
switch(this.options.link){
case "cancel":
this.cancel();
return true;
case "chain":
this.chain(this.send.bind(this,arguments));
return false;
}
return false;
},send:function(_24d){
if(!this.check(_24d)){
return this;
}
this.running=true;
var type=$type(_24d);
if(type=="string"||type=="element"){
_24d={data:_24d};
}
var old=this.options;
_24d=$extend({data:old.data,url:old.url,method:old.method},_24d);
var data=_24d.data,url=_24d.url,_252=_24d.method;
switch($type(data)){
case "element":
data=$(data).toQueryString();
break;
case "object":
case "hash":
data=Hash.toQueryString(data);
}
if(this.options.emulation&&["put","delete"].contains(_252)){
var _253="_method="+_252;
data=(data)?_253+"&"+data:_253;
_252="post";
}
if(this.options.urlEncoded&&_252=="post"){
var _254=(this.options.encoding)?"; charset="+this.options.encoding:"";
this.headers.set("Content-type","application/x-www-form-urlencoded"+_254);
}
if(data&&_252=="get"){
url=url+(url.contains("?")?"&":"?")+data;
data=null;
}
this.xhr.open(_252.toUpperCase(),url,this.options.async);
this.xhr.onreadystatechange=this.onStateChange.bind(this);
this.headers.each(function(_255,key){
try{
this.xhr.setRequestHeader(key,_255);
}
catch(e){
this.fireEvent("onException",[e,key,_255]);
}
},this);
this.fireEvent("onRequest");
this.xhr.send(data);
if(!this.options.async){
this.onStateChange();
}
return this;
},cancel:function(){
if(!this.running){
return this;
}
this.running=false;
this.xhr.abort();
this.xhr.onreadystatechange=$empty;
this.xhr=this.getXHR();
this.fireEvent("onCancel");
return this;
}});
(function(){
var _257={};
["get","post","GET","POST","PUT","DELETE"].each(function(_258){
_257[_258]=function(){
var _259=Array.link(arguments,{url:String.type,data:$defined});
return this.send($extend(_259,{method:_258.toLowerCase()}));
};
});
Request.implement(_257);
})();
Element.Properties.send={get:function(_25a){
if(_25a||!this.retrieve("send")){
this.set("send",_25a);
}
return this.retrieve("send");
},set:function(_25b){
var send=this.retrieve("send");
if(send){
send.cancel();
}
return this.store("send",new Request($extend({data:this,link:"cancel",method:this.get("method")||"post",url:this.get("action")},_25b)));
}};
Element.implement({send:function(url){
var _25e=this.get("send");
_25e.send({data:this,url:url||_25e.options.url});
return this;
}});
Request.HTML=new Class({Extends:Request,options:{update:false,evalScripts:true,filter:false},processHTML:function(text){
var _260=text.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
return (_260)?_260[1]:text;
},success:function(text){
var opts=this.options,res=this.response;
res.html=this.processHTML(text).stripScripts(function(_264){
res.javascript=_264;
});
var node=new Element("div",{html:res.html});
res.elements=node.getElements("*");
res.tree=(opts.filter)?res.elements.filterBy(opts.filter):$A(node.childNodes).filter(function(el){
return ($type(el)!="whitespace");
});
if(opts.update){
$(opts.update).empty().adopt(res.tree);
}
if(opts.evalScripts){
$exec(res.javascript);
}
this.onSuccess(res.tree,res.elements,res.html,res.javascript);
}});
Element.Properties.load={get:function(_267){
if(_267||!this.retrieve("load")){
this.set("load",_267);
}
return this.retrieve("load");
},set:function(_268){
var load=this.retrieve("load");
if(load){
load.cancel();
}
return this.store("load",new Request.HTML($extend({link:"cancel",update:this,method:"get"},_268)));
}};
Element.implement({load:function(){
this.get("load").send(Array.link(arguments,{data:Object.type,url:String.type}));
return this;
}});
Request.JSON=new Class({Extends:Request,options:{secure:true},initialize:function(_26a){
arguments.callee.parent(_26a);
this.headers.extend({"Accept":"application/json","X-Request":"JSON"});
},success:function(text){
this.response.json=JSON.decode(text,this.options.secure);
this.onSuccess(this.response.json,text);
}});

/*
 * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
 * Digest Algorithm, as defined in RFC 1321.
 * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
 * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
 * Distributed under the BSD License
 * See http://pajhome.org.uk/crypt/md5 for more info.
 */

/*
 * Configurable variables. You may need to tweak these to be compatible with
 * the server-side, but the defaults work in most cases.
 */
var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */

/*
 * These are the functions you'll usually want to call
 * They take string arguments and return either hex or base-64 encoded strings
 */
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }

/*
 * Perform a simple self-test to see if the VM is working
 */
function md5_vm_test()
{
  return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}

/*
 * Calculate the MD5 of an array of little-endian words, and a bit length
 */
function core_md5(x, len)
{
  /* append padding */
  x[len >> 5] |= 0x80 << ((len) % 32);
  x[(((len + 64) >>> 9) << 4) + 14] = len;

  var a =  1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d =  271733878;

  for(var i = 0; i < x.length; i += 16)
  {
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;

    a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
    d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
    c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
    b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
    a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
    d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
    c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
    b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
    a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
    d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
    c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
    b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
    a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
    d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
    c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
    b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);

    a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
    d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
    c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
    b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
    a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
    d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
    c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
    b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
    a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
    d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
    c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
    b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
    a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
    d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
    c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
    b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);

    a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
    d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
    c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
    b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
    a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
    d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
    c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
    b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
    a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
    d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
    c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
    b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
    a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
    d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
    c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
    b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);

    a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
    d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
    c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
    b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
    a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
    d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
    c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
    b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
    a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
    d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
    c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
    b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
    a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
    d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
    c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
    b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);

    a = safe_add(a, olda);
    b = safe_add(b, oldb);
    c = safe_add(c, oldc);
    d = safe_add(d, oldd);
  }
  return Array(a, b, c, d);

}

/*
 * These functions implement the four basic operations the algorithm uses.
 */
function md5_cmn(q, a, b, x, s, t)
{
  return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
  return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
  return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
  return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
  return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}

/*
 * Calculate the HMAC-MD5, of a key and some data
 */
function core_hmac_md5(key, data)
{
  var bkey = str2binl(key);
  if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);

  var ipad = Array(16), opad = Array(16);
  for(var i = 0; i < 16; i++)
  {
    ipad[i] = bkey[i] ^ 0x36363636;
    opad[i] = bkey[i] ^ 0x5C5C5C5C;
  }

  var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
  return core_md5(opad.concat(hash), 512 + 128);
}

/*
 * Add integers, wrapping at 2^32. This uses 16-bit operations internally
 * to work around bugs in some JS interpreters.
 */
function safe_add(x, y)
{
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}

/*
 * Bitwise rotate a 32-bit number to the left.
 */
function bit_rol(num, cnt)
{
  return (num << cnt) | (num >>> (32 - cnt));
}

/*
 * Convert a string to an array of little-endian words
 * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
 */
function str2binl(str)
{
  var bin = Array();
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < str.length * chrsz; i += chrsz)
    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  return bin;
}

/*
 * Convert an array of little-endian words to a string
 */
function binl2str(bin)
{
  var str = "";
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < bin.length * 32; i += chrsz)
    str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
  return str;
}

/*
 * Convert an array of little-endian words to a hex string.
 */
function binl2hex(binarray)
{
  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i++)
  {
    str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
           hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);
  }
  return str;
}

/*
 * Convert an array of little-endian words to a base-64 string
 */
function binl2b64(binarray)
{
  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i += 3)
  {
    var triplet = (((binarray[i   >> 2] >> 8 * ( i   %4)) & 0xFF) << 16)
                | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
                |  ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
    for(var j = 0; j < 4; j++)
    {
      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
    }
  }
  return str;
}
Posterwall={NS:"http://www.metroparc.nl/ns/posterwall/1",BORDERSIZE:2,GRIDSIZE:40,STARTERWIDTH:4,findfirst:function(_1,_2){
_2=_2.toUpperCase();
for(var c=_1.firstChild;c;c=c.nextSibling){
if(c.nodeType==1&&c.nodeName==_2){
return $(c);
}
}
return false;
},log:function(_4){
if(typeof console!="undefined"&&console.log){
console.log(_4);
}
},Point:function(v,w){
var d=Math.pow(v,2)+Math.pow(w,2);
this.x=function(){
return v;
};
this.y=function(){
return w;
};
this.toString=function(){
return "Point<"+v+","+w+">";
};
this.add=function(v2,w2){
if(typeof v2=="number"&&typeof w2=="number"){
return new Posterwall.Point(v+v2,w+w2);
}
throw new Error("Missing number arguments to add.");
};
this.distance=function(){
return d;
};
},Image:function(_a){
this.toString=function(){
return "Image<"+this.url+">";
};
var _b=false;
if(typeof _a=="undefined"){
throw new Error("Missing URL argument.");
}
if(typeof _a!="string"){
throw new Error("Given URL is not a string.");
}
if(_a.indexOf("http://")==-1&&_a.indexOf("https://")==-1){
if(/[a-z]+\:/.test(_a)){
throw new Error("Unsupported protocol in "+_a);
}
if(!_b){
var l=location.pathname.lastIndexOf("/");
_b=location.pathname.substring(0,l);
}
if(_a.indexOf("/")==-1){
_a=_b+_a;
}
_a=location.protocol+"//"+location.host+_a;
}
this.id=hex_md5(_a);
this.url=_a;
this.thumb_url=_a;
this.height=false;
this.width=false;
},Set:function(){
this._store={};
this.put=function(_d,_e){
this._store[_d]=_e;
};
this.get=function(_f){
if(this._store[_f]){
return this._store[_f];
}
return false;
};
this.toString=function(){
return JSON.encode(this._store);
};
},Rectangle:function(v,w,_12){
if(typeof v=="undefined"){
v=new Posterwall.Point(0,0);
w=new Posterwall.Point(1,1);
}else{
if(typeof w=="undefined"){
w=v.add(1,1);
}else{
if(w.distance()<=v.distance()){
w=v.add(1,1);
}
}
}
this.p1=v;
this.p2=w;
if(typeof _12=="undefined"){
_12=[w.x()-v.x(),w.y()-v.y()];
}
if(_12[0]<1||_12[1]<1){
throw new Error("Illegal aspect value: "+_12);
}
this.setAspect=function(hor,ver){
_12=[hor,ver];
};
this.computeHeight=function(_15){
var w0=_12[0];
var h0=_12[1];
return Math.round((_15*h0)/w0);
};
this.bounds=function(){
return {x1:this.p1.x(),y1:this.p1.y(),d1:this.p1.distance(),x2:this.p2.x(),y2:this.p2.y(),d2:this.p2.distance()};
};
this.within=function(_18){
return _18.p1.x()<=this.p1.x()&&this.p2.x()<=_18.p2.x()&&_18.p1.y()<=this.p1.y()&&this.p2.y()<=_18.p2.y();
};
this.move=function(dx,dy){
return new Posterwall.Rectangle(this.p1.add(dx,dy),this.p2.add(dx,dy),_12);
};
this.scale=function(_1b){
var _1c=this.p2.x()-this.p1.x()+_1b;
var _1d=Math.ceil((_1c*_12[1])/_12[0]);
if(_1c<1||_1d<1){
return new Posterwall.Rectangle(this.p1,this.p2,_12);
}else{
var _1e=new Posterwall.Point(this.p1.x()+_1c,this.p1.y()+_1d);
return new Posterwall.Rectangle(this.p1,_1e,_12);
}
};
this.getLayout=function(_1f){
var _20={};
var x1=this.p1.x();
var y1=this.p1.y();
_20.left=x1*Posterwall.GRIDSIZE+"px";
_20.top=y1*Posterwall.GRIDSIZE+"px";
_20.width=(this.p2.x()-x1)*Posterwall.GRIDSIZE+"px";
_20.height=(this.p2.y()-y1)*Posterwall.GRIDSIZE+"px";
for(field in _1f){
_20[field]=_1f[field];
}
return _20;
};
this.toString=function(){
return "Rectangle<"+this.p1.toString()+", "+this.p2.toString()+", "+_12+">";
};
this.copy=function(){
return new Posterwall.Rectangle(this.p1,this.p2,_12);
};
},Poster:new Class({url:false,id:false,rect:false,imageid:false,initialize:function(img,_24){
this.imageid=img.id;
this.id="poster_"+img.id;
this.url=img.url;
this.rect=_24.copy();
var _25=Posterwall.grid.root();
var _26=$(document.createElement("div"));
_26.addClass("poster");
_26.setProperty("id",this.id);
_25.appendChild(_26);
var i=$(new Image());
i.addClass("posterimage");
_26.appendChild(i);
i.addEvent("load",this.onload.bindWithEvent(this));
i.src=this.url;
_26.addEvent("click",this.onclick.bindWithEvent(this));
this._set_position();
},toString:function(){
return "Poster<'"+this.url+"', "+this.rect.toString()+">";
},expose:function(){
return {url:this.url,x1:this.rect.p1.x(),y1:this.rect.p1.y(),x2:this.rect.p2.x(),y2:this.rect.p2.y()};
},distanceOrigin:function(){
return this.rect.p1.distance();
},onclick:function(ev){
Posterwall.editor.setPoster(this);
Event.stopPropagation(ev);
},onload:function(){
this._set_layout();
$(this.id).setStyle("visibility","visible");
},setRectangle:function(_29){
if(!_29||_29.constructor!=Posterwall.Rectangle){
throw new Error("Missing rectangle argument");
}
this.rect=_29.copy();
this._set_layout();
},_set_layout:function(){
var _2a=false;
var _2b=this.rect.p2.x()-this.rect.p1.x();
var img=Posterwall.findfirst($(this.id),"img");
if(typeof img.naturalWidth!="undefined"){
var _2a=Math.ceil((_2b*img.naturalHeight)/img.naturalWidth);
this.rect.setAspect(img.naturalWidth,img.naturalHeight);
}else{
var _2d=new Image();
_2d.src=img.src;
var _2a=Math.ceil((_2b*_2d.height)/_2d.width);
this.rect.setAspect(_2d.width,_2d.height);
}
this.rect.p2=new Posterwall.Point(this.rect.p2.x(),this.rect.p1.y()+_2a);
var _2e=(_2b*Posterwall.GRIDSIZE)-(Posterwall.BORDERSIZE*2);
var _2f=this.rect.computeHeight(_2e);
img.setStyle("width",_2e+"px");
img.setStyle("height",_2f+"px");
this._set_position();
},_set_position:function(){
$(this.id).setStyles(this.rect.getLayout({width:"auto",height:"auto"}));
if(Posterwall.editor){
Posterwall.editor.update();
}
},getLayout:function(){
var s=$(this.id).getSize();
var p=$(this.id).getPosition();
var _32=Posterwall.grid.root().getPosition();
var r={};
r.left=(p.x-_32.x)+"px";
r.top=(p.y-_32.y)+"px";
r.width=(s.x-2*Posterwall.BORDERSIZE)+"px";
r.height=(s.y-2*Posterwall.BORDERSIZE)+"px";
return r;
}}),PosterList:function(){
var _34=new Array();
var _35=function(_36,_37){
return _36.distanceOrigin()-_37.distanceOrigin();
};
this.add=function(_38){
_34.push(_38);
_34.sort(_35);
};
this.remove=function(_39){
_34.remove(_39);
};
this.sort=function(){
_34.sort(_35);
};
this.toString=function(){
return "PosterList<"+_34.toString()+">";
};
this.findPostersOnRectangle=function(_3a){
var b=_3a.bounds();
var _3c=false;
for(var i=0;i<_34.length;i++){
var p=_34[i];
var _3f=p.rect.bounds();
if(_3f.d1>=b.d2){
break;
}
if(_3f.d2<b.d1){
continue;
}
if(_3f.x2<=b.x1||_3f.x1>=b.x2){
continue;
}
if(_3f.y2<=b.y1||_3f.y1>=b.y2){
continue;
}
if(_3c==false){
_3c=new Array();
}
_3c.push(p);
}
return _3c;
};
this.length=function(){
return _34.length;
};
this.itemAt=function(i){
return _34[i];
};
},GridStore:new Class({_update_handle:false,_posters:false,_send_options:false,_is_loading:true,initialize:function(_41,_42){
var url=location.protocol+"//"+location.host+location.pathname+"update";
this._send_options={url:url,method:"post"};
this._load_images();
},_load_images:function(){
this._is_loading=true;
var _44=function(_45){
var _46={x1:0,y1:0,x2:0,y2:0};
var _47=_45.split(";");
for(var i=0;i<_47.length;i++){
var _49=_47[i].trim();
if(_49.indexOf("-posterwall-")!=0){
continue;
}
var _4a=_49.split(":");
var _4b=_4a[0].trim();
_4b=_4b.substring(12,_4b.length);
if(_4b=="x1"||_4b=="y1"||_4b=="x2"||_4b=="y2"){
_46[_4b]=new Number(_4a[1].trim());
}else{
_46[_4b]=_4a[1].trim();
}
}
return _46;
};
for(var c=Posterwall.grid.root().firstChild;c;c=c.nextSibling){
if(c.nodeType!=1||c.nodeName!="IMG"){
continue;
}
c=$(c);
c.addClass("loaded");
var _4d=false;
if(c.hasAttributeNS&&c.hasAttributeNS(Posterwall.NS,"data")){
_4d=_44(c.getAttributeNS(Posterwall.NS,"data"));
}else{
_4d=_44(c.getProperty("pw:data"));
}
var _4e=new Posterwall.Rectangle(new Posterwall.Point(_4d.x1,_4d.y1),new Posterwall.Point(_4d.x2,_4d.y2));
var img=new Posterwall.Image(c.src);
img.width=$(c).getSize().x;
img.height=$(c).getSize().x;
if(img.id!=_4d.hash){
Posterwall.log("Failed to calculate hash of image "+img);
continue;
}
Posterwall.grid.createPoster(img,_4e);
}
this._is_loading=false;
},pickle:function(){
var _50=[];
for(var id in this._posters){
var _52=this._posters[id];
if(_52){
_50.push(_52.expose());
}
}
return JSON.encode(_50);
},onunload:function(ev){
},ongridchange:function(_54){
if(this._is_loading){
return;
}
this._posters=_54;
if(this._update_handle){
return;
}else{
this._update_handle=window.setTimeout(this.update.bindWithEvent(this),1500);
}
},update:function(){
if(!this._posters){
return;
}
this._update_handle=false;
var _55=this.pickle();
var _56=new Request.JSON(this._send_options);
return _56.send(_55);
}}),Grid:new Class({m:false,gridid:false,bounds:false,posters:{},list:false,initialize:function(_57,_58){
this.m=_58;
this.gridid=_57;
this.bounds=new Posterwall.Rectangle();
this.list=new Posterwall.PosterList();
this._calc_bounds();
window.addEvent("resize",this.onresize.bindWithEvent(this));
},_calc_bounds:function(){
var s=$(this.gridid).getSize();
var v=Math.floor(s.x/this.m);
var w=Math.floor(s.y/this.m);
this.bounds.p2=new Posterwall.Point(v,w);
},onresize:function(ev){
this._calc_bounds();
},onunload:function(ev){
$(this.gridid).setHTML("new...");
},getPosterByImageId:function(id){
if(this.posters[id]){
return this.posters[id];
}
return false;
},_is_free_for_poster:function(_5f,_60){
if(!_60.within(this.bounds)){
return false;
}
var _61=this.list.findPostersOnRectangle(_60);
if(_61&&_61.length>0){
if(_61.length==1&&_61[0]==_5f){
return true;
}else{
return false;
}
}
return true;
},findRectangle:function(_62,_63,_64){
var _65=$(this.gridid).getPosition();
var dx=Math.floor((_62-_65.x)/this.m);
var dy=Math.floor((_63-_65.y)/this.m);
var r=_64.move(dx,dy);
if(!r.within(this.bounds)){
return false;
}
var _69=this.list.findPostersOnRectangle(r);
if(_69){
return false;
}
return r;
},root:function(){
return $(this.gridid);
},getPosterByImageId:function(_6a){
var p=this.posters[_6a];
if(p){
return p;
}
return false;
},deletePoster:function(_6c){
if(!this.posters[_6c.imageid]){
return false;
}
this.posters[_6c.imageid]=undefined;
this.list.remove(_6c);
$(_6c.id).remove();
Posterwall.gridstore.ongridchange(this.posters);
return true;
},movePoster:function(_6d,_6e){
if(typeof _6e!="array"&&_6e.length!=2){
throw new Error("Direction argument is not an array of length two (delta x, delta y");
}
var r=_6d.rect.move(_6e[0],_6e[1]);
return this.movePosterTo(_6d,r);
},movePosterTo:function(_70,_71){
if(this._is_free_for_poster(_70,_71)){
_70.setRectangle(_71);
this.list.sort();
Posterwall.gridstore.ongridchange(this.posters);
return true;
}else{
return false;
}
},createPoster:function(img,_73){
if(img==false||img.constructor!=Posterwall.Image){
throw new Error("Missing image");
}
if(_73==false||_73.constructor!=Posterwall.Rectangle){
throw new Error("Missing rectangle");
}
if(this.posters[img.id]){
return false;
}
var p=new Posterwall.Poster(img,_73);
this.posters[img.id]=p;
this.list.add(p);
if(Posterwall.gridstore){
Posterwall.gridstore.ongridchange(this.posters);
}
return p;
},scalePoster:function(_75,_76){
var _77=_75.rect.scale(_76);
if(this._is_free_for_poster(_75,_77)){
_75.setRectangle(_77);
Posterwall.gridstore.ongridchange(this.posters);
return true;
}
return false;
}}),PosterControl:new Class({_poster:false,initialize:function(){
var d=$(document.createElement("div"));
d.setProperty("id","postercontrol");
d.setStyle("border-size",Posterwall.BORDERSIZE+"px");
d.addEvent("click",this.toggleVisibility.bindWithEvent(this));
Posterwall.grid.root().appendChild(d);
d.appendChild(this._createButton("delete","Delete","",this.ondelete));
d.appendChild(this._createButton("scaleup","Zoom in","z",this.onscaleup));
d.appendChild(this._createButton("scaledown","Zoom out","Shift + z",this.onscaledown));
d.appendChild(this._createButton("up","Up","Arrow up",this.onmoveup));
d.appendChild(this._createButton("down","Down","Arrow down",this.onmovedown));
d.appendChild(this._createButton("left","Left","Arrow left",this.onmoveleft));
d.appendChild(this._createButton("right","Right","Arrow right",this.onmoveright));
d.appendChild(this._createButton("unlock","Unlock","x",this.onunlock));
document.addEvent("keydown",this.onkeydown.bindWithEvent(this));
},_createButton:function(id,_7a,_7b,_7c){
var _7d=$(document.createElement("span"));
_7d.setProperty("id",id);
_7d.setProperty("title","Keyboard: "+_7b);
_7d.addClass("button");
_7d.addEvent("click",_7c.bindWithEvent(this));
_7d.appendChild(document.createTextNode(_7a));
return _7d;
},setPoster:function(_7e){
if(!_7e){
throw new Error("PosterControl.setPoster: Missing poster argument");
}
if(this._poster&&_7e!=this._poster){
this._poster=_7e;
this.toggleVisibility(true);
}else{
this._poster=_7e;
this.toggleVisibility();
}
},toggleVisibility:function(_7f){
var _80=this._is_visible?"hidden":"visible";
if(typeof _7f=="boolean"){
_80=_7f?"visible":"hidden";
}
if(_80=="hidden"){
this._is_visible=false;
$("postercontrol").blur();
$("postercontrol").setStyle("visibility","hidden");
Posterwall.dropper.stopFollowing();
}else{
this._is_visible=true;
$("postercontrol").setStyles(this._poster.getLayout());
$("postercontrol").setStyle("visibility","visible");
$("postercontrol").focus();
}
},update:function(){
if(this._is_visible){
$("postercontrol").setStyles(this._poster.getLayout());
}
},ondelete:function(ev){
if(!this._poster){
return;
}
Posterwall.grid.deletePoster(this._poster);
this.toggleVisibility(false);
Event.stopPropagation(ev);
},onscaleup:function(ev){
if(!this._poster){
return;
}
if(Posterwall.grid.scalePoster(this._poster,1)){
$("postercontrol").setStyles(this._poster.getLayout());
}
Event.stopPropagation(ev);
},onscaledown:function(ev){
if(!this._poster){
return;
}
if(Posterwall.grid.scalePoster(this._poster,-1)){
$("postercontrol").setStyles(this._poster.getLayout());
}
Event.stopPropagation(ev);
},onmoveup:function(ev){
if(!this._poster){
return;
}
if(Posterwall.grid.movePoster(this._poster,[0,-1])){
$("postercontrol").setStyles(this._poster.getLayout());
}
Event.stopPropagation(ev);
},onmovedown:function(ev){
if(!this._poster){
return;
}
if(Posterwall.grid.movePoster(this._poster,[0,1])){
$("postercontrol").setStyles(this._poster.getLayout());
}
Event.stopPropagation(ev);
},onmoveleft:function(ev){
if(!this._poster){
return;
}
if(Posterwall.grid.movePoster(this._poster,[-1,0])){
$("postercontrol").setStyles(this._poster.getLayout());
}
Event.stopPropagation(ev);
},onmoveright:function(ev){
if(!this._poster){
return;
}
if(Posterwall.grid.movePoster(this._poster,[1,0])){
$("postercontrol").setStyles(this._poster.getLayout());
}
Event.stopPropagation(ev);
},onunlock:function(ev){
if(!this._poster){
return;
}
Posterwall.dropper.startFollowing(ev,Posterwall.set.get(this._poster.imageid));
Event.stopPropagation(ev);
},onkeydown:function(ev){
if(!this._is_visible){
return;
}
if(ev.key=="up"){
this.onmoveup(ev);
}else{
if(ev.key=="down"){
this.onmovedown(ev);
}else{
if(ev.key=="left"){
this.onmoveleft(ev);
}else{
if(ev.key=="right"){
this.onmoveright(ev);
}else{
if(ev.key=="x"){
this.onunlock(ev);
}else{
if(ev.code==90||ev.key=="z"){
if(ev.shift){
this.onscaledown(ev);
}else{
this.onscaleup(ev);
}
}else{
if(ev.code==27){
this.toggleVisibility(false);
}
}
}
}
}
}
}
}}),GridControl:new Class({drop_image:false,drop_image_rect:false,snap_rect:false,_is_listening:false,initialize:function(){
var _8a=Posterwall.grid.root();
_8a.addEvent("mouseenter",this.onmouseenter.bindWithEvent(this));
_8a.addEvent("mouseleave",this.onmouseleave.bindWithEvent(this));
_8a.addEvent("click",this.onclick.bindWithEvent(this));
this._onmousemoveListener=this.onmousemove.bindWithEvent(this);
var b=$(document.createElement("div"));
b.setProperty("id","postercursor");
_8a.appendChild(b);
b=$(document.createElement("div"));
b.setProperty("id","posterdropsnap");
_8a.appendChild(b);
},_add_move_listener:function(){
this._is_listening=true;
var _8c=window;
if(!Browser.Engine.gecko){
_8c=Posterwall.grid.root();
}
_8c.addEvent("mousemove",this._onmousemoveListener);
},_remove_move_listener:function(){
var _8d=window;
if(!Browser.Engine.gecko){
_8d=Posterwall.grid.root();
}
_8d.removeEvent("mousemove",this._onmousemoveListener);
this._is_listening=false;
},startFollowing:function(ev,_8f){
if(_8f.constructor!=Posterwall.Image){
throw new Error("Missing image data for startFollowing");
}
this.drop_image=_8f;
var w=Posterwall.STARTERWIDTH;
var h=Math.ceil((w*this.drop_image.height)/this.drop_image.width);
this.drop_image_rect=new Posterwall.Rectangle(new Posterwall.Point(0,0),new Posterwall.Point(w,h));
var img=$("postercursor").firstChild;
if(!img){
img=$(document.createElement("img"));
$("postercursor").appendChild(img);
}
img.src=_8f.thumb_url;
$("postercursor").setStyle("height",(_8f.height+2*Posterwall.BORDERSIZE)+"px");
$("postercursor").setStyle("width",(_8f.width+2*Posterwall.BORDERSIZE)+"px");
this._add_move_listener();
},stopFollowing:function(){
this.onmouseleave();
this.drop_image=false;
},onmouseenter:function(ev){
if(this.drop_image){
this._add_move_listener();
$("postercursor").setStyle("visibility","visible");
}
},onmouseleave:function(ev){
this._remove_move_listener();
$("postercursor").setStyle("visibility","hidden");
$("posterdropsnap").setStyle("visibility","hidden");
},onmousemove:function(ev){
if(!this.drop_image){
return;
}
var _96=$("posterwall").getPosition();
$("postercursor").setStyles({visibility:"visible",left:ev.client.x-_96.x,top:ev.client.y-_96.y});
this.snap_rect=Posterwall.grid.findRectangle(ev.client.x,ev.client.y,this.drop_image_rect);
if(this.snap_rect){
$("posterdropsnap").setStyles(this.snap_rect.getLayout());
$("posterdropsnap").setStyle("visibility","visible");
}else{
$("posterdropsnap").setStyle("visibility","hidden");
}
},onclick:function(ev){
if(!this.drop_image){
Posterwall.editor.toggleVisibility(false);
return;
}
if(!this.snap_rect){
return;
}
$("postercursor").setStyle("visibility","hidden");
$("posterdropsnap").setStyle("visibility","hidden");
var _98=Posterwall.grid.getPosterByImageId(this.drop_image.id);
if(_98){
Posterwall.grid.movePosterTo(_98,this.snap_rect);
}else{
var _98=Posterwall.grid.createPoster(this.drop_image,this.snap_rect);
if(_98){
Posterwall.editor.setPoster(_98);
}
}
Posterwall.selector.deselect();
this.stopFollowing();
}}),SourceSelectionControl:new Class({selectionid:false,initialize:function(_99){
for(var lc=$(new String(_99)).firstChild;lc;lc=lc.nextSibling){
if(lc.nodeType!=1||lc.nodeName.toLowerCase()!="li"){
continue;
}
lc=$(lc);
var a=Posterwall.findfirst(lc,"a");
var _9c=new Posterwall.Image(a.getProperty("href"));
if(!lc.getProperty("id")){
lc.setProperty("id","piclist_"+_9c.id);
}
lc.addEvent("click",this.onclick.bindWithEvent(this));
var img=Posterwall.findfirst(a,"img");
_9c.thumb_url=img.src;
_9c.height=img.height;
_9c.width=img.width;
Posterwall.set.put(_9c.id,_9c);
}
this.selectionid=false;
},deselect:function(){
if(!this.selectionid){
return;
}
$(this.selectionid).removeClass("piclistselected");
this.selectionid=false;
},onclick:function(ev){
if(this.selectionid){
$(this.selectionid).removeClass("piclistselected");
Posterwall.dropper.stopFollowing(this.selectionid);
}
var _9f=false;
for(var _a0=$(ev.target);_a0;_a0=$(_a0.parentNode)){
if(_a0.nodeName.toLowerCase()=="li"){
_9f=_a0;
break;
}
}
var id=_9f.getProperty("id");
var _a2=id.replace("piclist_","");
var _a3=Posterwall.set.get(_a2);
if(id==this.selectionid){
this.selectionid=false;
Posterwall.dropper.stopFollowing(this.selectionid);
}else{
if(Posterwall.grid.getPosterByImageId(_a2)==false){
Posterwall.editor.toggleVisibility(false);
this.selectionid=id;
_9f.addClass("piclistselected");
Posterwall.dropper.startFollowing(ev,_a3);
}
}
ev.stopPropagation();
return false;
}}),ondomready:function(ev){
Posterwall.set=new Posterwall.Set();
Posterwall.grid=new Posterwall.Grid("posterwall",Posterwall.GRIDSIZE);
Posterwall.gridstore=new Posterwall.GridStore();
Posterwall.selector=new Posterwall.SourceSelectionControl("piclist");
Posterwall.dropper=new Posterwall.GridControl();
Posterwall.editor=new Posterwall.PosterControl();
window.addEvent("unload",Posterwall.gridstore.onunload.bindWithEvent(Posterwall.gridstore));
window.addEvent("unload",Posterwall.grid.onunload.bindWithEvent(Posterwall.grid));
},onunload:function(ev){
Posterwall.dropper=false;
Posterwall.selector=false;
Posterwall.grid=false;
Posterwall.set=false;
Posterwall.editor=false;
}};
window.addEvent("load",Posterwall.ondomready.bindWithEvent(Posterwall));
window.addEvent("unload",Posterwall.onunload.bindWithEvent(Posterwall));
demo={state:"none",toggle:function(ev){
if(this.state=="block"){
this.state="none";
}else{
this.state="block";
}
$("about_text").setStyle("display",this.state);
Event.stopPropagation(ev);
},onload:function(ev){
$("about_title").addEvent("click",this.toggle.bindWithEvent(this));
var t=$("about_text");
var e=$(document.createElement("p"));
t.appendChild(e);
var a=$(document.createElement("a"));
a.setProperty("href","javascript:void(0)");
a.setProperty("title","Close this dialog");
a.addEvent("click",this.toggle.bindWithEvent(this));
a.appendChild(document.createTextNode("Close"));
e.appendChild(a);
}};
window.addEvent("load",demo.onload.bindWithEvent(demo));

