/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  February 13th 2010 3:09:34 PM PST                            */
/*      Machine:  10.16.140.104                                                */
/*       Source:  Backing Store                                                */
/*     Location:  js/6cre1xxolmo0wwo0.pkg.js h:23mqyr2h                        */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/6cre1xxolmo0wwo0.pkg.js                                   */

if (window.CavalryLogger) { CavalryLogger.start_js(["js\/6cre1xxolmo0wwo0.pkg.js"]); }

var Configurable={getOption:function(opt){if(typeof(this.option[opt])=='undefined'){Util.warn('Failed to get option %q; it does not exist.',opt);return null;}return this.option[opt];},setOption:function(opt,v){if(typeof(this.option[opt])=='undefined'){Util.warn('Failed to set option %q; it does not exist.',opt);}else this.option[opt]=v;return this;},getOptions:function(){return this.option;}};
function Nectar(){}copy_properties(Nectar,{linkHandler:function(_L0,_L1){var _L2=Nectar.getNectarParams();_L2['ia']=1;var url=_L1.href;if(!url){url=URI.getRequestURI().toString();_L2['err']=1;}_L2['url']=url;var uri='/ajax/nectar.php'+'?'+URI.implodeQuery({'nctr':_L2})+'&';new AsyncSignal(uri,{}).send();return _L0;},getNectarParams:function(){var _L0={};var _L1=env_get('nctrlid');if(_L1)_L0['id']=_L1;var _L2=env_get('nctrlnid');if(_L2)_L0['nid']=_L2;if(_L1||_L2)_L0['ct']=(new Date()).getTime();copy_properties(_L0,Nectar.extraData.get_query_data());return _L0;},extraData:function(){var _L0={};var _L1=[];return {set_item:function(_L2,_L3,_L4){var _L5=_L0[_L2];if(_L5===undefined){if(_L4)_L1.push(_L2);_L5=[];_L0[_L2]=_L5;}return _L5.push(_L3);},get_item:function(_L2){return _L0[_L2]||[];},get_query_data:function(){var ii,_L3,_L4,_L5={};for(ii=0;ii<_L1.length;ii++){_L4=_L1[ii];_L3=_L0[_L4];if(_L3)_L5[_L4]=_L3.join(',');}_L0=[];_L1=[];return _L5;}};}()});
var PhotostreamConstants={ShowPhoto:'photostream/showPhoto'};
function NectarPhotosLog(){}copy_properties(NectarPhotosLog,{PHOTOS_BUF_LEN:20,showPhotoHandler:function(_L0,_L1){var pid,_L3,aid,ss;_L3=_L1.node;pid=_L1.pid;aid=_L1.aid;ss=_L1.ss;var _L6=Nectar.extraData.get_item('pts');if(pid!==undefined){if(_L6.length==0){Nectar.extraData.set_item('url',_L3.href,false);Nectar.extraData.set_item('aid',aid,true);Nectar.extraData.set_item('ss',ss,false);}Nectar.extraData.set_item('pts',pid,true);}_L6=Nectar.extraData.get_item('pts');if(_L6.length>=NectarPhotosLog.PHOTOS_BUF_LEN)NectarPhotosLog.flushLog();return false;},flushLog:function(){var _L0=Nectar.extraData.get_item('pts');if(_L0.length>0){var url=Nectar.extraData.get_item('url')[0];Nectar.linkHandler(false,{'href':url});}return false;}});onloadRegister(function(){Arbiter.subscribe(PhotostreamConstants.ShowPhoto,NectarPhotosLog.showPhotoHandler);});onbeforeunloadRegister(function(){NectarPhotosLog.flushLog();},false);
function Task(_L0,_L1){copy_properties(this,{task:_L0,option:{synchronous:!!_L1},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 _L0=this.task();}catch(exception){this.status=Task.ERROR;exception._task=this;throw exception;}if(this.getOption('synchronous'))this.didComplete(_L0);},didComplete:function(_L0){this.result=_L0;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(_L0){this.queue.push(_L0);_L0.queue=this;return _L0;},didCompleteTask:function(_L0){this.executingTasks--;this.reapQueue();if(!this.executionDepth)this.start();},runTask:function(_L0){this.executingTasks++;if(this.getOption('synchronous')){try{_L0.run();}catch(exception){Util.error('Exception thrown while running task: %x.',exception);this.didCompleteTask();}}else setTimeout(bind(_L0,'run'),10);},reapQueue:function(){var _L0;var ii,len;for(ii=0,len=this.queue.length;ii<len;ii++){_L0=this.queue[ii].status;if(_L0!=Task.DONE&&_L0!=Task.ERROR)break;}if(ii)this.queue=this.queue.slice(ii);},start:function(){this.executionDepth++;while(this.executingTasks<this.getOption('concurrency')){for(var ii=0,len=this.queue.length;ii<len;ii++)if(this.queue[ii].status==Task.READY){this.runTask(this.queue[ii]);break;}if(ii==len)break;}this.executionDepth--;},ready:function(n){n=n||1;for(var ii=0,len=this.queue.length;ii<len;ii++)if(this.queue[ii].status==Task.WAITING){this.queue[ii].status=Task.READY;if(!(--n))break;}this.start();}});
function PhotoTag(_L0,_L1,_L2,_L3){copy_properties(this,{centerPoint:new Vector2(_L0/100,_L1/100),photoOwnerId:_L2,photoId:_L3});copy_properties(this,{taggeeName:'',taggeeId:null,taggeeEmail:'',_saved:false,_pendingAsync:false});}copy_properties(PhotoTag,{SYNCING_ENDPOINT:'/ajax/photo_tagging_ajax.php',MAX_TAGS_PER_PHOTO:50,_tagList:{},_photoKey:function(_L0,_L1){return _L0+':'+_L1;},tagsForPhoto:function(_L0,_L1){var _L2=PhotoTag._photoKey(_L0,_L1);return PhotoTag._tagList[_L2]||[];},clearTagsForPhoto:function(_L0,_L1){var _L2=PhotoTag._photoKey(_L0,_L1);PhotoTag._tagList[_L2]=[];}});copy_properties(PhotoTag.prototype,{setTaggeeEmail:function(_L0){if(this.saved){Util.log('You cannot edit the email of a saved tag');return this;}else this.taggeeEmail=_L0;return this;},setTaggeeName:function(_L0){if(this.saved){Util.log('You cannot edit the name of a saved tag');return this;}else this.taggeeName=_L0;return this;},setTaggeeId:function(_L0){if(this.saved){Util.log('You cannot edit the id of a saved tag');}else this.taggeeId=_L0;return this;},absoluteCenter:function(_L0,_L1){return this.centerPoint.mul(_L0,_L1);},submit:function(_L0){if(!this.taggeeName&&!this.taggeeId){Util.log('No user, email, or string has been tagged yet');return;}else if(this._saved){Util.log('This tag has already been saved to the server.  You cannot '+'save it again');return;}else if(this._pendingAsync){return;}else if(PhotoTag.MAX_TAGS_PER_PHOTO<=PhotoTag.tagsForPhoto(this.photoId,this.photoOwnerId).length){Util.log('Cannot add more than %d tags to any given photo.  (pid: %d, '+'id: %d) is already at the limit.',PhotoTag.MAX_TAGS_PER_PHOTO,this.photoId,this.photoOwnerId);return;}_L0=_L0||bagofholding;var _L1={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};this._pendingAsync=true;new AsyncRequest().setURI(PhotoTag.SYNCING_ENDPOINT).setData(_L1).setHandler(bind(this,this._submitHandler,_L0)).setErrorHandler(bind(this,this._submitHandler,_L0)).setFinallyHandler(bind(this,function(){this._pendingAsync=false;})).send();},remove:function(_L0,_L1){if(!this.taggeeName&&!this.taggeeId){Util.log('No user or name has been tagged yet');return;}else if(this._pendingAsync){return;}else if(!this._saved){this._removeLocal();return _L0(this,{});}_L0=_L0||bagofholding;var _L2={pid:this.photoId,id:this.photoOwnerId,subject:this.taggeeId,name:this.taggeeName,action:_L1||'remove'};this._pendingAsync=true;new AsyncRequest().setURI(PhotoTag.SYNCING_ENDPOINT).setData(_L2).setHandler(bind(this,this._removeHandler,_L0)).setFinallyHandler(bind(this,function(){this._pendingAsync=false;})).send();return false;},invite:function(_L0){var _L1={pid:this.photoId,id:this.photoOwnerId,subject:this.taggeeId,name:this.taggeeName,email:this.taggeeEmail,x:this.centerPoint.x*100,y:this.centerPoint.y*100};_L0=_L0||bagofholding;var _L2=new AsyncRequest().setURI('/ajax/invite_photo_tag.php').setHandler(_L0).setData(_L1);var _L3=new Dialog().setAsync(_L2).show();return false;},_removeLocal:function(){var _L0=PhotoTag._photoKey(this.photoId,this.photoOwnerId);var _L1=PhotoTag._tagList[_L0]||[];for(var i=0,len=_L1.length;i<len;i++)if(_L1[i]==this){_L1.splice(i,1);break;}},setLocalSave:function(){var _L0=PhotoTag._photoKey(this.photoId,this.photoOwnerId);var _L1=PhotoTag._tagList[_L0]=PhotoTag._tagList[_L0]||[];PhotoTag._tagList[_L0][_L1.length]=this;return this;},setSaved:function(){this._saved=true;return this.setLocalSave();},getText:function(){return this.taggeeName||this.taggeeEmail;},getTaggeeId:function(){return this.taggeeId;},_submitHandler:function(_L0,_L1){var _L2=_L1.getError();var _L3=_L1.getPayload();if(_L2){ErrorDialog.showAsyncError(_L1);if(!_L3['tag_success'])return;}this.setSaved();this.taggeeName=_L3.taggeeName;this.taggeeId=_L3.taggeeId;_L0(this,_L3);},_removeHandler:function(_L0,_L1){this._removeLocal();(_L0||bagofholding)(this,_L1.getPayload());}});
function PhotoTagViewer(_L0){if(PhotoTagViewer._instances[_L0])return PhotoTagViewer._instances[_L0];copy_properties(this,{minTagDistance:83,photoElementId:_L0,photoOwnerId:null,photoId:null,photoObjectId:null,tagShowCallback:bagofholding,tagHideCallback:bagofholding,showingTag:null,tagFrame:null,nameFrame:null,_taggingEnabled:false});this._getPhotoElement=bind(null,ge,_L0);this._destruct=function(){_L2.remove();this.hideTag();this.tagHideCallback();delete PhotoTagViewer._instances[_L0];};this._wait_for_load=function(_L3){_L3.deferUntil(image_has_loaded.bind(this,this._getPhotoElement()),100);};if(!this._getPhotoElement())throw new Error('No images with the id `'+_L0+'\' '+'found on the page.  PhotoTagViewer Abort.');var _L1=bind(this,this._photoMouseMove);var _L2=Event.listen(document,'mousemove',_L1);onunloadRegister(bind(this,this._destruct));PhotoTagViewer._instances[_L0]=this;}copy_properties(PhotoTagViewer,{_instances:{},getInstance:function(_L0){return PhotoTagViewer._instances[_L0];}});copy_properties(PhotoTagViewer.prototype,{setPhotoData:function(_L0,_L1){this.photoOwnerId=_L0;this.photoId=_L1;this.hideTag();this.tagHideCallback();return this;},setPhotoObjectId:function(_L0){this.photoObjectId=_L0;return this;},setMinTagDistance:function(_L0){this.minTagDistance=_L0;return this;},registerTagHover:function(_L0,_L1){if(!_L0&&!_L1){this.tagShowCallback=bind(this,this.showTagText);this.tagHideCallback=bind(this,this.hideTagText);}else{this.tagShowCallback=_L0;this.tagHideCallback=_L1;}return this;},enableTagging:function(){this._taggingEnabled=true;},disableTagging:function(){this._taggingEnabled=false;},_photoClick:function(_L0){if(!this._getPhotoElement())return this._destruct();if(!this._taggingEnabled)return true;var _L1=PhotoTag.tagsForPhoto(this.photoId,this.photoOwnerId);if(PhotoTag.MAX_TAGS_PER_PHOTO<=_L1.length){new ErrorDialog().showError(_tx("Too Many Tags"),_tx("A photo may only have up to {limit} tags. To add a new tag, you must first remove one of the existing tags on the photo.",{limit:PhotoTag.MAX_TAGS_PER_PHOTO}));return $E(_L0).kill();}},showTag:function(tag){if(!this._getPhotoElement())return this._destruct();if(!tag)return;if(this._isPhotoCropOn())return;this._wait_for_load(this._showTag.bind(this,tag));},_showTag:function(tag){if(!this.tagFrame){var _L1=document.createElement('div');_L1.style.width=(2*this.minTagDistance)+'px';_L1.style.height=(2*this.minTagDistance)+'px';CSS.addClass(_L1,'photo_tag_frame_inside');this.tagFrame=$N('div',null,_L1);CSS.addClass(this.tagFrame,'photo_tag_frame');this.tagFrame.onclick=bind(this,this._photoClick);DOMScroll.getScrollRoot().appendChild(this.tagFrame);}var _L2=Vector2.getElementPosition(this._getPhotoElement());var _L3=Vector2.getElementDimensions(this._getPhotoElement());var _L4=tag.absoluteCenter(_L3.x,_L3.y);var _L5=this._calculateWithinBounds(_L4,2*this.minTagDistance,this._getPhotoElement());var _L6=new Vector2(_L5.size,_L5.size);var _L7=_L6.mul(.5,.5);_L6.setElementDimensions(DOM.find(this.tagFrame,'div.photo_tag_frame_inside'));new Vector2(-10000,-100000,'document').setElementPosition(this.tagFrame);show(this.tagFrame);var _L8=Vector2.getElementDimensions(this.tagFrame).sub(_L5.size,_L5.size).mul(.5,.5);_L2.add(_L5.tagPosition).sub(_L7).sub(_L8).setElementPosition(this.tagFrame);},hideTag:function(){hide(this.tagFrame);},showTagText:function(tag){if(!this._getPhotoElement())return this._destruct();if(!tag||this._taggingEnabled)return;this._wait_for_load(this._showTagText.bind(this,tag));},_showTagText:function(tag){if(this.nameFrame)this.hideTagText();if(this._isPhotoCropOn())return;this.nameFrame=$N('div',null,$N('span',null,tag.getText()));CSS.addClass(this.nameFrame,'photo_tag_name_frame');DOMScroll.getScrollRoot().appendChild(this.nameFrame);var _L1=Vector2.getElementPosition(this._getPhotoElement());var _L2=Vector2.getElementDimensions(this._getPhotoElement());var _L3=tag.absoluteCenter(_L2.x,_L2.y);var _L4=this._calculateWithinBounds(_L3,2*this.minTagDistance,this._getPhotoElement());var _L5=Vector2.getElementDimensions(this.nameFrame);var _L6=new Vector2(_L5.x/2,8+_L5.y-_L4.size/2);_L1.add(_L4.tagPosition).sub(_L6).setElementPosition(this.nameFrame);show(this.nameFrame);},hideTagText:function(){if(this.nameFrame)DOM.remove(this.nameFrame);this.nameFrame=null;},_forceWithinBounds:function(_L0,_L1,_L2){_L0=_L0.sub(0,0);if(_L0.x<_L1){_L0.x=Math.min(_L1,_L2.x);}else if(_L0.x>_L2.x-_L1)_L0.x=Math.max(0,_L2.x-_L1);if(_L0.y<_L1){_L0.y=Math.min(_L1,_L2.y);}else if(_L0.y>_L2.y-_L1)_L0.y=Math.max(0,_L2.y-_L1);return _L0;},_calculateWithinBounds:function(_L0,_L1,_L2){var _L3=Vector2.getElementPosition(_L2);var _L4=Vector2.getElementDimensions(_L2);var _L5=Math.max(_L0.x-_L1/2,0);var _L6=Math.min(_L0.x+_L1/2,_L4.x);var top=Math.max(_L0.y-_L1/2,0);var _L8=Math.min(_L0.y+_L1/2,_L4.y);var _L0=new Vector2((_L6+_L5)/2,(top+_L8)/2);var _L9=Math.min(_L6-_L5,_L8-top);return {tagPosition:_L0,size:_L9};},_photoMouseMove:function(_L0){if(!this._getPhotoElement())return this._destruct();if(this._taggingEnabled)return;if(!this.tagShowCallback&&!this.tagHideCallback)return;var _L1=PhotoTag.tagsForPhoto(this.photoId,this.photoOwnerId);if(!_L1)return;var _L2=Vector2.getEventPosition(_L0);var _L3=Vector2.getElementPosition(this._getPhotoElement());var _L4=Vector2.getElementDimensions(this._getPhotoElement());var _L5=_L2.sub(_L3);if(_L5.x>0&&_L5.x<_L4.x&&_L5.y>0&&_L5.y<_L4.y){var _L6=_L4.magnitude();var _L7=null;for(var i=0;i<_L1.length;i++){var _L9=_L1[i].absoluteCenter(_L4.x,_L4.y);var _La=_L9.sub(_L5);var _Lb=_La.magnitude();if(Math.abs(_La.x)<=this.minTagDistance&&Math.abs(_La.y)<=this.minTagDistance&&_Lb<=_L6){_L6=_Lb;_L7=_L1[i];if(0==_Lb)break;}}}if(!_L7&&this.showingTag&&this.tagHideCallback){this.showingTag=null;this.tagHideCallback(this.showingTag);}else if(_L7&&this.tagShowCallback&&_L7!=this.showingTag){this.showingTag=_L7;this.tagShowCallback(_L7);}},_isPhotoCropOn:function(){return window['photocrop']&&window['photocrop'].instance&&true;}});

if (window.Bootloader) { Bootloader.done(["js\/6cre1xxolmo0wwo0.pkg.js"]); }