/*    HTTP Host:  b.static.ak.fbcdn.net                                        */
/*    Generated:  February 11th 2010 7:21:42 PM PST                            */
/*      Machine:  10.16.140.101                                                */
/*       Source:  Local Cache                                                  */
/*     Location:  rsrc:4:bfaemoon                                              */
/*       Locale:  nu_ll                                                        */
/*         Path:  js/cjbdy5gjm7co4w88.pkg.js                                   */

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

PhotoTagSelector=function(){var y;var zc;var e;var m=false;var p=null;var g=[];var h=[];var q=false;var t=null;var r=null;var s=null;var b=false;var n=false;var za=bagofholding;var l=bagofholding;var zb=[];var zd=0;var d=function(){zc.value='';e.value='';PhotoTagSelector.exitInviteMode();};var u=function(){if(!m)return;var zg=zc.value.toLowerCase().trim();zg=typeahead_source.flatten_string(zg);var zj=[];var zk=[];for(var zf=0,zh=g.length;zf<zh;zf++){var ze=g[zf];if(!zg||-1!=ze.flat_name.indexOf(zg))(ze.rel?zk:zj).push(ze.fragment);}zd=zj.length+zk.length;if(0==zd||n){hide('pts_userlist','pts_userlistlabel','pts_choose_text','pts_invite_msg');if(b){z();}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 zl='';if(0!=zj.length&&0!=zk.length)zl='<hr />';var zi=zk.join('')+zl+zj.join('');$('pts_userlist').setContent(HTML(zi));if((1==zd)&&zg)DOM.find($('pts_userlist'),'input[type="checkbox"]').checked=true;};var i=function(){if(p){return v();}else if(q)return false;q=true;new AsyncRequest().setHandler(k).setErrorHandler(j).setTransportErrorHandler(j).setFinallyHandler(function(){q=false;}).setURI('/ajax/photos_tag_options.php').setData({pid:r,id:t,oid:s}).setMethod('GET').setReadOnly(true).send();};var w=function(){g=p;if(!zb)return;for(var ze=0,zf=zb.length;ze<zf;ze++)if(zb[ze].id>0){g=g.filter(function(zg){return zb[ze].id!=zg.id;});}else g=g.filter(function(zg){return zb[ze].id!=zg.id||zb[ze].name.toLowerCase()!=zg.name.toLowerCase();});};var k=function(zg){g=p=zg.getPayload();for(var ze=0,zf=p.length;ze<zf;ze++)f(p[ze]);v();};var j=function(ze){PhotoTagSelector.hide();ErrorDialog.showAsyncError(ze);};var f=function(ze){ze.flat_name=typeahead_source.flatten_string(ze.name);ze.fragment=['<label><input type="checkbox" onclick="',sprintf('PhotoTagSelector._checkboxClick(this, %d, \'%s\')',ze.id,escape_js_quotes(ze.name)),'" />',htmlize(ze.name),'</label>'].join('');};var a=function(ze){h.push(ze);};var v=function(){for(var ze=0,zf=h.length;ze<zf;ze++)h[ze]();h=[];};var o=function(event){switch(Event.getKeyCode(event)){case KEYS.RETURN:c();break;case KEYS.ESC:PhotoTagSelector.hide();break;default:setTimeout(u,0);}};var c=function(){var zf=0;var zg='';var ze='';if(''!=e.value.trim()){ze=e.value.trim();zg=zc.value.trim();}else if(1==zd){var zh=DOM.find($('pts_userlist'),'input[type="checkbox"]');if(zh.checked){return zh.onclick();}else zg=zc.value.trim();}else zg=zc.value.trim();x(zf,zg,ze);};var x=function(zh,zj,ze){zh=zh||0;zj=zj||'';ze=ze||'';if(!zj&&!zh)return;za(zh,zj,ze);PhotoTagSelector.hide();if(zh){for(var zg=0,zi=p.length;zg<zi;zg++)if(p[zg].id==zh){p[zg].rel=true;break;}}else if(!ze){var zf=false;for(var zg=0,zi=p.length;zg<zi;zg++)if(!p[zg].id&&p[zg].name==zj){p[zg].rel=true;zf=true;break;}if(!zf){var zk={name:zj,rel:true,id:0};f(zk);p.unshift(zk);}}};var z=function(){var zf=zc.value.trim();var ze;if(zf){var zg=zf.indexOf(' ');ze=zg>-1?zf.substr(0,zg):zf;}else ze=_tx("your friend");$('pts_invite_name').setContent(ze);show('pts_invite_section');};return {init:function(){if(m)return;m=true;var ze='<span id="pts_invite_name">'+_tx("your friend")+'</span>';markup='<label for="name" id="label_name" class="pts_name_input">';markup+=_tx("Type any name or tag:");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("or choose a person:");markup+='</span>';markup+='<div id="pts_userlist">';markup+='<div style="margin: 4px;">';markup+=_tx("Loading friends...");markup+='</div>';markup+='</div>';markup+='<div id="pts_invite_section" style="display: none;">';markup+=_tx("Enter {name}'s email address. We'll send a link to this photo and add them to your friends list.",{name:ze});markup+='<div>';markup+='<label for="pts_invite_email" id="label_pts_invite_email">';markup+=_tx("Email:");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("Person doesn't use Facebook?");markup+='</strong>';markup+='<div>';markup+='<a onclick="PhotoTagSelector.enterInviteMode()">';markup+=_tx("Click here to tag them.");markup+='</a>';markup+='</div>';markup+='</div>';markup+='<div class="buttons">';markup+='<input type="button" class="inputbutton" id="tag" name="tag" value="'+_tx("Tag")+'" />';markup+='<input type="button" class="inputbutton inputaux" id="cancel" name="cancel" value="'+_tx("Cancel")+'" />';markup+='</div>';y=$N('div',null,HTML(markup));y.id='photo_tag_selector';DOMScroll.getScrollRoot().appendChild(y);e=$('pts_invite_email');zc=$('pts_name_input');zc.onkeyup=o;DOM.find(y,'input[name="tag"]').onclick=c;DOM.find(y,'input[name="cancel"]').onclick=this.hide;},prime:function(){i();return this;},hide:function(){l();if(!m)return;y.style.display='none';za=bagofholding;l=bagofholding;t=null;r=null;s=null;zb=[];zd=0;d();return this;},showAt:function(ze){ze.setElementPosition(y);y.style.display='block';a(w);a(u);a(function(){zc.focus();});i();return this;},setTagCallback:function(ze){za=ze;return this;},setHideCallback:function(ze){l=ze;return this;},setTaggedPeople:function(ze){zb=ze;return this;},setPhotoOwner:function(ze){t=ze;return this;},setPhotoId:function(ze){r=ze;return this;},setPhotoObjectId:function(ze){s=ze;return this;},setAllowEmailTags:function(ze){b=ze;return this;},enterInviteMode:function(){n=true;hide('pts_userlist','pts_userlistlabel','pts_choose_text','pts_invite_msg');z();if(zc.value){var ze=DOM.find($('pts_invite_section'),'input[name="pts_invite_email"]');ze.focus();}else zc.focus();return this;},exitInviteMode:function(){n=false;hide('pts_invite_section');if(b)show('pts_invite_msg');return this;},_checkboxClick:function(ze,zf,zg){if(!ze||!ze.checked)return;x(zf,zg);}};}();function PhotoTagController(b){if(PhotoTagController._instances[b])return PhotoTagController._instances[b];var c=PhotoTagViewer.getInstance(b);if(!c)c=new PhotoTagViewer(b);copy_properties(this,{photoElementId:b,photoOwnerId:null,photoId:null,photoObjectId:null,_taggingEnabled:false,_tagCallbackFn:bagofholding,_autoSubmitTags:true,viewerObject:c});this._getPhotoElement=bind(null,ge,b);this._destruct=function(){PhotoTagSelector.hide();this.viewerObject._destruct();delete PhotoTagController._instances[b];};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 `'+b+'\' '+'found on the page.  PhotoTagController Abort.');onunloadRegister(bind(this,this._destruct));var a=this._getPhotoElement();a.onclick=chain(bind(this,this._photoClick),a.onclick);PhotoTagController._instances[b]=this;}copy_properties(PhotoTagController,{_instances:{},getInstance:function(a){return PhotoTagController._instances[a];}});copy_properties(PhotoTagController.prototype,{setPhotoData:function(b,a){this.photoOwnerId=b;this.photoId=a;PhotoTagSelector.hide();this.viewerObject.setPhotoData(b,a);return this;},setPhotoObjectId:function(a){this.photoObjectId=a;return this;},setMinTagDistance:function(a){this.viewerObject.setMinTagDistance(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();return this;},disableTagging:function(){this.viewerObject.disableTagging();if(!this._getPhotoElement())return this._destruct();this._taggingEnabled=false;this._tagCallbackFn=bagofholding;this._autoSubmitTags=true;this._getPhotoElement().style.cursor='';PhotoTagSelector.hide();return this;},_photoClick:function(event){if(!this._getPhotoElement())return this._destruct();if(!this._taggingEnabled)return true;var k=PhotoTag.tagsForPhoto(this.photoId,this.photoOwnerId);if(PhotoTag.MAX_TAGS_PER_PHOTO<=k.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();}PhotoTagSelector.hide();var e=Vector2.getEventPosition(event);var c=Vector2.getElementPosition(this._getPhotoElement());var b=Vector2.getElementDimensions(this._getPhotoElement());var f=e.sub(c);var i=new PhotoTag(100*f.x/b.x,100*f.y/b.y,this.photoOwnerId,this.photoId);this.viewerObject.showTag(i);var g=Vector2.getElementPosition(this.viewerObject.tagFrame);if(f.x>(b.x/2)||b.x<300){g=g.sub(210,0);}else{var j=Vector2.getElementDimensions(this.viewerObject.tagFrame);g=g.add(j.x+10,0);}var h=[];for(var a=0,d=k.length;a<d;a++)h.push({name:k[a].getText(),id:k[a].getTaggeeId()});PhotoTagSelector.setTagCallback(bind(this,this._photoTagCallback,i)).setHideCallback(bind(this.viewerObject,this.viewerObject.hideTag)).setPhotoOwner(this.photoOwnerId).setPhotoId(this.photoId).setPhotoObjectId(this.photoObjectId).setTaggedPeople(h).showAt(g);return $E(event).kill();},_photoTagCallback:function(d,b,c,a){if(b)d.setTaggeeId(b);if(c)d.setTaggeeName(c);if(a)d.setTaggeeEmail(a);if(this._autoSubmitTags){d.submit(this._tagCallbackFn);}else{d.setLocalSave();this._tagCallbackFn(d,{});}},_isPhotoCropOn:function(){return window.photocrop&&window.photocrop.instance&&true;}});
var PhotoPageTags={removeCallback:function(b,a){var c=ge('phototags');if(c&&undefined!==a.tag_html)c.setContent(HTML(a.tag_html));PhotoTagViewer.getInstance('myphoto').hideTag();PhotoPageTags.resetInstructions();},addCallback:function(c,a){var e=ge('phototags');if(e&&undefined!==a.tag_html)e.setContent(HTML(a.tag_html));var f=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("Tag for yourself saved");}else d+=_tx("Tag for {name} saved",{name:f});}else if(a.user==c.getTaggeeId()){d+=_tx("Tag request for yourself sent to {photo-owner} for approval",{'photo-owner':b});}else d+=_tx("Tag request for {name} sent to {photo-owner} for approval",{name:f,'photo-owner':b});d+='</b>.<br/>';}else d='<b style="color:red">'+_tx("There was an error tagging this photo. Try again later.")+'</b><br />';if(a.invite_sent)d+='<b style="color: green">'+_tx("An invitation and friend request have been sent to {name}",{name:f})+'</b><br/>';if(!a.tags_need_approval){d+=_tx("You can continue to tag the photo below.");}else d+=_tx("You can continue to request tags in the photo below.");d+='<br/>'+_tx("When you are done, click the \"Done Tagging\" button to resume browsing.");hide('tagging_instructions_default_message');set_inner_html($('tagging_instructions_status_message'),d);PhotoPageTags.focusInstructions();},showTaggingUI:function(){window.photocrop&&window.photocrop.destroy();PhotoTagController.getInstance('myphoto').enableTagging(PhotoPageTags.addCallback);show('tagging_instructions');PhotoPageTags.resetInstructions();PhotoPageTags.focusInstructions();},resetInstructions:function(){if(!ge('tagging_instructions_status_message'))return;$('tagging_instructions_status_message').empty();show('tagging_instructions_default_message');},hideTaggingUI:function(){hide('tagging_instructions');if(PhotoTagController.getInstance('myphoto'))PhotoTagController.getInstance('myphoto').disableTagging();},focusInstructions:function(){var a=Vector2.getElementPosition($('tagging_instructions'));if(Vector2.getScrollPosition().y>a.y)DOMScroll.scrollTo(a.sub(0,8));}};

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