function Photostream(img,next_url,is_search,data,pid,page){if(next_url){(new Image()).src=next_url;} if(ua.safari()<500){return;} copy_properties(this,{data:copy_properties(data,{async:true}),seq:0,pid:pid,img:img,minseq:0,isSearch:is_search});copy_properties(this,{error:0,album:null,jumps:{},unseen:null,cursor:null,queue:new TaskQueue(),events:new EventController(this),loads:[],pagesize:20,fetched:{},pending:1,readied:false});copy_properties(this,{displayPosition:$('photo_count'),displayCaption:$('photocaption'),displayPhototags:$('phototags'),displayShare:$($('additional_info').getElementsByTagName('a')[0]),displayAdded:$('photodate'),displayComments:$('photocomment'),displayForm:ge('photo_comment_post'),displayNext:ge('photo_form_next'),displayBadge:$('photo_badge'),displayActions:$('photoactions'),displayProps:ge('props_container'),photolink:$('myphotolink'),displayLoad:$('load_indicator'),displayContext:$('photoinalbum'),displayCmtForm:$('photoaddcomment')});if(ua.firefox()){this.photolink.onfocus=this.photolink.blur.bind(this.photolink);} var next=bind(this.events,'addEvent','next');var prev=bind(this.events,'addEvent','prev');(ge('photonav_next')||{}).onclick=next;(ge('photonav_prev')||{}).onclick=prev;this.img.onclick=chain(this.onimageclick.bind(this),next);this.img.onload=null;if(ua.ie()<7){this.img.galleryimg="no";} KeyEventController.registerKey('RIGHT',next);KeyEventController.registerKey('LEFT',prev);this.didGetAlbumResponse(new AsyncResponse(page));Quickling.registerURIHandler(bind(this,'onfragmentchange'));var info=this.album[this.jumps[this.pid]];if(this.isSearch){Quickling.setCanonicalLocation('#pid='+info.pid+'&id='+info.id);}else{Quickling.setCanonicalLocation('#pid='+info.pid);}};copy_properties(Photostream.prototype,{debug:bagofholding,requestPage:function(page){if(this.fetched[page]){return;} this.fetched[page]=true;this.pending++;new AsyncRequest().setURI(this.isSearch?'/photo_search.php':'/album.php').setMethod('GET').setReadOnly(true).setData(copy_properties(this.data,{page:page})).setHandler(bind(this,'didGetAlbumResponse')).setErrorHandler(bind(this,'didGetAlbumError')).setTransportErrorHandler(bind(this,'didGetAlbumError')).send();},onnext:function(e){this.readPhotoState();this.cursor=(this.cursor+1)%this.album.length;return this.update();},onimageclick:function(e){return imageClick(event_get(e),this.img);},onprev:function(e){this.readPhotoState();this.cursor=((this.cursor-1)+this.album.length)%this.album.length;return this.update();},readPhotoState:function(){if(this.album[this.cursor]){this.album[this.cursor].tags=this.displayPhototags.innerHTML.replace(/\\\//g,'/');this.album[this.cursor].photo_tags=photo_tags;}},update:function(){if(this.error){return true;} if(!this.readied){this.readied=true;var stepsAhead=env_get('ps_rate')||(5);this.queue.setOption('concurrency',stepsAhead).ready(stepsAhead);} if(ge('changessaved')){remove_node(ge('changessaved'));} if(ge('photocrop_error')){remove_node(ge('photocrop_error'));} var info=this.album[this.cursor];if(this.displayPosition){var pos=sprintf('Photo %d of %d',this.cursor+1,this.album.length);DOM.setText(this.displayPosition,pos);} if(info){var img=document.createElement('img');copy_properties(img.style,{display:'none'});if(this.isSearch){Quickling.go('#pid='+info.pid+'&id='+info.id,false);}else{Quickling.go('#pid='+info.pid,false);} if(!info.seen){var hi_bound=(parseInt(this.cursor/this.pagesize)+1)*this.pagesize;var near_edge=((hi_bound-this.cursor)<=3);info.seen=true;--this.unseen;if(near_edge&&!this.pending){var cur_page=parseInt(this.cursor/this.pagesize)+1;var max_page=parseInt((this.album.length-1)/this.pagesize)+1;var get_page=null;for(ii=cur_page+1;ii<=max_page;ii++){if(!this.fetched[ii]){get_page=ii;break;}} if(get_page===null){for(ii=1;ii