/*    HTTP Host:  static.ak.fbcdn.net                                          */
/*    Generated:  December 22nd 2009 10:00:42 AM PST                           */
/*      Machine:  10.16.140.102                                                */
/*       Source:  Global Cache                                                 */
/*     Location:  js/8ls5iuhtvw08scs0.pkg.js h:2z70auz7                        */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/8ls5iuhtvw08scs0.pkg.js                                   */

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

function adz_insertTagIntoDiv(f,b){var a=document.getElementById(b);if(!a){window.Util&&false;return;}a.innerHTML='<div style="display:none"><br></div>'+f;var e={};var c={};var d=function(){var g=a.getElementsByTagName('script');var l=null;var j=null;for(var k=0;k<g.length;k++)if(g[k].src){var i=g[k].src;if(!e[i]){l=i;break;}}else{var h=g[k].innerHTML;if(!c[h]){j=h;break;}}if(l){e[l]=true;adz_stubOutDocumentWriteExec(function(m){loadExternalJavascript(l,m);},a.id,d);}else if(j){c[j]=true;adz_stubOutDocumentWriteExec(function(m){if(window.eval_global)eval_global(j);if(m)m();},a.id,d);}};d();}function adz_stubOutDocumentWriteExec(g,c,a){var b=document.getElementById(c);if(!b){window.Util&&false;return;}var i=document.write,h=0,f=false;var d=b.innerHTML;document.write=function(j){d+=j;b.innerHTML=d;if(!h){h=1;setTimeout(e,0);}};var e=function(){if(!f){document.write=i;if(a)a();}f=true;};g(e);}
function PhotoTag(a,b,d,c){copy_properties(this,{centerPoint:new Vector2(a/100,b/100),photoOwnerId:d,photoId:c});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(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;},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_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};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;},invite:function(c){var b={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};c=c||bagofholding;var a=new AsyncRequest().setURI('/ajax/invite_photo_tag.php').setHandler(c).setData(b);var d=new Dialog().setAsync(a).show();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;},_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 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,tagFrame:null,nameFrame:null,_taggingEnabled:false});this._getPhotoElement=bind(null,ge,c);this._destruct=function(){b.remove();this.hideTag();this.tagHideCallback();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);onunloadRegister(bind(this,this._destruct));PhotoTagViewer._instances[c]=this;}copy_properties(PhotoTagViewer,{_instances:{},getInstance:function(a){return PhotoTagViewer._instances[a];}});copy_properties(PhotoTagViewer.prototype,{setPhotoData:function(b,a){this.photoOwnerId=b;this.photoId=a;this.hideTag();this.tagHideCallback();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;},_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_TAGS_PER_PHOTO<=a.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(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);DOMScroll.getScrollRoot().appendChild(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(d){if(this.nameFrame)this.hideTagText();if(this._isPhotoCropOn())return;this.nameFrame=$N('div',null,$N('span',null,d.getText()));CSS.addClass(this.nameFrame,'photo_tag_name_frame');DOMScroll.getScrollRoot().appendChild(this.nameFrame);var c=Vector2.getElementPosition(this._getPhotoElement());var b=Vector2.getElementDimensions(this._getPhotoElement());var e=d.absoluteCenter(b.x,b.y);var a=this._calculateWithinBounds(e,2*this.minTagDistance,this._getPhotoElement());var f=Vector2.getElementDimensions(this.nameFrame);var g=new Vector2(f.x/2,8+f.y-a.size/2);c.add(a.tagPosition).sub(g).setElementPosition(this.nameFrame);show(this.nameFrame);},hideTagText:function(){if(this.nameFrame)DOM.remove(this.nameFrame);this.nameFrame=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._taggingEnabled)return;if(!this.tagShowCallback&&!this.tagHideCallback)return;var i=PhotoTag.tagsForPhoto(this.photoId,this.photoOwnerId);if(!i)return;var g=Vector2.getEventPosition(event);var d=Vector2.getElementPosition(this._getPhotoElement());var c=Vector2.getElementDimensions(this._getPhotoElement());var h=g.sub(d);if(h.x>0&&h.x<c.x&&h.y>0&&h.y<c.y){var e=c.magnitude();var f=null;for(var b=0;b<i.length;b++){var a=i[b].absoluteCenter(c.x,c.y);var k=a.sub(h);var j=k.magnitude();if(Math.abs(k.x)<=this.minTagDistance&&Math.abs(k.y)<=this.minTagDistance&&j<=e){e=j;f=i[b];if(0==j)break;}}}if(!f&&this.showingTag&&this.tagHideCallback){this.showingTag=null;this.tagHideCallback(this.showingTag);}else if(f&&this.tagShowCallback&&f!=this.showingTag){this.showingTag=f;this.tagShowCallback(f);}},_isPhotoCropOn:function(){return window.photocrop&&window.photocrop.instance&&true;}});
var PhotoAlbumTag={addTagToPage:function(p,l){var i=l.taggeeId||-3;var k=l.photoId;var j=l.taggeeName;var h=l.taggeeEmail;var d=k+"_*"+i+"_*"+encodeURI(j);var f=l.centerPoint.x*100;var g=l.centerPoint.y*100;var e=k+"_*"+i+"_*"+j+"_*"+f+"_*"+g+"_*"+(h?htmlspecialchars(h):'');var a=$N('input',{type:'hidden',value:'val_*'+e,name:'tag_*'+d});var m=$N('a',{href:'#'},_tx("remove"));var b=[j+' ',a,m];var c=$N('div');c.id=d;DOM.setContent(c,b);m.onclick=bind(l,l.remove,bind(null,PhotoAlbumTag.removeTag,c,p));var o=ge(p);var n=ge(d);if(n&&o)o.removeChild(n);hide(p+'_none');$(p).appendChild(c);},removeTag:function(a,c){var b=$(c);DOM.remove(a);if(b.childNodes.length==0)show(c+"_none");return false;}};

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