var Preloader=Class.create({initialize:function(){
this.preloadImages=[];
this.loadedImagePaths=[];
this.bObj=this.onImageLoad.bind(this);
},addToQueue:function(_1){
if(typeof _1=="string"){
this.preloadImages.push(_1);
}else{
if(typeof _1=="array"||typeof _1=="object"){
for(var i=0;i<_1.length;i++){
this.preloadImages.push(_1[i]);
}
}
}
},startLoading:function(){
this.loadNext();
},loadNext:function(){
if(this.preloadImages.length==0){
return;
}
var _3=this.preloadImages.shift();
var _4=Element.extend(document.createElement("img"));
var _5=$$("body")[0];
_4.setStyle({display:"none"});
_5.insert({bottom:_4});
Event.observe(_4,"load",this.bObj);
Event.observe(_4,"error",this.bObj);
_4.setAttribute("src",_3);
},hasPathLoaded:function(_6){
for(var i=0;i<this.loadedImagePaths.length;i++){
var _8=parseUri(this.loadedImagePaths[i]);
if(_8.relative==_6){
return true;
}
}
return false;
},onImageLoad:function(ev){
this.loadedImagePaths.push(ev.element().src);
Event.stopObserving(ev.element(),"load",this.bObj);
Event.stopObserving(ev.element(),"error",this.bObj);
ev.element().remove();
if(this.preloadImages.length!=0){
this.loadNext();
}
}});
function parseUri(_a){
var o=parseUri.options,m=o.parser[o.strictMode?"strict":"loose"].exec(_a),_d={},i=14;
while(i--){
_d[o.key[i]]=m[i]||"";
}
_d[o.q.name]={};
_d[o.key[12]].replace(o.q.parser,function($0,$1,$2){
if($1){
_d[o.q.name][$1]=$2;
}
});
return _d;
}
parseUri.options={strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};

