/*1306641323,176833974*/

if (window.CavalryLogger) { CavalryLogger.start_js(["v9\/OW"]); }

function PhotoFaceBox(b,c,a){copy_properties(this,{centerPoint:new Vector2(b,c),photoFbid:a});PhotoFaceBox._photoboxList[a]=PhotoFaceBox._photoboxList[a]||[];PhotoFaceBox._photoboxList[a].push(this);}copy_properties(PhotoFaceBox,{_photoboxList:{},faceBoxesForPhoto:function(a){return PhotoFaceBox._photoboxList[a]||[];},clearFaceBoxesForPhoto:function(a){PhotoFaceBox._photoboxList[a]=[];}});copy_properties(PhotoFaceBox.prototype,{_removeLocal:function(){var c=this.photoFbid;var d=PhotoFaceBox._photoboxList[c]||[];for(var a=0,b=d.length;a<b;a++)if(d[a]==this){d.splice(a,1);break;}},getCenterPoint:function(){return this.centerPoint;}});
function PhotoTag(a,b,d,c){copy_properties(this,{centerPoint:new Vector2(a/100,b/100),photoOwnerId:d,photoId:c,qn:null});copy_properties(this,{taggeeName:'',taggeeId:null,taggeeEmail:'',scale:1,source:'',_saved:false,_pendingAsync:false});}copy_properties(PhotoTag,{SYNCING_ENDPOINT:'/ajax/photo_tagging_ajax.php',MAX_USER_TAGS_PER_PHOTO:50,_tagList:{},_photoKey:function(a,b){return a+':'+b;},tagsForPhoto:function(a,c){var b=PhotoTag._photoKey(a,c);return PhotoTag._tagList[b]||[];},clearTagsForPhoto:function(a,c){var b=PhotoTag._photoKey(a,c);PhotoTag._tagList[b]=[];}});copy_properties(PhotoTag.prototype,{setTaggeeEmail:function(a){if(this.saved){return this;}else this.taggeeEmail=a;return this;},setTaggeeName:function(a){if(this.saved){return this;}else this.taggeeName=a;return this;},setTaggeeId:function(a){if(!(this.saved))this.taggeeId=a;return this;},setQueueName:function(a){if(!this._qn)this._qn=a;return this;},absoluteCenter:function(b,a){return this.centerPoint.mul(b,a);},submit:function(b){if(!this.taggeeName&&!this.taggeeId){return;}else if(this._saved){return;}else if(this._pendingAsync){return;}else if(PhotoTag.MAX_USER_TAGS_PER_PHOTO<=PhotoTag.tagsForPhoto(this.photoId,this.photoOwnerId).length)return;b=b||bagofholding;var a={pid:this.photoId,id:this.photoOwnerId,subject:this.taggeeId,name:this.taggeeName,email:this.taggeeEmail,action:'add',x:this.centerPoint.x*100,y:this.centerPoint.y*100,scale:this.scale,source:this.source};if(this._qn)a.qn=this._qn;this._pendingAsync=true;new AsyncRequest().setURI(PhotoTag.SYNCING_ENDPOINT).setData(a).setHandler(bind(this,this._submitHandler,b)).setErrorHandler(bind(this,this._submitHandler,b)).setFinallyHandler(bind(this,function(){this._pendingAsync=false;})).send();},remove:function(c,a){if(!this.taggeeName&&!this.taggeeId){return;}else if(this._pendingAsync){return;}else if(!this._saved){this._removeLocal();return c(this,{});}c=c||bagofholding;var b={pid:this.photoId,id:this.photoOwnerId,subject:this.taggeeId,name:this.taggeeName,action:a||'remove'};this._pendingAsync=true;new AsyncRequest().setURI(PhotoTag.SYNCING_ENDPOINT).setData(b).setHandler(bind(this,this._removeHandler,c)).setFinallyHandler(bind(this,function(){this._pendingAsync=false;})).send();return false;},_removeLocal:function(){var c=PhotoTag._photoKey(this.photoId,this.photoOwnerId);var d=PhotoTag._tagList[c]||[];for(var a=0,b=d.length;a<b;a++)if(d[a]==this){d.splice(a,1);break;}},setLocalSave:function(){var b=PhotoTag._photoKey(this.photoId,this.photoOwnerId);var a=PhotoTag._tagList[b]=PhotoTag._tagList[b]||[];PhotoTag._tagList[b][a.length]=this;return this;},setSaved:function(){this._saved=true;return this.setLocalSave();},getText:function(){return this.taggeeName||this.taggeeEmail;},getTaggeeId:function(){return this.taggeeId;},setScale:function(a){this.scale=a;return this;},setSource:function(a){this.source=a;return this;},setSource:function(a){this.source=a;return this;},_submitHandler:function(a,d){var b=d.getError();var c=d.getPayload();if(b){ErrorDialog.showAsyncError(d);if(!c['tag_success'])return;}this.setSaved();this.taggeeName=c.taggeeName;this.taggeeId=c.taggeeId;a(this,c);},_removeHandler:function(a,b){this._removeLocal();(a||bagofholding)(this,b.getPayload());}});
function PhotosTaggingWaterfall(a){PhotosTaggingWaterfall._queueName=a||PhotosTaggingWaterfall._queueName;}copy_properties(PhotosTaggingWaterfall,{BEGIN:"begin",TAG_FACE:"tag_face",ADD_NAME:"add_name",TAG_CONFIRMED:"tag_confirmed",FINISH:"finish",TYPE_NAME:'type_name',SELECT_NAME:'select_name',_queueName:null,sendSignal:function(b,a){new AsyncSignal('/ajax/photos/tag_waterfall.php',{data:JSON.stringify(b)}).setHandler(a).send();}});
var PhotoPageTags={removeCallback:function(b,a){PhotoPageTags._replaceTagHtml(a);PhotoTagViewer.getInstance('myphoto').hideTag();PhotoPageTags.resetInstructions();},addCallback:function(c,a){PhotoPageTags._replaceTagHtml(a);var e=htmlize(c.getText());var b=htmlize(a.photoOwnerName);var d='';if(a.tag_success){d='<b>';if(!a.tags_need_approval){if(a.user==c.getTaggeeId()){d+=_tx("Se ha guardado tu autoetiqueta.");}else d+=_tx("Se ha guardado la etiqueta de {name}.",{name:e});}else if(a.user==c.getTaggeeId()){d+=_tx("Tu solicitud de etiquetado ha sido enviada a {photo-owner} para su aprobaci\u00f3n",{'photo-owner':b});}else d+=_tx("Se ha enviado a {photo-owner} una solicitud de etiquetado de {name} para su aprobaci\u00f3n",{name:e,'photo-owner':b});d+='</b>.<br/>';}else d='<b style="color:red">'+_tx("Se ha producido un error al etiquetar esta foto. Int\u00e9ntalo m\u00e1s tarde.")+'</b><br />';if(a.invite_sent)d+='<b style="color: green">'+_tx("Se ha enviado una invitaci\u00f3n y una solicitud de amigo a {name}",{name:e})+'</b><br/>';if(!a.tags_need_approval){d+=_tx("Puedes continuar etiquetando la foto abajo.");}else d+=_tx("Puedes seguir solicitando etiquetas en la siguiente foto.");d+='<br/>'+_tx("Cuando hayas terminado, haz clic en el bot\u00f3n \"Finalizar etiquetado\" para seguir usando Facebook.");hide('tagging_instructions_default_message');DOM.setContent($('tagging_instructions_status_message'),HTML(d));PhotoPageTags.focusInstructions();},showTaggingUI:function(a){window.photocrop&&window.photocrop.destroy();show('tagging_instructions');PhotoTagController.getInstance('myphoto').enableTagging(PhotoPageTags.addCallback);PhotoPageTags.resetInstructions();PhotoPageTags.focusInstructions();if(a!='ignore'){data={context:a};new AsyncSignal('/ajax/photos/tagbutton.php',{data:JSON.stringify(data)}).send();}if(ge('untagged_message'))DOM.remove('untagged_message');},_replaceTagHtml:function(a){DOM.setContent($('phototags_row'),HTML(a.tag_html));DOM.setContent($('photo_tag_boxes'),HTML(a.tag_boxes));},resetInstructions:function(){if(!ge('tagging_instructions_status_message'))return;DOM.empty('tagging_instructions_status_message');show('tagging_instructions_default_message');},hideTaggingUI:function(){hide('tagging_instructions');if(PhotoTagController.getInstance('myphoto'))PhotoTagController.getInstance('myphoto').disableTagging();},focusInstructions:function(){if(ge('tagging_instructions')){var a=Vector2.getElementPosition($('tagging_instructions'));if(Vector2.getScrollPosition().y>a.y)DOMScroll.scrollTo(a.sub(0,8));}}};
function PhotoTagViewer(c){if(PhotoTagViewer._instances[c])return PhotoTagViewer._instances[c];copy_properties(this,{minTagDistance:83,photoElementId:c,photoOwnerId:null,photoId:null,photoObjectId:null,tagShowCallback:bagofholding,tagHideCallback:bagofholding,showingTag:null,showingFaceBox:null,tagFrame:null,tagNameFrame:null,faceBoxNameFrame:null,_taggingEnabled:false});this._getPhotoElement=bind(null,ge,c);this._destruct=function(){b.remove();this.hideTag();this.tagHideCallback();this.hideFaceBoxText();this.showingFaceBox=null;delete PhotoTagViewer._instances[c];};this._wait_for_load=function(d){d.deferUntil(image_has_loaded.bind(this,this._getPhotoElement()),100);};if(!this._getPhotoElement())throw new Error('No images with the id `'+c+'\' '+'found on the page.  PhotoTagViewer Abort.');var a=bind(this,this._photoMouseMove);var b=Event.listen(document,'mousemove',a);onleaveRegister(bind(this,this._destruct));PhotoTagViewer._instances[c]=this;}copy_properties(PhotoTagViewer,{_instances:{},_tagThisFriendText:'',_showFaceBoxes:false,_alwaysShowFaceBoxes:false,getInstance:function(a){return PhotoTagViewer._instances[a];},setTagThisFriendText:function(a){PhotoTagViewer._tagThisFriendText=a;},getTagThisFriendText:function(){return PhotoTagViewer._tagThisFriendText;},setShowFaceBoxes:function(a){PhotoTagViewer._showFaceBoxes=a;},getShowFaceBoxes:function(){return PhotoTagViewer._showFaceBoxes;},setAlwaysShowFaceBoxes:function(a){PhotoTagViewer._alwaysShowFaceBoxes=a;},getAlwaysShowFaceBoxes:function(){return PhotoTagViewer._alwaysShowFaceBoxes;}});copy_properties(PhotoTagViewer.prototype,{setPhotoData:function(c,b,a){this.photoOwnerId=c;this.photoId=b;this.photoFbid=a;this.hideTag();this.tagHideCallback();this.hideFaceBoxText();this.showingFaceBox=null;return this;},setPhotoObjectId:function(a){this.photoObjectId=a;return this;},setMinTagDistance:function(a){this.minTagDistance=a;return this;},registerTagHover:function(b,a){if(!b&&!a){this.tagShowCallback=bind(this,this.showTagText);this.tagHideCallback=bind(this,this.hideTagText);}else{this.tagShowCallback=b;this.tagHideCallback=a;}return this;},enableTagging:function(){this._taggingEnabled=true;},disableTagging:function(){this._taggingEnabled=false;},shouldShowBoxes:function(){return !this._taggingEnabled||(PhotoTagViewer.getAlwaysShowFaceBoxes()&&!shown($('photo_tag_selector')));},_photoClick:function(event){if(!this._getPhotoElement())return this._destruct();if(!this._taggingEnabled)return true;var a=PhotoTag.tagsForPhoto(this.photoId,this.photoOwnerId);if(PhotoTag.MAX_USER_TAGS_PER_PHOTO<=a.length){ErrorDialog.show(_tx("Demasiadas etiquetas"),_tx("Sent\u00edmolo, non puidemos gardar a t\u00faa etiqueta porque esta foto cont\u00e9n o m\u00e1ximo n\u00famero de etiquetas permitidas. Para m\u00e1is informaci\u00f3n, por favor visita O \u003ca href=\"\/help\/?faq=16974\">Centro de Axuda\u003c\/a>."));return $E(event).kill();}},showTag:function(a){if(!this._getPhotoElement())return this._destruct();if(!a)return;if(this._isPhotoCropOn())return;this._wait_for_load(this._showTag.bind(this,a));},_showTag:function(f){if(!this.tagFrame){var e=document.createElement('div');e.style.width=(2*this.minTagDistance)+'px';e.style.height=(2*this.minTagDistance)+'px';CSS.addClass(e,'photo_tag_frame_inside');this.tagFrame=$N('div',null,e);CSS.addClass(this.tagFrame,'photo_tag_frame');this.tagFrame.onclick=bind(this,this._photoClick);DOM.appendContent(document.body,this.tagFrame);}var d=Vector2.getElementPosition(this._getPhotoElement());var c=Vector2.getElementDimensions(this._getPhotoElement());var i=f.absoluteCenter(c.x,c.y);var a=this._calculateWithinBounds(i,2*this.minTagDistance,this._getPhotoElement());var g=new Vector2(a.size,a.size);var h=g.mul(.5,.5);g.setElementDimensions(DOM.find(this.tagFrame,'div.photo_tag_frame_inside'));new Vector2(-10000,-100000,'document').setElementPosition(this.tagFrame);show(this.tagFrame);var b=Vector2.getElementDimensions(this.tagFrame).sub(a.size,a.size).mul(.5,.5);d.add(a.tagPosition).sub(h).sub(b).setElementPosition(this.tagFrame);},hideTag:function(){hide(this.tagFrame);},showTagText:function(a){if(!this._getPhotoElement())return this._destruct();if(!a||this._taggingEnabled)return;this._wait_for_load(this._showTagText.bind(this,a));},_showTagText:function(c){if(this.tagNameFrame)this.hideTagText();if(this._isPhotoCropOn())return;var a=Vector2.getElementDimensions(this._getPhotoElement());var d=c.absoluteCenter(a.x,a.y);var b=Vector2.getElementPosition(this._getPhotoElement());this.tagNameFrame=this._showText(d,b,c.getText(),null);},showFaceBoxText:function(a){if(!this._getPhotoElement())return this._destruct();if(!a||!this.shouldShowBoxes())return;this._wait_for_load(this._showFaceBoxText.bind(this,a));},_showFaceBoxText:function(d){if(this._isPhotoCropOn())return;this.hideFaceBoxText();this.faceBoxFrame=[];var l=d.getCenterPoint();var c=bind(this,this._faceBoxClickCallback,d);var h=$N('div',{className:'photo_tag_frame_inside'});var e=$N('div',{className:'photo_tag_frame',onclick:c},h);CSS.addClass(e,'facebox_frame');DOM.appendContent(document.body,e);var g=Vector2.getElementPosition(this._getPhotoElement());var f=Vector2.getElementDimensions(this._getPhotoElement());var a=this._calculateWithinBounds(l,2*this.minTagDistance,this._getPhotoElement());var j=new Vector2(a.size,a.size);var k=j.mul(.5,.5);j.setElementDimensions(DOM.find(e,'div.photo_tag_frame_inside'));var b=Vector2.getElementDimensions(e).sub(a.size,a.size).mul(.5,.5);g.add(a.tagPosition).sub(k).sub(b).setElementPosition(e);this.faceBoxFrame.push(e);var i=this._showText(l.add(0,12),g,PhotoTagViewer.getTagThisFriendText(),c);this.faceBoxFrame.push(i);},_showText:function(e,c,f,b){if(b){var d=$N('a',{onclick:b,className:'photo_box_name_link'},f);}else var d=$N('span',null,f);var g=$N('div',null,d);if(b){CSS.addClass(g,'photo_box_name_frame');}else CSS.addClass(g,'photo_tag_name_frame');DOM.appendContent(document.body,g);var a=this._calculateWithinBounds(e,1.2*this.minTagDistance,this._getPhotoElement());var h=Vector2.getElementDimensions(g);var i=new Vector2(h.x/2,(h.y-a.size)/2-9);c.add(a.tagPosition).sub(i).setElementPosition(g);show(g);return g;},_faceBoxClickCallback:function(b){this.showingFaceBox=null;this.hideFaceBoxText();var a=new PhotoTagController(this.photoElementId).setPhotoData(this.photoOwnerId,this.photoId,this.photoFbid);PhotoPageTags.showTaggingUI('facebox');PhotoTagSelector.init();a.enableTaggingForFaceBox(b);},hideTagText:function(){if(this.tagNameFrame)DOM.remove(this.tagNameFrame);this.tagNameFrame=null;},hideFaceBoxText:function(){if(this.faceBoxFrame)for(var a=0;a<this.faceBoxFrame.length;a++)DOM.remove(this.faceBoxFrame[a]);this.faceBoxFrame=null;},_forceWithinBounds:function(c,b,a){c=c.sub(0,0);if(c.x<b){c.x=Math.min(b,a.x);}else if(c.x>a.x-b)c.x=Math.max(0,a.x-b);if(c.y<b){c.y=Math.min(b,a.y);}else if(c.y>a.y-b)c.y=Math.max(0,a.y-b);return c;},_calculateWithinBounds:function(i,b,c){var e=Vector2.getElementPosition(c);var d=Vector2.getElementDimensions(c);var f=Math.max(i.x-b/2,0);var g=Math.min(i.x+b/2,d.x);var j=Math.max(i.y-b/2,0);var a=Math.min(i.y+b/2,d.y);var i=new Vector2((g+f)/2,(j+a)/2);var h=Math.min(g-f,a-j);return {tagPosition:i,size:h};},_photoMouseMove:function(event){if(!this._getPhotoElement())return this._destruct();if(!this.shouldShowBoxes())return;var e=PhotoTag.tagsForPhoto(this.photoId,this.photoOwnerId);var d=PhotoFaceBox.faceBoxesForPhoto(this.photoFbid);var b=Vector2.getEventPosition(event);var a=Vector2.getElementPosition(this._getPhotoElement());var c=b.sub(a);if(e.length>0){if(PhotoTagViewer.getAlwaysShowFaceBoxes())this._photoMouseMoveFaceBoxes(c,d);this._photoMouseMoveTags(c,e);}else if((PhotoTagViewer.getShowFaceBoxes()||PhotoTagViewer.getAlwaysShowFaceBoxes())&&d.length>0)this._photoMouseMoveFaceBoxes(c,d);},_photoMouseMoveTags:function(f,g){if(!this.tagShowCallback&&!this.tagHideCallback)return;var c=Vector2.getElementDimensions(this._getPhotoElement());if(f.x>0&&f.x<c.x&&f.y>0&&f.y<c.y){var d=c.magnitude();var e=null;for(var b=0;b<g.length;b++){var a=g[b].absoluteCenter(c.x,c.y);var i=a.sub(f);var h=i.magnitude();if(Math.abs(i.x)<=this.minTagDistance&&Math.abs(i.y)<=this.minTagDistance&&h<=d){d=h;e=g[b];if(0==h)break;}}}if(!e&&this.showingTag&&this.tagHideCallback){this.showingTag=null;this.tagHideCallback(this.showingTag);}else if(e&&this.tagShowCallback&&e!=this.showingTag){this.showingTag=e;this.tagShowCallback(e);}},_photoMouseMoveFaceBoxes:function(f,g){var c=Vector2.getElementDimensions(this._getPhotoElement());var d=c.magnitude();var e=null;if(f.x>0&&f.x<c.x&&f.y>0&&f.y<c.y){for(var b=0;b<g.length;b++){var a=g[b].getCenterPoint();var i=a.sub(f);var h=i.magnitude();if(h<=d){d=h;e=g[b];if(0==h)break;}}if(!e&&this.showingFaceBox){this.showingFaceBox=null;this.hideFaceBoxText();}else if(e&&e!=this.showingFaceBox){this.showingFaceBox=e;this.showFaceBoxText(e);}}else{this.showingFaceBox=null;this.hideFaceBoxText();}},_isPhotoCropOn:function(){return window.photocrop&&window.photocrop.instance&&true;}});
PhotoTagSelector=function(){var zd;var zh;var f;var t=null;var h=[];var i=[];var u=false;var x=null;var z=null;var v=null;var w=null;var b=false;var c=false;var s=false;var o=false;var zf=bagofholding;var n=bagofholding;var zg=[];var zi=0;var m=false;var e=function(){zh.value='';f.value='';m=false;PhotoTagSelector.exitInviteMode();};var p=function(){return !!ge('photo_tag_selector');};var y=function(){if(!p())return;var zl=zh.value.toLowerCase().trim();zl=typeahead_source.flatten_string(zl);var zo=[];var zp=[];for(var zk=0,zm=h.length;zk<zm;zk++){var zj=h[zk];if(!zl||q(zl,zj))(zj.rel?zp:zo).push(zj.fragment);}zi=zo.length+zp.length;if(0==zi||o){hide('pts_userlist','pts_userlistlabel','pts_choose_text','pts_invite_msg');if(b){ze();}else hide('pts_invite_section');return;}show('pts_userlist','pts_userlistlabel','pts_choose_text');hide('pts_invite_section');if(b)show('pts_invite_msg');var zq='';if(0!=zo.length&&0!=zp.length)zq='<hr />';var zn=zp.join('')+zq+zo.join('');DOM.setContent($('pts_userlist'),HTML(zn));if((1==zi)&&zl)DOM.find($('pts_userlist'),'input[type="checkbox"]').checked=true;};var q=function(zm,zj){var zl=zm.split(' ');for(var zk=0;zk<zl.length;zk++)if(-1==zj.flat_name.indexOf(zl[zk]))return false;return true;};var j=function(){if(t&&!s){return za();}else if(u)return false;u=true;s=false;new AsyncRequest().setHandler(l).setErrorHandler(k).setFinallyHandler(function(){u=false;}).setURI('/ajax/photos_tag_options.php').setData({pid:v,id:x,oid:w,page_tag:c}).setMethod('GET').setReadOnly(true).send();};var zb=function(){h=t;if(!zg)return;for(var zj=0,zk=zg.length;zj<zk;zj++)if(zg[zj].id>0){h=h.filter(function(zl){return zg[zj].id!=zl.id;});}else h=h.filter(function(zl){return zg[zj].id!=zl.id||zg[zj].name.toLowerCase()!=zl.name.toLowerCase();});};var l=function(zl){h=t=zl.getPayload();for(var zj=0,zk=t.length;zj<zk;zj++)g(t[zj]);za();};var k=function(zj){PhotoTagSelector.hide();AsyncResponse.verboseErrorHandler(zj);};var g=function(zj){zj.flat_name=typeahead_source.flatten_string(zj.name);var zk='PhotoTagSelector._checkboxClick(this, '+parseInt(zj.id,10)+", '"+escape_js_quotes(zj.name)+"');";zj.fragment='<label><input type="checkbox" onclick="'+zk+'" />'+htmlize(zj.name)+'</label>';};var a=function(zj){i.push(zj);};var za=function(){for(var zj=0,zk=i.length;zj<zk;zj++)i[zj]();i=[];};var r=function(event){switch(Event.getKeyCode(event)){case KEYS.RETURN:d();break;case KEYS.ESC:PhotoTagSelector.hide();break;default:setTimeout(y,0);m=true;}};var d=function(){var zk=0;var zl='';var zj='';if(''!=f.value.trim()){zj=f.value.trim();zl=zh.value.trim();}else if(1==zi){var zm=DOM.find($('pts_userlist'),'input[type="checkbox"]');if(zm.checked){return zm.onclick();}else zl=zh.value.trim();}else zl=zh.value.trim();zc(zk,zl,zj);};var zc=function(zm,zo,zj){zm=zm||0;zo=zo||'';zj=zj||'';if(!zo&&!zm)return;zf(zm,zo,zj,m);PhotoTagSelector.hide();if(zm){for(var zl=0,zn=t.length;zl<zn;zl++)if(t[zl].id==zm){t[zl].rel=true;break;}}else if(!zj){var zk=false;for(var zl=0,zn=t.length;zl<zn;zl++)if(!t[zl].id&&t[zl].name==zo){t[zl].rel=true;zk=true;break;}if(!zk){var zp={name:zo,rel:true,id:0};g(zp);t.unshift(zp);}}};var ze=function(){var zk=zh.value.trim();var zj;if(zk){var zl=zk.indexOf(' ');zj=zl>-1?zk.substr(0,zl):zk;}else zj=_tx("tu amigo\/a");DOM.setContent($('pts_invite_name'),zj);show('pts_invite_section');};return {init:function(){if(p())return;var zj='<span id="pts_invite_name">'+_tx("tu amigo\/a")+'</span>';markup='<label for="name" id="label_name" class="pts_name_input">';markup+=_tx("Escribe un nombre o etiqueta:");markup+='</label>';markup+='<input type="text" class="inputtext i_name" size="20"';markup+='autocomplete="off" id="pts_name_input"/>';markup+='<span id="pts_choose_text">';markup+=_tx("o elige una persona:");markup+='</span>';markup+='<div id="pts_userlist">';markup+='<div style="margin: 4px;">';markup+=_tx("Cargando amigos...");markup+='</div>';markup+='</div>';markup+='<div id="pts_invite_section" style="display: none;">';markup+=_tx("Introduce el correo electr\u00f3nico de {name}. Le enviaremos un enlace con esta foto y le a\u00f1adiremos a tu lista de amigos.",{name:zj});markup+='<div>';markup+='<label for="pts_invite_email" id="label_pts_invite_email">';markup+=_tx("Correo electr\u00f3nico:");markup+='</label>';markup+='<input type="text" class="inputtext" id="pts_invite_email" name="pts_invite_email" value="" />';markup+='</div>';markup+='</div>';markup+='<div id="pts_invite_msg" class="hidden_elem">';markup+='<strong>';markup+=_tx("\u00bfLa persona no usa Facebook?");markup+='</strong>';markup+='<div>';markup+='<a onclick="PhotoTagSelector.enterInviteMode()">';markup+=_tx("Haz clic aqu\u00ed para etiquetarlos.");markup+='</a>';markup+='</div>';markup+='</div>';markup+='<div class="buttons">';markup+='<input type="button" class="inputbutton" id="tag" name="tag" value="'+_tx("Etiquetar")+'" />';markup+='<input type="button" class="inputbutton inputaux" id="cancel" name="cancel" value="'+_tx("Cancelar")+'" />';markup+='</div>';zd=$N('div',null,HTML(markup));zd.id='photo_tag_selector';ge('content').appendChild(zd);f=$('pts_invite_email');f.onkeydown=r;zh=$('pts_name_input');zh.onkeydown=r;DOM.find(zd,'input[name="tag"]').onclick=d;DOM.find(zd,'input[name="cancel"]').onclick=this.hide;},prime:function(){j();return this;},hide:function(){n();if(!p())return;zd.style.display='none';zf=bagofholding;n=bagofholding;x=null;v=null;w=null;zg=[];zi=0;e();return this;},showAt:function(zj){zj.setElementPosition(zd);zd.style.display='block';a(zb);a(y);a(function(){zh.focus();});j();return this;},setTagCallback:function(zj){zf=zj;return this;},setHideCallback:function(zj){n=zj;return this;},setTaggedPeople:function(zj){zg=zj;return this;},setPhotoOwner:function(zj){x=zj;if(c&&x!=z){z=x;s=true;}return this;},setPhotoId:function(zj){v=zj;return this;},setPhotoObjectId:function(zj){w=zj;return this;},setAllowEmailTags:function(zj){b=zj;return this;},setAllowPageTag:function(zj){if(zj!=c){s=true;}else s=false;c=zj;return this;},enterInviteMode:function(){o=true;hide('pts_userlist','pts_userlistlabel','pts_choose_text','pts_invite_msg');ze();if(zh.value){var zj=DOM.find($('pts_invite_section'),'input[name="pts_invite_email"]');zj.focus();}else zh.focus();return this;},exitInviteMode:function(){o=false;hide('pts_invite_section');if(b)show('pts_invite_msg');return this;},_checkboxClick:function(zj,zk,zl){if(!zj||!zj.checked)return;zc(zk,zl);}};}();function PhotoTagController(a){if(PhotoTagController._instances[a])return PhotoTagController._instances[a];var b=PhotoTagViewer.getInstance(a);if(!b)b=new PhotoTagViewer(a);copy_properties(this,{photoElementId:a,photoOwnerId:null,photoId:null,photoFbid:null,photoObjectId:null,_qn:null,_taggingEnabled:false,_tagCallbackFn:bagofholding,_autoSubmitTags:true,viewerObject:b,scale:1,source:''});this._getPhotoElement=bind(null,ge,a);this._destruct=function(){PhotoTagSelector.hide();this.viewerObject._destruct();if(this._taggingEnabled)this._sendWaterfallLogSignal(PhotosTaggingWaterfall.FINISH);delete PhotoTagController._instances[a];};this._wait_for_load=function(c){c.deferUntil(image_has_loaded.bind(this,this._getPhotoElement()),100);};if(!this._getPhotoElement())throw new Error('No images with the id `'+a+'\' '+'found on the page.  PhotoTagController Abort.');onleaveRegister(bind(this,this._destruct));Event.listen(this._getPhotoElement(),'click',bind(this,this._photoClick),Event.Priority.TRADITIONAL);PhotoTagController._instances[a]=this;}copy_properties(PhotoTagController,{_instances:{},getInstance:function(a){return PhotoTagController._instances[a];}});copy_properties(PhotoTagController.prototype,{setPhotoData:function(c,b,a){this.photoOwnerId=c;if(b!=this.photoId){if(this.photoId)Event.listen(this._getPhotoElement(),'click',bind(this,this._photoClick),Event.Priority.TRADITIONAL);this.photoId=b;}this.photoFbid=a;PhotoTagSelector.hide();this.viewerObject.setPhotoData(c,b,a);return this;},setPhotoObjectId:function(a){this.photoObjectId=a;return this;},setQueueName:function(a){this._qn=a;return this;},_randomizeQueueName:function(){if(this._qn)this._qn+=Math.floor(Math.random()*60);},_sendWaterfallLogSignal:function(c,a){if(this._qn){var b={qn:this._qn,step:c,pid:this.photoId,source:this.source};copy_properties(b,a);PhotosTaggingWaterfall.sendSignal(b);}},setMinTagDistance:function(a){this.viewerObject.setMinTagDistance(a);return this;},setScale:function(a){this.scale=a;return this;},setSource:function(a){this.source=a;return this;},enableTagging:function(b,a){if(!this._getPhotoElement())return this._destruct();this.viewerObject.enableTagging();this._taggingEnabled=true;this._tagCallbackFn=b||bagofholding;this._autoSubmitTags=(a===undefined)||a;this._getPhotoElement().style.cursor='crosshair';PhotoTagSelector.setPhotoOwner(this.photoOwnerId).setPhotoId(this.photoId).setPhotoObjectId(this.photoObjectId).prime();this._randomizeQueueName();this._sendWaterfallLogSignal(PhotosTaggingWaterfall.BEGIN);return this;},enableTaggingForFaceBox:function(a){this.enableTagging();this.showTaggerForFaceBox(a.getCenterPoint());},disableTagging:function(){this.viewerObject.disableTagging();if(!this._getPhotoElement())return this._destruct();this._sendWaterfallLogSignal(PhotosTaggingWaterfall.FINISH);this._taggingEnabled=false;this._tagCallbackFn=bagofholding;this._autoSubmitTags=true;this._getPhotoElement().style.cursor='';this._qn=null;PhotoTagSelector.hide();return this;},_photoClick:function(event){if(!this._getPhotoElement())return this._destruct();if(!this._taggingEnabled)return true;if(PhotoTagViewer.getAlwaysShowFaceBoxes()){var a=DOM.find(document.body,'div.facebox_frame');CSS.hide(a);var b=DOM.find(document.body,'div.photo_box_name_frame');CSS.hide(b);}var f=PhotoTag.tagsForPhoto(this.photoId,this.photoOwnerId);if(PhotoTag.MAX_USER_TAGS_PER_PHOTO<=f.length){ErrorDialog.show(_tx("Demasiadas etiquetas"),_tx("Sent\u00edmolo, non puidemos gardar a t\u00faa etiqueta porque esta foto cont\u00e9n o m\u00e1ximo n\u00famero de etiquetas permitidas. Para m\u00e1is informaci\u00f3n, por favor visita O \u003ca href=\"\/help\/?faq=16974\">Centro de Axuda\u003c\/a>."));return $E(event).kill();}this._sendWaterfallLogSignal(PhotosTaggingWaterfall.TAG_FACE);var d=Vector2.getEventPosition(event);var c=Vector2.getElementPosition(this._getPhotoElement());var e=d.sub(c);this._photoEnableTaggerRelative(e);return $E(event).kill();},showTaggerForFaceBox:function(a){this._photoEnableTaggerRelative(a);},_photoEnableTaggerRelative:function(d){PhotoTagSelector.hide();var b=Vector2.getElementDimensions(this._getPhotoElement());var i=PhotoTag.tagsForPhoto(this.photoId,this.photoOwnerId);var g=new PhotoTag(100*d.x/b.x,100*d.y/b.y,this.photoOwnerId,this.photoId);g.setScale(this.scale);g.setSource(this.source);this.viewerObject.showTag(g);var e=Vector2.getElementPosition(this.viewerObject.tagFrame);if(d.x>(b.x/2)||b.x<300){e=e.sub(210,0);}else{var h=Vector2.getElementDimensions(this.viewerObject.tagFrame);e=e.add(h.x+10,0);}var f=[];for(var a=0,c=i.length;a<c;a++)f.push({name:i[a].getText(),id:i[a].getTaggeeId()});PhotoTagSelector.setTagCallback(bind(this,this._photoTagCallback,g)).setHideCallback(bind(this.viewerObject,this.viewerObject.hideTag)).setPhotoOwner(this.photoOwnerId).setPhotoId(this.photoId).setPhotoObjectId(this.photoObjectId).setTaggedPeople(f).showAt(e);},_photoTagCallback:function(f,d,e,b,c){if(d)f.setTaggeeId(d);if(e)f.setTaggeeName(e);if(b)f.setTaggeeEmail(b);f.setSource('photo_php');f.setQueueName(this._qn);var a=c?PhotosTaggingWaterfall.TYPE_NAME:PhotosTaggingWaterfall.SELECT_NAME;this._sendWaterfallLogSignal(PhotosTaggingWaterfall.ADD_NAME,{method:a});if(this._autoSubmitTags){f.submit(this._tagCallbackFn);}else{f.setLocalSave();this._tagCallbackFn(f,{});}},_isPhotoCropOn:function(){return window.photocrop&&window.photocrop.instance&&true;}});
function Photocaption(e,j,f,d,a){d=copy_properties({typeaheadSource:null,successCallback:null,beginEditCallback:null},d||{});this.displayCaption=DOM.find(e,'div.photocaption');this.displayCapText=DOM.find(e,'div.photocaption_text');this.displayCapIcon=ge('photocaption_editicon');this.displayEditCapText=DOM.find(e,'textarea.photocaption_edit_text');this.displayNoCaption=DOM.find(e,'div.photocaption_nocaption');this.displayEditCaption=DOM.find(e,'div.photocaption_edit');this.captionMode=Photocaption.READ;this.successCallback=d.successCallback;this.beginEditCallback=d.beginEditCallback;this.uid=j;this.pid=f;this.mentionsHasFocus=false;this.can_caption=a;var c=DOM.find(e,'a.photocaption_toggle');var h=DOM.find(e,'a.photocaption_nocaption_edit');var g=DOM.find(e,'.caption_save');var b=DOM.find(e,'.caption_cancel');if(d.typeaheadSource&&typeof(typeahead_mentions)!=='undefined')this.initializeMentions(d.typeaheadSource);var i=this.toggleCaption.bind(this);c&&(c.onmousedown=i);h&&(h.onclick=i);g&&(g.onclick=this.saveCaption.bind(this));if(b)b.onclick=function(k){this.setCaptionUpdating(false);return $E(k).kill();}.bind(this);this.cappt=this.getCaptionEditText();}Photocaption.READ=0;Photocaption.WRITE=1;Photocaption.UPDATING=2;copy_properties(Photocaption.prototype,{initializeMentions:function(c){if(ua.firefox()<3||ua.opera())return;var d=this.getCaptionEditText();var a=$N('div',{className:'photocaption_mentions',contentEditable:true},document.createTextNode(d));DOM.replace(this.displayEditCapText,a);this.displayEditCapText=a;var b=new typeahead_mentions(a,c);this.getCaptionEditText=b.getMessage.bind(b);this.setCaptionEditText=b.setMessage.bind(b);this.setCaptionFocus=b.focusInput.bind(b);this.enableCaption=b.enable.bind(b);this.disableCaption=b.disable.bind(b);this.mentionsObj=b;Event.listen(a,'focus',function(e){this.mentionsHasFocus=true;}.bind(this));Event.listen(a,'blur',function(e){this.mentionsHasFocus=false;}.bind(this));},toggleCaption:function(a){if(this.captionMode==Photocaption.WRITE){this.captionMode=Photocaption.READ;this.displayCaptionUI();}else if(this.captionMode==Photocaption.READ){this.captionMode=Photocaption.WRITE;this.displayCaptionUI();}return $E(a).kill();},displayCaptionUI:function(){var a=this.captionMode;if(a==Photocaption.WRITE){this.beginEditCallback&&this.beginEditCallback();hide(this.displayCaption);hide(this.displayNoCaption);show(this.displayEditCaption);if(this.getCaption()){CSS.show(this.displayCapIcon);}else CSS.hide(this.displayCapIcon);this.setCaptionFocus();}else if(a==Photocaption.READ){hide(this.displayEditCaption);if(this.getCaption()){hide(this.displayNoCaption);show(this.displayCaption);if(this.can_caption){CSS.show(this.displayCapIcon);}else CSS.hide(this.displayCapIcon);}else{hide(this.displayCaption);CSS.hide(this.displayCapIcon);if(this.can_caption){show(this.displayNoCaption);}else hide(this.displayNoCaption);}}},saveCaption:function(b){if(this.captionMode!=Photocaption.WRITE)return;var a=trim(this.getCaptionEditText());if(a!=this.cappt){this.setCaptionUpdating(true);new AsyncRequest().setURI('/ajax/editphotocaption.php').setMethod('POST').setData({caption:a,oid:this.uid,pid:this.pid}).setHandler(this.saveCaptionResponse.bind(this)).setErrorHandler(this.saveCaptionError.bind(this)).send();}else this.setCaptionUpdating(false);return $E(b).kill();},saveCaptionResponse:function(a){var b=a.getPayload();this.cappt=b.plaintext;DOM.setContent(this.displayCapText,HTML(b.rendered));this.successCallback&&this.successCallback(b);this.setCaptionUpdating(false);this.setCaptionEditText(this.cappt);},saveCaptionError:function(a){this.setCaptionUpdating(false);AsyncResponse.verboseErrorHandler(a);},setCaptionData:function(c,b,a){this.setCaptionUpdating(false);this.uid=c;this.pid=b;this.cappt=a;this.setCaptionEditText(a);this.displayCaptionUI();},getCaption:function(){return this.displayCapText.innerHTML;},setCaptionUpdating:function(a){if(a){this.captionMode=Photocaption.UPDATING;CSS.addClass(this.displayEditCapText,'updating');this.disableCaption();}else{this.captionMode=Photocaption.READ;CSS.removeClass(this.displayEditCapText,'updating');this.enableCaption();this.displayCaptionUI();}},isUpdating:function(){return this.captionMode==Photocaption.UPDATING;},isEditing:function(){return this.captionMode==Photocaption.WRITE;},mentionsIsFocused:function(){return this.isEditing()&&this.mentionsHasFocus;},setCanCaption:function(a){this.can_caption=a;},setCaptionEditText:function(a){this.displayEditCapText.value=HTML(a);},getCaptionEditText:function(){return this.displayEditCapText.value;},setCaptionFocus:function(){this.displayEditCapText.focus();},enableCaption:function(){this.displayEditCapText.disabled=false;},disableCaption:function(){this.displayEditCapText.disabled=true;}});
var Configurable={getOption:function(a){if(typeof(this.option[a])=='undefined')return null;return this.option[a];},setOption:function(a,b){if(!(typeof(this.option[a])=='undefined'))this.option[a]=b;return this;},getOptions:function(){return this.option;}};function Task(a,b){copy_properties(this,{task:a,option:{synchronous:!!b},status:Task.WAITING,result:null,queue:null});}copy_properties(Task,{WAITING:0,READY:1,RUNNING:2,DONE:3,ERROR:4});copy_properties(Task.prototype,Configurable);copy_properties(Task.prototype,{run:function(){this.status=Task.RUNNING;try{var result=this.task();}catch(a){this.status=Task.ERROR;a._task=this;throw a;}if(this.getOption('synchronous'))this.didComplete(result);},didComplete:function(a){this.result=a;this.status=Task.DONE;if(this.queue)this.queue.didCompleteTask(this);return this;}});function TaskQueue(){copy_properties(this,{queue:[],executingTasks:0,executionDepth:0,option:{synchronous:true,concurrency:2}});}copy_properties(TaskQueue.prototype,Configurable);copy_properties(TaskQueue.prototype,{addTask:function(a){this.queue.push(a);a.queue=this;return a;},didCompleteTask:function(a){this.executingTasks--;this.reapQueue();if(!this.executionDepth)this.start();},runTask:function(b){this.executingTasks++;if(this.getOption('synchronous')){try{b.run();}catch(a){this.didCompleteTask();}}else setTimeout(bind(b,'run'),10);},reapQueue:function(){var c;var a,b;for(a=0,b=this.queue.length;a<b;a++){c=this.queue[a].status;if(c!=Task.DONE&&c!=Task.ERROR)break;}if(a)this.queue=this.queue.slice(a);},start:function(){this.executionDepth++;while(this.executingTasks<this.getOption('concurrency')){for(var a=0,b=this.queue.length;a<b;a++)if(this.queue[a].status==Task.READY){this.runTask(this.queue[a]);break;}if(a==b)break;}this.executionDepth--;},ready:function(c){c=c||1;for(var a=0,b=this.queue.length;a<b;a++)if(this.queue[a].status==Task.WAITING){this.queue[a].status=Task.READY;if(!(--c))break;}this.start();}});
function Photostream(e,k,f,d,u,o,q,c,l,h,m,a,n,t,b,g){Photostream.instance=this;if(k)(new Image()).src=k;if(ua.safari()<500||ua.firefox()<2)return;copy_properties(this,{data:copy_properties(d,{async:true,start_pos:q}),seq:0,pid:o,uid:u,img:e,minseq:0,isSearch:f});copy_properties(this,{error:0,album:new Array(c),has_moved:false,jumps:{},unseen:null,cursor:null,is_rendered:true,queue:new TaskQueue(),loads:[],pagesize:20,fetchedPages:{},numFetchedPages:0,pending:(m?1:0),readied:false,lastTimeout:null,slideshowSpeed:3000,slideshowActive:false,slideshowEventsInited:false,photoLoadTimeout:null,netegoPagelet:null,keyboardDialogViews:g});this.setupDisplay();this.setupCaptions(u,o,t,b);copy_properties(this,{lastAdsRefreshTime:(new Date()).getTime(),adsRefreshMinInterval:a});var j=this.onnext.bind(this);var r=this.onprev.bind(this);var p=this.onplay.bind(this);var s=this.onstop.bind(this);ge('photonav_next')&&Event.listen($('photonav_next'),'click',j);ge('photonav_prev')&&Event.listen($('photonav_prev'),'click',r);if(this.displayStartShow)Event.listen(this.displayStartShow,'click',p);if(this.displayStopShow)Event.listen(this.displayStopShow,'click',s);Event.listen(this.img,'click',j);KeyEventController.registerKey('RIGHT',j);KeyEventController.registerKey('LEFT',r);PageTransitions.registerHandler(bind(this,'photosPageTransitionHandler'));if(URI.getRequestURI().getQueryData().ss)p();this.img.onload=null;if(ua.ie()<7)this.img.galleryimg="no";this.cursor=q;this.requestPage(l);if(h){var i=bind(this,function(v){scribe_log(v?'photostream':'photostream_ajax',this.seq);},m!=undefined);onunloadRegister(i);onleaveRegister(i);}this.orig_params=URI.getRequestURI().getQueryData();}copy_properties(Photostream.prototype,{debug:bagofholding,setupDisplay:function(){copy_properties(this,{displayPhotoBox:$('photoborder').parentNode,displayPosition:$('photo_count'),displayPhototags:$('phototags_row'),displayTagBoxes:$('photo_tag_boxes'),displayComments:$('photocomment'),displayNext:ge('photo_form_next'),displayActions:$('photoactions'),photolink:$('myphotolink'),displayLoad:$('load_indicator'),displayContext:$('photoinalbum'),displayPublicLink:ge('public_link_photo'),displayStartShow:ge('photo_start_show'),displayStopShow:ge('photo_stop_show'),displayCaption:DOM.find($('photocaption_parent'),'div.photocaption_text')});},setupCaptions:function(h,f,g,a){var e=$('photocaption_parent');if(window.Photocaption){var b={typeaheadSource:(g||{}).typeaheadSource,successCallback:this.setDataFromCaption.bind(this),beginEditCallback:this.stopSlideshow.bind(this)};var d=this.album[this.cursor];var c=d?d.id:h;var f=d?d.pid:f;this.caption=new Photocaption(e,c,f,b,a);}},requestPage:function(a){if(this.fetchedPages[a])return;this.fetchedPages[a]=true;this.numFetchedPages++;this.pending++;new AsyncRequest().setURI(this.isSearch?'/photo_search.php':'/album.php').setAllowCrossPageTransition(true).setMethod('GET').setReadOnly(true).setData(copy_properties(this.data,{page:a})).setHandler(bind(this,'didGetAlbumResponse',a)).send();},checkAndRefreshAds:function(){var a=(new Date()).getTime();if(a-this.lastAdsRefreshTime>=this.adsRefreshMinInterval)this.refreshAds();},refreshAds:function(){UIPagelet.loadFromEndpoint('WebEgoPane',DOM.find(window.document,'div.UIStandardFrame_SidebarAds'),{pid:5,data:[this.uid,this.pid,null]});this.lastAdsRefreshTime=(new Date()).getTime();},maxPagesToFetch:function(){return parseInt((this.album.length-1)/this.pagesize,10)+1;},onnext:function(a){var b=(this.cursor+1)%this.album.length;if(this.slideshowActive)clearTimeout(this.lastTimeout);this.checkAndRefreshAds();if(!this.hideKeyPress(a)&&this.showPhoto(b)){if(a.getTarget().id=='photonav_next')this.showKeyboardShortcutsDialog();return $E(a).kill();}},hideKeyPress:function(b){if(window.Dialog&&window.Dialog.getCurrent()||this.caption&&this.caption.mentionsIsFocused()){event=$E(b);var a=event?Event.getKeyCode(event):-1;switch(a){case KEYS.RIGHT:case KEYS.LEFT:return true;}}return false;},setDataFromCaption:function(a){this.album[this.cursor].caption=a.rendered;this.album[this.cursor].caption_plaintext=a.plaintext;},slideshowTimeoutCallback:function(){var a=(this.cursor+1)%this.album.length;if(this.slideshowActive)if(this.album[a]){this.showPhoto(a);}else{this.requestPage(1+Math.floor(a/this.pagesize));this.slideshowGoNext(500);}},onprev:function(a){var b=((this.cursor-1)+this.album.length)%this.album.length;this.checkAndRefreshAds();if(!this.hideKeyPress(a)&&this.showPhoto(b)){if(a.getTarget().id=='photonav_prev')this.showKeyboardShortcutsDialog();return $E(a).kill();}},onplay:function(a){this.slideshowActive=true;if(!this.slideshowEventsInited){var b=this.onSlideshowInputEvent.bind(this);Event.listen(window,{keypress:b,mousedown:b});this.slideshowEventsInited=true;}this.showSlideshowControls();this.slideshowGoNext(this.slideshowSpeed);return false;},onstop:function(a){this.stopSlideshow();return $E(a).kill();},stopSlideshow:function(){if(this.slideshowEventsInited&&this.displayStartShow){this.slideshowActive=false;clearTimeout(this.lastTimeout);this.hideSlideshowControls();}},onSlideshowInputEvent:function(a){if(!this.slideshowActive||!a)return;var c=a.getTarget();var b=true;switch(c){case 'my_photo':case 'photonav_next':case 'photonav_prev':case 'photo_start_show':case 'photo_stop_show':b=false;break;default:break;}if(b){this.stopSlideshow();clearTimeout(this.lastTimeout);}return true;},slideshowGoNext:function(a){clearTimeout(this.lastTimeout);this.lastTimeout=setTimeout(this.slideshowTimeoutCallback.bind(this),a);},showSlideshowControls:function(){CSS.show(this.displayStopShow);CSS.hide(this.displayStartShow);},hideSlideshowControls:function(){CSS.hide(this.displayStopShow);CSS.show(this.displayStartShow);},readPhotoState:function(){if(this.is_rendered&&this.album[this.cursor]){this.album[this.cursor].tags=this.displayPhototags.innerHTML;if(this.displayComments)this.album[this.cursor].comments=this.displayComments.innerHTML;if(this.displayActions)this.album[this.cursor].actions=this.displayActions.innerHTML;}},showPhoto:function(b){if(this.error)return false;if(this.caption&&this.caption.isUpdating())return true;var a=this.has_moved&&!this.album[this.cursor];this.has_moved=true;this.setCursor(b);var d=this.album[b];if(d){Arbiter.inform('photostream/showPhoto',{node:{href:URI.getRequestURI().toString()},pid:d.pid,owner_id:d.id});var c={pid:d.pid,id:d.id,fbid:d.fbid};if(this.slideshowActive)c.ss='on';goURI(URI.getRequestURI().addQueryData(c).removeQueryData('alert').removeQueryData('untagged'));}else{if(!a){this.showLoadIndicator();this.prepareToLeavePhoto();}this.requestPage(1+parseInt(b/this.pagesize,10));}return true;},prepareToLeavePhoto:function(){if(!this.readied){this.readied=true;var a=env_get('ps_rate')||(5);this.queue.setOption('concurrency',a).ready(a);}if(ge('changessaved'))DOM.remove(ge('changessaved'));if(ge('photocrop_error'))DOM.remove(ge('photocrop_error'));if(window.PhotoPageTags)PhotoPageTags.resetInstructions();},setCursor:function(a){if(a===this.cursor)return;this.readPhotoState();this.is_rendered=false;this.cursor=a;this.updateCountText();},updateCountText:function(){var a=_tx("Foto {photo-number} de {total-count}",{"photo-number":this.cursor+1,"total-count":this.album.length});this.displayPosition&&DOM.setContent(this.displayPosition,HTML(a));},showCursorPhotoWithInfo:function(){this.prepareToLeavePhoto();var f=this.album[this.cursor];var e=document.createElement('img');copy_properties(e.style,{display:'none'});if(!f.seen){var c=(parseInt(this.cursor/this.pagesize)+1)*this.pagesize;c=Math.min(c,this.album.length);var g=((c-this.cursor)<=3);f.seen=true;--this.unseen;if(g&&!this.pending){var a=parseInt(this.cursor/this.pagesize)+1;var b=null;for(var d=a+1;d<=this.maxPagesToFetch();d++)if(!this.fetchedPages[d]){b=d;break;}if(b===null)for(var d=1;d<a;d++)if(!this.fetchedPages[d]){b=d;break;}if(b!==null)this.requestPage(b);}}if(!this.photoLoadTimeout)this.photoLoadTimeout=setTimeout(this.showLoadIndicator.bind(this),750);e.seq=++this.seq;e.onload=async_callback(bind(this,'renderPhoto',e,f),'photo_stream');window.ArbiterMonitor&&ArbiterMonitor.customReport('phtld',['stream']);e.src=f.src;},renderPhoto:function(b,c){if(b.seq<this.minseq){delete b;return;}this.hideLoadIndicator();this.minseq=b.seq;var a=this.img.id;if(window.photocrop)photocrop.destroy();b.style.display='';if(this.img.parentNode==null)this.img=$('myphoto');this.img.parentNode.appendChild(b);b.style.cursor=this.img.style.cursor;DOM.remove(this.img);this.img=b;this.img.id=a;Event.listen(this.img,'click',this.onnext.bind(this));this.displayCaption&&DOM.setContent(this.displayCaption,HTML(c.caption));this.displayPhototags&&DOM.setContent(this.displayPhototags,HTML(c.tags));this.displayTagBoxes&&DOM.setContent(this.displayTagBoxes,HTML(c.tag_boxes));this.displayComments&&DOM.setContent(this.displayComments,HTML(c.comments));this.displayActions&&DOM.setContent(this.displayActions,HTML(c.actions));this.displayContext&&DOM.setContent(this.displayContext,HTML(c.context_info));this.displayPublicLink&&DOM.setContent(this.displayPublicLink,HTML(c.public_link));if(this.caption){this.caption.setCanCaption(c.can_caption);this.caption.setCaptionData(c.id,c.pid,c.caption_plaintext);}this.is_rendered=true;if(window.PhotoTagController&&PhotoTagController.getInstance('myphoto')){PhotoTagController.getInstance('myphoto').setPhotoData(c.id,c.pid,c.fbid);}else PhotoTagViewer.getInstance('myphoto').setPhotoData(c.id,c.pid,c.fbid);if(this.slideshowActive)animation(this.img).from('opacity',0).to('opacity',1).duration(300).ondone(this.slideshowGoNext.bind(this,this.slideshowSpeed)).go();this.queue.ready();},didGetAlbumResponse:function(e,a){this.pending--;var f=a.getPayload();var j=(this.has_moved&&this.cursor!==null&&!this.album[this.cursor]);var c,i,d,h,g=f.data;for(var b=0;b<g.length;++b){data=g[b];h=(f.offset||(this.pagesize*(e-1)))+b;if((this.cursor===null||f.album_count)&&data.pid==this.pid)this.cursor=h;data.pos=h;data.seen=false;this.album[h]=data;this.jumps[data.fbid]=h;c=new Image();d=bind(c,function(k){this.src=k;},data.src);i=new Task(d);c.onload=i.didComplete.bind(i);this.queue.addTask(i);}this.unseen+=g.length;if(f.album_count){this.album.length=f.album_count;this.updateCountText();}if(j)this.showPhoto(this.cursor);},photosPageTransitionHandler:function(b){var a=this.pageTransitionHandler(b);if(!a)Arbiter.inform('photostream/showPhoto',{flush:true});return a;},pageTransitionHandler:function(b){var a=b.getQueryData();if(b.getPath()=='/photo.php'){for(var c in this.orig_params)if(c!='pid'&&c!='fbid'&&(!this.isSearch||(c!='id'&&c!='psids'))&&this.orig_params[c]!=a[c])return false;if(a.alert!==undefined)return false;fbid=a.fbid;if(this.jumps[fbid]!==undefined){this.setCursor(this.jumps[fbid]);this.showCursorPhotoWithInfo();PageTransitions.transitionComplete();return true;}}return false;},showLoadIndicator:function(){CSS.addClass(this.displayLoad,'loading');animation(this.displayLoad).to('opacity',0).duration(0).go().to('opacity',1).duration(200).go();animation(this.img).to('opacity',0).duration(200).go();return this;},hideLoadIndicator:function(){if(this.photoLoadTimeout){clearTimeout(this.photoLoadTimeout);this.photoLoadTimeout=null;}animation(this.img).to('opacity',1).duration(0).go();CSS.removeClass(this.displayLoad,'loading');return this;},showKeyboardShortcutsDialog:function(){if(this.keyboardDialogViews!=0){new AsyncRequest('/ajax/photos/keyboard_dialog.php').setData({count:this.keyboardDialogViews}).setMethod('POST').setAllowCrossPageTransition(true).send();this.keyboardDialogViews=0;}}});
