var frontPhotoManager;var anyPhotoEditDone=false;var saveAnyPhotoEditDone=false;var anyTaggingDone=false;var inRotate=false;var inNavigate=false;var saveTopOffset=-1;var prevNextAlbumID=-1;var origTitle="";function onViewPhotoPageLoad(b,a){if(Object.isUndefined(b)){b=photo_data;a=false}b.saveTopOffset=saveTopOffset;if((inRotate||inNavigate)&&typeof frontPhotoManager!="undefined"){frontPhotoManager.hideDimmedPreloader();anyPhotoEditDone=saveAnyPhotoEditDone;inRotate=false;inNavigate=false}frontPhotoManager=new PhotoManager(b,a);commentsReset()}function loadViewEditPhoto(c,b,a){if(currentAnchor==null||currentAnchor==""||currentAnchor=="#"){navigateToHash("#"+(typeof b!="undefined"&&b!=null?b+"-":"")+a)}anyPhotoEditDone=false;anyTaggingDone=false;if(typeof c=="undefined"){photoSiteID=siteID}else{photoSiteID=c}var f="siteID="+photoSiteID+"&photoID="+a+"&lang="+lang;if(typeof b!="undefined"&&b!=null){f+="&sourceID="+b}if($("flashcontent")){var e=$("flashcontent").down().id;f+="&flashType="+e}albumID=b;photoID=a;var d=new Ajax.Request("/FP/Library/Photos/ViewPhoto/getViewEditPhoto.php",{method:"POST",parameters:f,onComplete:function(g){onLoadViewEditPhotoDone(g)},onFailure:function(g){alert(errorOccurred);hideEditPhotoShowFlash();return}})}function onLoadViewEditPhotoDone(c){if(c.status!=200||c.responseText=="error"){hideEditPhotoReloadFlash();return}var b=$("editPhotoContent");b.replace(c.responseText);var a=document.getElementById("masterPageFooter");if(a){a.style.display="block"}}function onLoadViewEditPhotoScriptsDone(a){switch(a){case 0:case 3:break;case 1:case 2:window.location.reload();return;default:alert(errorOccurred);hideEditPhotoShowFlash();return}onViewPhotoPageLoad(photo_data,true)}function navigationPhotoClickedViaAjax(b){if(typeof frontPhotoManager=="undefined"){return false}if(!frontPhotoManager.embededInFlash){return false}var a=/(photo|video|document|audio)-([0-9]+)_([0-9]+)_([0-9]+)\/[^\/]+$/;var d=a.exec(b);if(d==null){return false}var c=d[2];replacePhoto(albumID,c,true);return true}function replacePhoto(c,b,a){if(a){navigateToHash("#"+(typeof c!="undefined"&&c!=null?c+"-":"")+b)}saveAnyPhotoEditDone=anyPhotoEditDone;saveTopOffset=document.viewport.getScrollOffsets().top;inNavigate=true;frontPhotoManager.showDimmedPreloader();loadViewEditPhoto(photoSiteID,c,b)}function viewEditPhotoBackClicked(){if(typeof frontPhotoManager!="undefined"){frontPhotoManager.resetDocumentTitle()}if(anyTaggingDone||(anyPhotoEditDone&&!inTagger)){hideEditPhotoReloadFlash(frontPhotoManager.photo.pid)}else{frontPhotoManager.unSetEvents();if($("balloon_box")){$("balloon_box").remove()}hideEditPhotoShowFlash()}}function downloadPhoto(){writeActivityIndicator(ACTIVITY_VIEW_EDIT_PHOTO,SCENARIO_VIEWPHOTO_DOWNLOAD_PHOTO);var a=document.getElementById("downloadIFrame");if(a==null){a=document.createElement("iframe");a.setAttribute("style","display:none;");a.setAttribute("id","downloadIFrame");a.setAttribute("width","0");a.setAttribute("height","0");document.body.appendChild(a)}a.setAttribute("src",downloadPhotoURL)}function showDownloadPhotoPleaseWaitMsg(){messageBox2(SECTION_NONE,"Popup"+MESSAGE_BOX_PARAMETER_SEPARATOR+"Notice","Photos"+MESSAGE_BOX_PARAMETER_SEPARATOR+"Prepare downloadable photo",MB_ICONINFORMATION,MB_CLOSE,MB_DEFAULT_BUTTON,null)}function viewPhotoMatchToCelebrities(a){writeActivityIndicator(ACTIVITY_VIEW_EDIT_PHOTO,SCENARIO_VIEWPHOTO_MATCH_TO_CELEBRITIES);invokeuScrambleURL(a)}function deletePhoto(){messageBox2(MEMBERS_SECTION,"Popup"+MESSAGE_BOX_PARAMETER_SEPARATOR+"Confirmation","Photos"+MESSAGE_BOX_PARAMETER_SEPARATOR+"Delete photo",MB_ICONQUESTION,MB_YESNO,MB_DEFAULT_BUTTON,"deletePhotoConfirmation")}function showDeletePhotoErrorMsg(){messageBox2(SECTION_NONE,"Popup"+MESSAGE_BOX_PARAMETER_SEPARATOR+"Notice","Photos"+MESSAGE_BOX_PARAMETER_SEPARATOR+"Failed to delete photo",MB_ICONINFORMATION,MB_CLOSE,MB_DEFAULT_BUTTON,null)}function showDeletePhotoPleaseWaitMsg(){messageBox2(SECTION_NONE,"Popup"+MESSAGE_BOX_PARAMETER_SEPARATOR+"Notice","Photos"+MESSAGE_BOX_PARAMETER_SEPARATOR+"Please wait delete photo",MB_ICONINFORMATION,MB_CLOSE,MB_DEFAULT_BUTTON,null)}function deletePhotoConfirmation(a){if(a!=MB_YES){return}invokeDeletePhoto()}function invokeDeletePhoto(){showDeletePhotoPleaseWaitMsg();var a=getAjaxObject();sendAjaxRequest(a,deleteAPI,deleteRequest,"","GET","deletePhotoCallback","","")}function deletePhotoCallback(a,b){b=unescape(b);if(b.indexOf("<response ")!=-1){if(frontPhotoManager.embededInFlash){hideEditPhotoReloadFlash()}else{document.location.href=photoSourceURL}}else{showDeletePhotoErrorMsg()}}function invokeRotatePhoto(c){if(inRotate&&typeof frontPhotoManager!="undefined"){return}var a=getAjaxObject();var b=rotateRequest.replace(directionTemplate,c);inRotate=true;sendAjaxRequest(a,rotateAPI,b,"","GET","rotatePhotoCallback","","");frontPhotoManager.showDimmedPreloader()}function rotatePhotoCallback(a,b){b=unescape(b);if(b.indexOf("<response ")!=-1){if(frontPhotoManager.embededInFlash){loadViewEditPhoto(photoSiteID,albumID,photoID)}else{window.location.reload()}}else{}}function clickPersonById(a){frontPhotoManager.clickPersonById($(a).getAttribute("person_id"))}function hideViewPhotoShowEditPhoto(){var b=document.getElementById("viewPhotoContainer");var a=document.getElementById("editPhotoContent");if(b==null){return}else{b.style.display="none"}if(a==null){return}else{a.style.display="block"}}function searchByKeyword(c){writeActivityIndicator(ACTIVITY_VIEW_EDIT_PHOTO,SCENARIO_VIEWPHOTO_SEARCH_BY_KEYWORD);var b=Event.element(c);var a=b.innerHTML.unescapeHTML().strip();document.location.href=keywordsURLTemplate.replace(/keywordPlaceHolder/,encodeURIComponent(a))}function html_entity_decode(a){return a.unescapeHTML()}function html_entity_encode(a){return a.escapeHTML()}function maximizePhoto(){frontPhotoManager.maximize()}function minimizePhoto(){frontPhotoManager.minimize()}Tools={showCelebrityInfo:function(a){window.open(myheritage+"FP/Company/popup.php?p=celebrity&params=id%3D"+a,"mw","width=742, height=500");return false},createDiv:function(a,c){var b=document.createElement("div");if(a!=null){b.className=a}if(c){b.id=c}return $(b)},sendAjaxRequest:function(c,b,g,e){var a=true;var f=e?"get":"post";var d=new Ajax.Request(b,{method:f,parameters:c,onComplete:function(h){g(h)}})},onmouseover:function(b){var a=Event.element(b);a.style.textDecoration="underline";a.style.color="#000014"},onmouseout:function(b){var a=Event.element(b);a.style.textDecoration="none";a.style.color="#304A73"},removeElementFromArray:function(b,c){var a=new Array();c.each(function(d){if(d!=b){a.push(d)}});return a}};var BasePhotoEditDialog=function(){};BasePhotoEditDialog.prototype={initialize:function(a){this.el=$(a);this.btnCancel=this.el.select("div.person-dialog-btn-cancel")[0];this.btnCancel.onclick=this._onCancel.bindAsEventListener(this);if(this.bindControls){this.bindControls()}},show:function(){this.el.style.display="block";var b=this.el.down(".shadow-box-content");if(b){var e=b.viewportOffset();var c=b.getDimensions();var a=document.viewport.getDimensions();var d=(e.top+c.height-a.height);if(d>0){window.scrollBy(0,d+20)}}},_onCancel:function(a){Event.stop(a);if(this.onClose){this.onClose()}this.close()},close:function(){this.el.style.display="none"},_onSuccess:function(a){if(this.onSuccess){this.onSuccess(a)}}};var SearchPhotoEditDialog=Class.create();SearchPhotoEditDialog.prototype=Object.extend(new BasePhotoEditDialog(),{bindControls:function(){this.nameInput=$("txtSearchPersonName");this.typeahead=txtSearchPersonNameObj;this.typeahead.onSelect=this.setData.bindAsEventListener(this);this.typeahead.onServerResponse=this.onServerResponse.bindAsEventListener(this);this.typeahead.onChange=this.onChange.bindAsEventListener(this);this.yearFormatter=new YearFormatter();this.btnDone=$("btnSearchDone");this.btnDone.onclick=this.callSuccess.bindAsEventListener(this);this.typeahead.onCancel=this.btnCancel.onclick;this.typeahead.onApply=this.btnDone.onclick;this.content=$$(".person-dialog-search-content")[0];this.titleString=$$(".person-dialog-content-row")[0]},onServerResponse:function(a){if(this.onServerResponse){this.onServerResponse(a)}},onChange:function(a){this.changed=true},fill:function(a,b){this.person=a;if(a){this.titleString.innerHTML=changePositionString}else{var c="";switch(b){case IMAGE_FORMAT_PHOTO:c=setPositionString;break;case IMAGE_FORMAT_VIDEO:c=setPositionStringVideo;break;case IMAGE_FORMAT_DOCUMENT:c=setPositionStringDocument;break;case IMAGE_FORMAT_AUDIO:c=setPositionStringAudio;break;default:c=setPositionString;break}this.titleString.innerHTML=c}txtSearchPersonNameObj.clearSelectedIndividual();if(a&&a.name!=_unknown){txtSearchPersonNameObj.currentUserIndividualObj=new Object();txtSearchPersonNameObj.currentUserIndividualObj.id=a.id;txtSearchPersonNameObj.currentUserIndividualObj.gender=a.gender;txtSearchPersonNameObj.currentUserIndividualObj.isAlive=a.isAlive;txtSearchPersonNameObj.currentUserIndividualObj.name=a.name;txtSearchPersonNameObj.setRootIndividual("FL_FieldText");this.changed=false}else{if(!isTextAreaShadedEmpty(this.nameInput)){this.nameInput.value="";setTimeout(function(){try{this.nameInput.focus()}catch(d){}}.bind(this),100)}}},setData:function(a){this.dataFromList=a;this.changed=false},clear:function(){this.dataFromList=null;this.person=null;this.nameInput.value="";this.changed=true},callSuccess:function(c){Event.stop(c);if(isTextAreaShadedEmpty(this.nameInput)){return}var a=this.dataFromList!=null&&!this.changed;var d=!this.changed&&this.person;var b=[];b.name=this.nameInput.value;if(a){b.id=this.dataFromList.id;b.selectedFromList=true;b.path=this.dataFromList.path;b.relationship=this.dataFromList.relationship;b.isAlive=this.dataFromList.isAlive;b.gender=this.dataFromList.gender;this.dataFromList=null;return this._onSuccess(b)}if(d){b=this.person.json;b.name=this.nameInput.value;b.id=this.person.id;b.selectedFromList=true;return this._onSuccess(b)}b.selectedFromList=false;return this._onSuccess(b)}});var AddPhotoEditDialog=Class.create();AddPhotoEditDialog.prototype=Object.extend(new BasePhotoEditDialog(),{bindControls:function(){this.txtFirstName=$("txtFirstName");this.txtLastName=$("txtLastName");this.rbMale=$("rbMale");this.rbFeMale=$("rbFeMale");this.isAlive=$("isAlive");this.txtBornOn=$("txtBornOn");this.txtEmailAddress=$("txtEmailAddress");this.txtDescribeThisPerson=$("txtDescribeThisPerson");this.selPersonType=$("selPersonType");this.btnPersonAdd=$("btnPersonAdd");this.btnPersonAdd.onclick=this.callSuccess.bindAsEventListener(this);this.errorEl=$("addPhotoEditDialogError")},fill:function(a){var a=this.parseName(a);this.txtFirstName.value=a.firstName;this.txtLastName.value=a.lastName;this.rbMale.checked=true;this.isAlive.checked=true},parseName:function(c){var a=c.split(" ");var d=c;var b="";if(a.length!=1){b=a[a.length-1];a.length=a.length-1;d=a.join(" ")}return{firstName:d,lastName:b}},clear:function(){this.txtFirstName.value="";this.txtLastName.value="";this.txtDescribeThisPerson.value="";this.txtEmailAddress.value="";this.selPersonType.selectedIndex=0;this.displayError("");this.txtBornOn.value=""},validEmail:function(a){if(a==""){return true}return a.match(/^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$/)},displayError:function(a){if(a==""){this.errorEl.className="";this.errorEl.innerHTML=""}else{this.errorEl.className="addNewPersonError";this.errorEl.innerHTML=a}},callSuccess:function(b){Event.stop(b);if(!this.validEmail(this.txtEmailAddress.value)){this.displayError(invalidEmailAddress);return}if(this.txtFirstName.value==""&&this.txtLastName.value==""){this.displayError(pleaseEnterName);return}var a={firstName:this.txtFirstName.value,lastName:this.txtLastName.value,gender:$F(this.rbMale)=="male"?"M":"F",isAlive:$F(this.isAlive)=="on"?1:0,email:this.txtEmailAddress.value,decribeThisPerson:this.txtDescribeThisPerson.value,personType:$F(this.selPersonType),birthDate:this.txtBornOn.value,selectedFromList:true};this._onSuccess(a)},aliveChanged:function(){this.inviteRow.style.display=$F(this.isAlive)=="on"?"block":"none"}});var YearFormatter=Class.create();YearFormatter.prototype={initialize:function(){},getYear:function(e,h,f){var j=e==""&&h=="";var g=e!=""&&h=="";var c=g&&f=="no";var d=e!=""&&h!="";var b=e==""&&h!="";var k=this.parseYear(e);var a=this.parseYear(h);if(j){return""}if(d){return"("+k+"-"+a+")"}if(c){return"("+k+"-?)"}if(g){return"("+k+")"}if(b){return"(?-"+a+")"}},parseYear:function(b){var a=b.match(/\d\d\d\d/);if(a!=null){return a[0]}return""}};var PersonRow=Class.create();PersonRow.prototype={initialize:function(b,a){this.data=b;this.parent=a;this.yearFormatter=new YearFormatter();this.template='<table class="matched-person"><tbody><tr><td class="matched-person-td1">#{imageSnippet}</td><td class="matched-person-td2"><div class="person-dialog-person-info"><div><a href="#">#{name}</a></div><div>#{year}</div></div></td></tr></tbody></table>';this.render()},render:function(){this.data.year=this.yearFormatter.getYear(this.data.birthDate,this.data.deathDate,this.data.isAlive);if(this.data.path==""){this.data.imageSnippet=(this.data.isAlive=="yes"?unknownSilhouette:unknownSilhouetteDeceased);if(this.data.gender=="M"){this.data.imageSnippet=(this.data.isAlive=="yes"?maleSilhouette:maleSilhouetteDeceased)}if(this.data.gender=="F"){this.data.imageSnippet=(this.data.isAlive=="yes"?femaleSilhouette:femaleSilhouetteDeceased)}}else{this.data.imageSnippet='<img class="person-dialog-image" src="'+this.data.path+'"/>'}this.html=new Template(this.template).evaluate(this.data);new Insertion.Bottom(this.parent.personsList,this.html);this.el=this.parent.personsList.lastChild;this.el.onclick=this.onclick.bindAsEventListener(this)},onclick:function(a){Event.stop(a);this.parent.callSuccess(this.data)}};var ChoosePhotoEditDialog=Class.create();ChoosePhotoEditDialog.prototype=Object.extend(new BasePhotoEditDialog(),{bindControls:function(){this.personsList=$("personsList");this.personName=$("personName");this.contentBlock=$("chooseDialogContentBlock");this.btnNewPerson=$("btnNewPerson");this.btnNewPerson.onclick=this._onAddNewPerson.bindAsEventListener(this);this.rows=[]},fill:function(a,d){this.clear();this.name=a;this.personName.innerHTML=a;for(var b=0;b<d.length;b++){var c=d[b];this.rows.push(new PersonRow(c,this))}var e=!!(window.attachEvent&&!window.opera);if(e){this.show();this.contentBlock.style.height=this.contentBlock.getHeight()+"px"}},clear:function(){this.rows.length=0;this.personsList.innerHTML="";this.personName.innerHTML=""},_onAddNewPerson:function(a){Event.stop(a);if(this.onAddNewPerson){this.onAddNewPerson(this.name)}},callSuccess:function(a){this._onSuccess(a)}});var PersonMatcher=Class.create();PersonMatcher.prototype={initialize:function(a){this.matchCallback=a},askForMatches:function(a){var b="act=ind&siteID="+siteID+"&query="+encodeURIComponent(a);new Ajax.Request(URL_TO_AJAX_CONTROLLER,{method:"post",parameters:b,onComplete:this.onResponse.bindAsEventListener(this)})},onResponse:function(b){var a=b.responseText.evalJSON();this.matchCallback(a)}};var DialogManager=Class.create();DialogManager.prototype={initialize:function(b){this.photoManager=b;this.pathToUrl=URL_TO_AJAX_CONTROLLER;this.addDialog=new AddPhotoEditDialog("addDialog");this.searchDialog=new SearchPhotoEditDialog("searchDialog");this.chooseDialog=new ChoosePhotoEditDialog("chooseDialog");this.searchDialog.onSuccess=this.afterSearch.bindAsEventListener(this);this.searchDialog.onServerResponse=this.onServerResponse.bindAsEventListener(this);this.chooseDialog.onSuccess=this.onPersonChosen.bindAsEventListener(this);this.chooseDialog.onAddNewPerson=this.showAddDialog.bindAsEventListener(this);this.addDialog.onSuccess=this.firePersonAdded.bindAsEventListener(this);this.dialogs=$A([this.addDialog,this.searchDialog,this.chooseDialog]);this.dialogs.each(function(c){c.onClose=this._onClose.bindAsEventListener(this)}.bind(this));this.personMatcher=new PersonMatcher(this.afterSearchMatched.bindAsEventListener(this));var a=$("photo_container");this.imgLoading=$("person-dialog-img-loading");this.addDialogImgLoading=$("add-person-dialog-img-loading")},onServerResponse:function(a){if(this.onServerResponse){this.onServerResponse(a)}},closeDialogs:function(){this.dialogs.each(function(a){a.close()});this.hideImgLoading()},showDialog:function(a){this.searchDialog.fill(a,this.photoManager.photo.imageFormat);this.showConcreteDialog(this.searchDialog)},showConcreteDialog:function(a){this.closeDialogs();this.hideImgLoading();a.show()},afterSearch:function(a){if(a.selectedFromList){this.firePersonSelected(a);return}this.currentName=a.name;this.personMatcher.askForMatches(a.name)},afterSearchMatched:function(a){this.onServerResponse(a);if(a.length==0){this.addDialog.fill(this.currentName);this.showConcreteDialog(this.addDialog)}if(a.length==1){if(this.currentName==a[0].name){this.firePersonSelected(a[0]);return}}if(a.length>=1){this.chooseDialog.fill(this.currentName,a);this.showConcreteDialog(this.chooseDialog)}},onPersonChosen:function(a){this.firePersonSelected(a)},showAddDialog:function(a){this.addDialog.fill(a);this.showConcreteDialog(this.addDialog)},firePersonAdded:function(a){if(this.onPersonAdded){this.showImgLoading();this.onPersonAdded(a)}else{this.closeDialogs()}},firePersonSelected:function(a){if(this.onPersonSelected){this.showImgLoading();this.onPersonSelected(a)}else{this.closeDialogs()}},_onClose:function(){if(this.onCancel){this.onCancel()}},showImgLoading:function(){this.imgLoading.show();this.addDialogImgLoading.show();disableButtonSprite2("btnSearchDone");disableButtonSprite2("btnDialogCancel");disableButtonSprite2("btnPersonAdd");disableButtonSprite2("btnAddDialogCancel")},hideImgLoading:function(){this.imgLoading.hide();this.addDialogImgLoading.hide();restoreButtonSprite2("btnSearchDone",true);restoreButtonSprite2("btnDialogCancel",true);restoreButtonSprite2("btnPersonAdd",true);restoreButtonSprite2("btnAddDialogCancel",true)}};var PhotoManager=Class.create();PhotoManager.prototype={initialize:function(b,a){this.embededInFlash=a;this.canEdit=b.canEdit;this.ftbSource=b.ftbSource;this.dialog_container=$("dialog_container");this.add_person=$("addPeopleButton");this.initLinksHash(b.imageFormat);this.tooltip=new Tooltip($("photo_container"));this.dialog_manager=new DialogManager(this);this.maximized=b.maximized;this.directLink=b.directLink;this.photo=new Photo(this,b);this.setEvents();this.dimmer=null;if(this.embededInFlash){this.setDocumentTitle(b.title)}},initLinksHash:function(f){var e=new Array();if(f==IMAGE_FORMAT_PHOTO){e=$$("#personsTable .FL_LinkBold")}else{e=$$("#personsTable .FL_LabelBold")}var d=$$("#personsTable .individualThumb");var g=$$("#personsTable .ClickableCloseBtnOnGray");this.personLinksHash=new Array();this.relationshipHash=new Array();this.personThumbnailsHash=new Array();this.personDeletersHash=new Array();var a=e.length;var b,c;while(a--){b=e[a].getAttribute("person_id");this.personLinksHash[b]=e[a];c=e[a].up().up().select(".FL_LabelDimmed");if(c!=null&&c.length>0){this.relationshipHash[b]=c[0]}}a=d.length;while(a--){this.personThumbnailsHash[d[a].getAttribute("person_id")]=d[a]}a=g.length;while(a--){this.personDeletersHash[g[a].getAttribute("person_id")]=g[a]}},findPersonLinkById:function(a){if(this.personLinksHash[a]){return this.personLinksHash[a]}return null},findRelationshipById:function(a){if(this.relationshipHash[a]){return this.relationshipHash[a]}return null},findPersonThumbById:function(a){if(this.personThumbnailsHash[a]){return this.personThumbnailsHash[a]}return null},findDeleterById:function(a){if(this.personDeletersHash[a]){return this.personDeletersHash[a]}return null},setEvents:function(){this.windowOnResize=this.onDocumentResize.bindAsEventListener(this);Event.observe(window,"resize",this.windowOnResize);if(this.canEdit){this.dialog_manager.onPersonAdded=this.setAddedPerson.bindAsEventListener(this);this.dialog_manager.onPersonSelected=this.setPerson.bindAsEventListener(this);this.dialog_manager.onCancel=this.closeDialog.bindAsEventListener(this);this.dialog_manager.onServerResponse=this.filterExistingPersons.bindAsEventListener(this);if(this.add_person){this.add_person.onclick=this.addPerson.bindAsEventListener(this)}}this.hookupInplaceEditors()},unSetEvents:function(){this.photo.eventListener.undoListening();Event.stopObserving(window,"resize",this.windowOnResize)},hookupInplaceEditors:function(){this.closeCurrentDialogCB=null;this.saveChanges=false;var n=$("closeShowLink");n.onclick=function(){this.closeCurrentDialogCB=null;$("showDirectLinkLink").show();$("directLinkForm").hide()}.bind(this);var m=$("showDirectLinkLink");m.onclick=function(){this.closeOtherDialogs(n.onclick);$("showDirectLinkLink").hide();$("directLinkEdit").value=this.directLink;$("directLinkForm").show();$("directLinkEdit").activate();return false}.bind(this);if(!this.canEdit){return}var k=new Serializer(this.photo,false);var p=$("keywordsEditCancel");p.onclick=function(){this.closeCurrentDialogCB=null;$("editKeywordsLink").show();$("keywordsDisplay").show();$("keywordsEditForm").hide();$("keywordsEdit").value=d;this.existingKeywordManager.highlightKeywords()}.bind(this);var h=$("editKeywordsLink");h.existingKeywordManager=null;var d;h.onclick=function(){this.closeOtherDialogs(p.onclick);if(this.existingKeywordManager==null){this.existingKeywordManager=new ExistingKeywordManager()}$("editKeywordsLink").hide();$("keywordsDisplay").hide();$("keywordsEditForm").show();d=$F("keywordsEdit");$("keywordsEdit").activate();return false}.bind(this);var r=$("keywordsEditApply");r.saveCallback=function(){var u=$("keywordsDisplay");if($F("keywordsEdit")==""){u.innerHTML=""}else{var v=$F("keywordsEdit").replace(/,\s*/g,",").split(",");var t,s=v.length;for(t=0;t<s;t++){v[t]='<a href="#" onclick="searchByKeyword(event);return false;" class="FL_Link">'+v[t].escapeHTML()+"</a>"}u.innerHTML=v.join('<span class="FL_Label">, </span>')}$("editKeywordsLink").innerHTML=this.formatEditOrAddLink($F("keywordsEdit"));$("editKeywordsLink").show();$("keywordsDisplay").show();$("keywordsEditForm").hide();$("keywordsEditImgLoading").hide();restoreButtonSprite2("keywordsEditApply",true);restoreButtonSprite2("keywordsEditCancel",true);this.saveChanges=false;this.closeCurrentDialogCB=null}.bind(this);r.saveError=function(){$("keywordsEditImgLoading").hide();restoreButtonSprite2("keywordsEditApply",true);restoreButtonSprite2("keywordsEditCancel",true);this.saveChanges=false}.bind(this);r.onclick=function(){if(!this.saveChanges){this.saveChanges=true;$("keywordsEditImgLoading").show();disableButtonSprite2("keywordsEditApply");disableButtonSprite2("keywordsEditCancel");k.saveXML(r.saveCallback,r.saveError,SCENARIO_VIEWPHOTO_EDIT_KEYWORDS)}}.bind(this);$("keywordsEdit").onkeypress=function(s){this.handleKeypress(s,r.onclick)}.bindAsEventListener(this);if(!this.ftbSource){var j=$("titleEditCancel");j.onclick=function(){$("titleAndEditLink").show();$("submitterRow").show();if(!this.maximized){$("actionButtonsRow").show()}$("titleEditForm").hide();$("titleEdit").value=l;$("dateEdit").value=c;$("placeEdit").value=b;this.closeCurrentDialogCB=null}.bind(this);var f=$("editTitleDatePlace");var l,c,b;f.onclick=function(){this.closeOtherDialogs(j.onclick);$("titleAndEditLink").hide();$("submitterRow").hide();if(!this.maximized){$("actionButtonsRow").hide()}$("titleEditForm").show();l=$F("titleEdit");c=$F("dateEdit");b=$F("placeEdit");$("titleEdit").activate();return false}.bind(this);var a=$("titleEditApply");a.saveCallback=function(){this.setDocumentTitle($F("titleEdit"));$($("titleAndEditLink").firstDescendant()).innerHTML=this.formatTitle($F("titleEdit"),$F("dateEdit"),$F("placeEdit"));$("editTitleDatePlace").innerHTML=this.formatEditTitleLink($F("titleEdit"),$F("dateEdit"),$F("placeEdit"));$("titleAndEditLink").show();$("submitterRow").show();if(!this.maximized){$("actionButtonsRow").show()}$("titleEditForm").hide();$("titleEditImgLoading").hide();restoreButtonSprite2("titleEditApply",true);restoreButtonSprite2("titleEditCancel",true);this.saveChanges=false;this.closeCurrentDialogCB=null}.bind(this);a.saveError=function(){$("titleEditImgLoading").hide();restoreButtonSprite2("titleEditApply",true);restoreButtonSprite2("titleEditCancel",true);this.saveChanges=false}.bind(this);a.onclick=function(){if(!this.saveChanges){this.saveChanges=true;$("titleEditImgLoading").show();disableButtonSprite2("titleEditApply");disableButtonSprite2("titleEditCancel");k.saveXML(a.saveCallback,a.saveError,SCENARIO_VIEWPHOTO_EDIT_TITLE)}}.bind(this);$("titleEdit").onkeypress=function(s){this.handleKeypress(s,a.onclick)}.bindAsEventListener(this);$("dateEdit").onkeypress=function(s){this.handleKeypress(s,a.onclick)}.bindAsEventListener(this);$("placeEdit").onkeypress=function(s){this.handleKeypress(s,a.onclick)}.bindAsEventListener(this);var o=$("notesEditCancel");o.onclick=function(){$("editNotesLink").show();$("notesDisplay").show();$("notesEditForm").hide();$("notesEdit").value=g;this.closeCurrentDialogCB=null}.bind(this);var e=$("editNotesLink");var g;e.onclick=function(){this.closeOtherDialogs(o.onclick);$("editNotesLink").hide();$("notesDisplay").hide();$("notesEditForm").show();g=$F("notesEdit");$("notesEdit").activate();return false}.bind(this);var q=$("notesEditApply");q.saveCallback=function(){$("notesDisplay").innerHTML=$F("notesEdit").escapeHTML().replace(/\n/g,"<br />");$("editNotesLink").innerHTML=this.formatEditOrAddLink($F("notesEdit"));$("editNotesLink").show();$("notesDisplay").show();$("notesEditForm").hide();$("notesEditImgLoading").hide();restoreButtonSprite2("notesEditApply",true);restoreButtonSprite2("notesEditCancel",true);this.saveChanges=false;this.closeCurrentDialogCB=null}.bind(this);q.saveError=function(){$("notesEditImgLoading").hide();restoreButtonSprite2("notesEditApply",true);restoreButtonSprite2("notesEditCancel",true);this.saveChanges=false}.bind(this);q.onclick=function(){if(!this.saveChanges){this.saveChanges=true;$("notesEditImgLoading").show();disableButtonSprite2("notesEditApply");disableButtonSprite2("notesEditCancel");k.saveXML(q.saveCallback,q.saveError,SCENARIO_VIEWPHOTO_EDIT_NOTES)}}.bind(this);$("notesEdit").onkeypress=function(s){this.handleKeypress(s)}.bindAsEventListener(this)}},closeOtherDialogs:function(a){this.photo.closeCurrentPerson();this.dialog_manager.closeDialogs();if(this.closeCurrentDialogCB){this.closeCurrentDialogCB()}this.closeCurrentDialogCB=a},formatTitle:function(d,c,b){var a="";var e="";if(d.strip()==""){d=untitledTitle}if(d.strip()!=""){a=d.escapeHTML()}if(c.strip()!=""){e+=c.escapeHTML()}if(b.strip()!=""){if(e!=""){e+=", "}e+=b.escapeHTML()}if(e!=""){if(a!=""){a+=" &ndash; "}a+=e}return a},formatEditTitleLink:function(c,b,a){var d;if(c.strip()==""||b.strip()==""||a.strip()==""){d=editTitleDatePlace}else{d=editLinkEdit}return"("+d+")"},formatEditOrAddLink:function(a){if(a.strip()==""){return"("+editLinkAdd+")"}else{return"("+editLinkEdit+")"}},setDocumentTitle:function(d){if(origTitle==""){origTitle=document.title}var a="";switch(this.photo.imageFormat){case IMAGE_FORMAT_PHOTO:a=titleFormatPrefixPhoto;break;case IMAGE_FORMAT_VIDEO:a=titleFormatPrefixVideo;break;case IMAGE_FORMAT_DOCUMENT:a=titleFormatPrefixDocument;break;case IMAGE_FORMAT_AUDIO:a=titleFormatPrefixAudio;break;default:a=titleFormatPrefixPhoto;break}document.title=a.replace("%1",d)+titleFormatSuffix;if(Prototype.Browser.IE){try{var c=document.frames("ajaxIFrame");if(c){c.document.title=document.title}}catch(b){}}},resetDocumentTitle:function(){if(origTitle!=""){document.title=origTitle}},filterExistingPersons:function(d){var c=function(f){for(var e=0;e<this.photo.persons.length;e++){if(this.photo.persons[e].id==f){return true}}return false}.bind(this);var b=[];for(var a=0;a<d.length;a++){if(c(d[a].id)){if((txtSearchPersonNameObj.selectedIndividualObj==null)||(txtSearchPersonNameObj.selectedIndividualObj!=null&&d[a].id!=txtSearchPersonNameObj.selectedIndividualObj.id)){b.push(a-b.length)}}}for(var a=0;a<b.length;a++){d.splice(b[a],1)}},deletePerson:function(b){this.photo.deletePerson();if(b){var a=new Serializer(this.photo,true);a.saveXML(function(){this.deletePersonCallback()}.bind(this))}else{this.deletePersonCallback()}},deletePersonCallback:function(){this.photo.deletePersonAfterSave();if(this.photo.isAddingPersonMode){this.cancelAddingPerson()}this.closeDialog()},setPersonCommon:function(b,c){var a=new Serializer(this.photo,true);this.person_name=this.photo.currentPerson.name;this.photo.currentPerson.setPerson(b);a.saveXML(function(d){this.setPersonCallback(b,c,d)}.bind(this))},setPerson:function(a){this.setPersonCommon(a,false)},setAddedPerson:function(a){this.setPersonCommon(a,true)},setPersonCallback:function(c,e,l){this.dialog_manager.closeDialogs();if(this.photo.isAddingPersonMode){this.photo.fixSepInPersonsTable(this.photo.currentPerson.personDiv);this.cancelAddingPerson()}if(e){var f=l.documentElement.getElementsByTagName("individual");if(f!=null){var b,a=this.photo.currentPerson.mark;var j=Math.round(a.x/this.photo.ratio);var g=Math.round(a.y/this.photo.ratio);var k=Math.round(a.w/this.photo.ratio);var d=Math.round(a.h/this.photo.ratio);for(b=f.length-1;b>=0;b--){if(f[b].getAttribute("x")==j&&f[b].getAttribute("y")==g&&f[b].getAttribute("w")==k&&f[b].getAttribute("h")==d){this.photo.currentPerson.id=f[b].getAttribute("id");break}}}this.photo.currentPerson.isNew=false}this.photo.updateWhoAppearsInstructions();this.closeDialog()},closeDialog:function(){if(this.photo.isAddingPersonMode){this.cancelAddingPerson();this.deletePerson();return}var a=$("editPhotoContent");if(a){$("editPhotoContent").appendChild(this.dialog_container)}else{document.body.appendChild(this.dialog_container)}if(!this.photo.currentPerson){this.photo.isEditStatus=false;return}this.photo.isEditStatus=true;this.photo.currentPerson.mark.setMode()},cancelAddingPerson:function(){this.photo.isAddingPersonMode=false},addPerson:function(){this.closeOtherDialogs();this.photo.addPerson()},clickPersonById:function(a){this.photo.selectPersonById(a)},handleKeypress:function(c,b){var a=c.keyCode?c.keyCode:c.charCode;if(c.keyCode==Event.KEY_RETURN&&b){b(c)}else{if(c.keyCode==Event.KEY_ESC&&this.closeCurrentDialogCB){this.closeCurrentDialogCB(c)}}},maximize:function(){if(!this.maximized){this.maximized=true;$$(".NormalPhoto").first().className="MaximizedPhoto";this.scrollToTopOfPhoto(-1);this.onDocumentResize();new Ajax.Request("/FP/API/Photos/set-view-mode.php?maximize=1")}},minimize:function(){if(this.maximized){this.maximized=false;$("rightPhotoPanelRounded").style.height="auto";$$(".MaximizedPhoto").first().className="NormalPhoto";this.scrollToTop();this.onDocumentResize();new Ajax.Request("/FP/API/Photos/set-view-mode.php?maximize=0")}},scrollToTop:function(){$("masterPageHeader").scrollTo()},scrollToTopOfPhoto:function(b){var a=null;var c=$$(".MasterPageMainBox");if(c!=null&&c.size()==1){a=c.first().up("table")}if(a!=null){if(b==-1){a.scrollTo()}else{var d=a.cumulativeOffset();if(d.top>b){a.scrollTo()}else{window.scrollTo(0,b)}}}},onDocumentResize:function(b){var a=this.photo.ratio;if(this.photo.resizeToFullScreen(a)){this.photo.repositionMarkers(a)}if(this.isDimmedPreloaderVisible()){this.showDimmedPreloader()}},upscaleIndividualThumbs:function(b,c){var e,a;var d=$$("#personsTable IMG");if(d!=null){a=d.length;for(e=0;e<a;e++){if(d[e].src==b){d[e].src=c}}}},showDimmedPreloader:function(){var a=$("editPhotoContent");if(a){if(this.dimmer==null){var c=new SWFObject(editPhotoPreloader,"editPhotoPreloader","65","65");c.addParam("quality","best");c.addParam("allowScriptAccess","never");c.addParam("wmode","transparent");this.dimmer=new Element("div",{"class":"dimmer"});this.dimmer.setOpacity(0.65);this.flashDiv=new Element("div").insert(c.getSWFHTML());this.flashDiv.style.position="absolute";this.flashDiv.style.zIndex=100;this.photo.photoContainer.insert(this.dimmer);this.dimmer.insert({after:this.flashDiv})}this.dimmer.style.height=a.getHeight()+"px";this.dimmer.style.width=a.getWidth()+"px";var b=this.photo.photoContainer.cumulativeOffset();var d=a.cumulativeOffset();this.dimmer.style.top=(d.top-b.top)+"px";this.dimmer.style.left=(d.left-b.left)+"px";this.flashDiv.style.top=(Math.round((this.photo.photoContainer.getHeight()-65)/2))+"px";this.flashDiv.style.left=(Math.round((this.photo.photoContainer.getWidth()-65)/2))+"px";this.dimmer.show();this.flashDiv.show()}},hideDimmedPreloader:function(){if(this.isDimmedPreloaderVisible()){this.dimmer.hide();this.flashDiv.hide()}},isDimmedPreloaderVisible:function(){if(this.dimmer!=null&&this.dimmer.visible()){return true}return false}};var Photo=Class.create();Photo.prototype={initialize:function(c,b){this.isEditStatus=false;this.isConfirmWaiting=false;this.photoManager=c;this.json=b;this.canEdit=this.json.canEdit;this.pid=b.pid;this.ratio=b.ratio;this.imageFormat=b.imageFormat;if(this.imageFormat==IMAGE_FORMAT_AUDIO||this.imageFormat==IMAGE_FORMAT_VIDEO){this.flowPlayerId=b.flowPlayerId}this.hasReverseSide=b.hasReverseSide;this.prevNextThumbs=b.prevNextThumbs;this.currentPerson=null;this.photoThumbs=b.photoThumbs;this.photoThumbs[0].loaded=true;this.photoImg=$("viewPhoto");this.photoImgHeight=0;if(this.hasReverseSide){this.reverseImg=$("viewReversePhoto");this.photoThumbs[0].reverseLoaded=true}this.resizeToFullScreen(this.ratio,true);if(this.photoManager.maximized){this.photoManager.scrollToTopOfPhoto(b.saveTopOffset)}$("photoContainerTd").show();$("commentsTd").style.display="";this.photoContainer=$("photo_container");this.photoKeywordsContainer=$("keywordsEdit");if(!this.photoManager.ftbSource){this.photoTitleContainer=$("titleEdit");this.photoDateContainer=$("dateEdit");this.photoPlaceContainer=$("placeEdit");this.photoNotesContainer=$("notesEdit")}var a=$("personsTable");if(a){this.personsContainer=a.down()}this.persons=new Array();this.eventListener=new EventListener();this.initPersons();this.dimmers=null},selectPersonById:function(a){this.persons.each(function(b){if(b.id==a){b.onclick();return}}.bind(this))},initPersons:function(){this.highlightedPerson=null;this.json.persons.each(function(b){var a=new Person(this,b);this.persons.push(a)}.bind(this));this.initPhotoFileds()},fixSepInPersonsTable:function(b){var a=$("PeopleInPhotoSeparator");if(b){if(b.up()){b.remove()}a.insert({before:b})}if(a.next()&&a.previous()){a.show()}else{a.hide()}},initPhotoFileds:function(){if(this.canEdit){this.photoKeywordsContainer.value=this.json.keywords;if(!this.photoManager.ftbSource){this.photoTitleContainer.value=this.json.title;this.photoDateContainer.value=this.json.date;this.photoPlaceContainer.value=this.json.place;this.photoNotesContainer.value=this.json.notes}}this.setEvents()},deletePerson:function(){this.persons=Tools.removeElementFromArray(this.currentPerson,this.persons)},deletePersonAfterSave:function(){this.currentPerson.deletePersonGifts();this.currentPerson=null;this.updateWhoAppearsInstructions()},addPerson:function(){this.closeCurrentPerson();var a=0,b=0,e=0,d=0;if(this.isRealPhoto()){a=7;e=7;b=92;d=122;if(displayLanguageDirection=="right"){a=this.photoContainer.getWidth()-a-b}}var c=new Person(this,{x:a/this.ratio,y:e/this.ratio,w:b/this.ratio,h:d/this.ratio,n:""},true);this.persons.push(c);this.isAddingPersonMode=true;c.onclick()},closeCurrentPerson:function(){if(this.isEditStatus&&this.currentPerson){this.currentPerson.onclick()}},updateWhoAppearsInstructions:function(){var c=$("PeopleInPhotoSubCaption");var a=$("addPeopleButton-middle");if(a&&a.down()&&c){if(this.persons.length>0){a.down().innerHTML=addAnotherPerson.escapeHTML();if(this.isRealPhoto()){c.innerHTML=addAnotherPersonSubCaption.escapeHTML()}else{c.innerHTML=""}}else{a.down().innerHTML=addAPerson.escapeHTML();var b="";switch(this.imageFormat){case IMAGE_FORMAT_PHOTO:b=addAPersonSubCaption;break;case IMAGE_FORMAT_VIDEO:b=addAPersonSubCaptionVideo;break;case IMAGE_FORMAT_DOCUMENT:b=addAPersonSubCaptionDocument;break;case IMAGE_FORMAT_AUDIO:b=addAPersonSubCaptionAudio;break}c.innerHTML=b.escapeHTML()}}},setEvents:function(){this.photoContainer.onmouseover=this.onmouseover.bindAsEventListener(this);this.photoContainer.onmouseout=this.onmouseout.bindAsEventListener(this)},selectAllMarks:function(b){var a=b?"yellow":"green";this.persons.each(function(c){c.selectPerson(b)}.bind(this))},deselectAllMarks:function(a){this.persons.each(function(b){b.deselectPerson(a)}.bind(this))},deselectGreenSelection:function(){this.persons.each(function(a){a.mark.removeGreenSelection()}.bind(this))},onmouseover:function(b){this.isOutContainer=false;if(this.isEditStatus||this.isConfirmWaiting||this.photoManager.isDimmedPreloaderVisible()){if(this.eventListener.isUnpress==true){this.photoContainer.onmousemove=null}return}var a=Event.element(b);this.selectAllMarks(true)},onmouseout:function(b){this.isOutContainer=true;if(this.isEditStatus||this.isConfirmWaiting||this.photoManager.isDimmedPreloaderVisible()){this.eventListener.setUnpress();return}var c=Event.element(b);var k=this.photoContainer.cumulativeOffset();var l=this.photoContainer.getDimensions();var e=k.left;var a=k.top;var j=k.left+l.width-1;var h=k.top+l.height-1;var g=Event.pointerX(b);var d=Event.pointerY(b);if(Prototype.Browser.IE&&g>=0){g-=3;if(languageDirection=="RTL"&&document.body.scrollHeight>document.body.clientHeight){g-=18}d-=3}var f=(g>e&&d>a&&g<j&&d<h);if(c.className.indexOf("rectangle")!=-1||c.parentNode.className.indexOf("rectangle")!=-1){return}if(!f){this.deselectAllMarks(false);this.deselectGreenSelection()}},dimPhoto:function(b){var a;if(this.dimmers==null){var c=(this.isRealPhoto()?4:1);this.dimmers=new Array(c);for(a=0;a<c;a++){this.dimmers[a]=new Element("div",{"class":"dimmer"});this.dimmers[a].setOpacity(0.65);this.photoContainer.insert(this.dimmers[a])}this.dimmers[0].style.top="0px";this.dimmers[0].style.left="0px";if(c==4){this.dimmers[2].style.left="0px";this.dimmers[3].style.left="0px"}}for(a=0;a<this.dimmers.length;a++){this.dimmers[a].show()}this.positionDimmers(b);if(this.imageFormat==IMAGE_FORMAT_AUDIO||this.imageFormat==IMAGE_FORMAT_VIDEO){this.pauseFlowPlayer()}},undimPhoto:function(){if(this.dimmers==null){return}var a;for(a=0;a<this.dimmers.length;a++){this.dimmers[a].hide()}if(this.imageFormat==IMAGE_FORMAT_AUDIO||this.imageFormat==IMAGE_FORMAT_VIDEO){this.resumeFlowPlayer()}},positionDimmers:function(d){if(this.dimmers==null){return}var c=this.photoContainer.getDimensions().width;var f=this.photoContainer.getDimensions().height;if(!this.isRealPhoto()){this.dimmers[0].style.height=f+"px";this.dimmers[0].style.width=c+"px";this.dimmers[0].show();return}var a=d.x;var g=d.y;var e=d.h+3;var b=d.w+3;if(g>0){this.dimmers[0].show();this.dimmers[0].style.height=g+"px";this.dimmers[0].style.width=c+"px"}else{this.dimmers[0].hide()}if(e>0&&(c-b-a)>0){this.dimmers[1].show();this.dimmers[1].style.width=(c-b-a)+"px";this.dimmers[1].style.top=g+"px";this.dimmers[1].style.left=(a+b)+"px";this.dimmers[1].style.height=e+"px"}else{this.dimmers[1].hide()}if(f-g-e>0){this.dimmers[2].show();this.dimmers[2].style.top=(g+e)+"px";this.dimmers[2].style.height=(f-g-e)+"px";this.dimmers[2].style.width=c+"px"}else{this.dimmers[2].hide()}if(e>0&&a>0){this.dimmers[3].show();this.dimmers[3].style.top=g+"px";this.dimmers[3].style.width=a+"px";this.dimmers[3].style.height=e+"px"}else{this.dimmers[3].hide()}},resizeToFullScreen:function(f,x){if($("rightPhotoPanelWidget")==null){return false}var y=Math.max(1020,document.viewport.getWidth());var o=y-17-15-18-5*2;o-=$("rightPhotoPanelWidget").getWidth()+parseInt($("rightPhotoPanelOuter").getStyle(displayLanguageDirection=="left"?"padding-left":"padding-right"));var D=$("prevNextButtonsRow");if(D==null){D=$("actionButtonsRow")}var d=0;if(!this.photoManager.maximized){var j=D.cumulativeOffset();d=j.top}var z=document.viewport.getHeight()-d-D.getHeight()-30;if(this.imageFormat!=IMAGE_FORMAT_PHOTO){if(this.imageFormat==IMAGE_FORMAT_DOCUMENT){o=Math.max(550,o-10);z=Math.max(412,z-10);var u=$$(".scribdInternalBorder");if(u!=null&&u.length>0){u[0].style.width=o+"px";u[0].style.height=z+"px"}}else{if(this.imageFormat==IMAGE_FORMAT_AUDIO){z=38}else{if(this.imageFormat==IMAGE_FORMAT_VIDEO){z=this.photoThumbs[this.photoThumbs.length-1].height}}}this.photoImgHeight=z;this.resizeRightPannel();return false}var t=this.photoThumbs[0].width;var C=this.photoThumbs[0].height;var q=this.photoThumbs[this.photoThumbs.length-1].width;var p=this.photoThumbs[this.photoThumbs.length-1].height;var e=q;var E=p;if(e==0||E==0){return false}var n=0;var h=0;if(this.hasReverseSide){o-=20;t+=this.photoThumbs[0].reverseWidth;C=Math.max(C,this.photoThumbs[0].reverseHeight);n=this.photoThumbs[this.photoThumbs.length-1].reverseWidth;h=this.photoThumbs[this.photoThumbs.length-1].reverseHeight;if(n==0||h==0){return false}if(typeof this.reverseFactor=="undefined"){this.reverseFactor=this.photoThumbs[0].reverseWidth/(n*this.ratio)}n=n*this.reverseFactor;h=h*this.reverseFactor;q+=n;p=Math.max(p,h)}if(o>q&&z>p){o=q;z=p}if(o<t||z<C){o=t;z=C}if(this.photoThumbs.length>1&&o>this.photoThumbs[1].width&&o-44<=this.photoThumbs[1].width){o=this.photoThumbs[1].width;z=this.photoThumbs[1].height}var k=o/q;var a=z/p;var b=Math.min(k,a);if(b/this.ratio>0.97&&b/this.ratio<1.03){if(x){this.preloadPrevNextThumbs()}this.photoImgHeight=p;this.resizeRightPannel();return false}var s=Math.round(b*e);var g=Math.round(b*E);this.ratio=b;var B,w=this.photoThumbs.length;for(B=0;B<w;B++){if(this.photoThumbs[B].width>=s&&this.photoThumbs[B].height>=g){this.photoImg.height=g;this.photoImg.width=s;this.photoImgHeight=g;var A=this.photoImg.src;if(A!=this.photoThumbs[B].src){var v=null;var r=function(){if($("viewPhotoFetchingPreloader")==null){return}this.photoImg.src=this.photoThumbs[B].src;v=null;this.photoThumbs[B].loaded=true;if(b>f){this.photoManager.upscaleIndividualThumbs(A,this.photoImg.src)}if(x){this.preloadPrevNextThumbs()}$("viewPhotoFetchingPreloader").hide()}.bind(this);if(!this.photoThumbs[B].loaded){v=new Element("img",{src:this.photoThumbs[B].src});if(v.complete){r()}else{Event.observe(v,"load",r);if($("viewPhotoFetchingPreloader")!=null){$("viewPhotoFetchingPreloader").show()}}}else{r()}}else{if(x){this.preloadPrevNextThumbs()}}if(this.hasReverseSide){var G=Math.round(b*n);var m=Math.round(b*h);this.reverseImg.height=m;this.reverseImg.width=G;var F=null;var c=function(){this.reverseImg.src=this.photoThumbs[B].reverseSrc;F=null;this.photoThumbs[B].reverseLoaded=true}.bind(this);if(!this.photoThumbs[B].reverseLoaded){F=document.createElement("img");F.src=this.photoThumbs[B].reverseSrc;if(F.complete){c()}else{F.onload=c}}else{c()}}break}}this.resizeRightPannel();return true},resizeRightPannel:function(){if($("rightPhotoPanelRounded")==null){return}if(this.photoManager.maximized){var a=0;if(this.photoImg!=null){a=this.photoImg.height}if(Object.isUndefined(a)||a==0){a=this.photoImgHeight}if(this.hasReverseSide){a=Math.max(a,this.reverseImg.height)}$("rightPhotoPanelRounded").style.height=a+"px"}else{$("rightPhotoPanelRounded").style.height="auto"}},repositionMarkers:function(a){this.persons.each(function(b){b.reposition(a,this.ratio)}.bind(this))},preloadPrevNextThumbs:function(){if(this.prevNextThumbs==null){return}for(i=0;i<this.prevNextThumbs.length;i++){if(this.prevNextThumbs[i]!=""){var a=new Element("img",{src:this.prevNextThumbs[i]})}}this.prevNextThumbs=null},isRealPhoto:function(){return this.imageFormat==IMAGE_FORMAT_PHOTO},pauseFlowPlayer:function(){this.resumePending=false;if(this.flowPlayer==null){this.flowPlayer=flowplayer(this.flowPlayerId)}if(this.flowPlayer.getState()==3){this.flowPlayer.pause();this.resumePending=true}},resumeFlowPlayer:function(){if(this.flowPlayer==null){this.flowPlayer=flowplayer(this.flowPlayerId)}if(this.resumePending){this.flowPlayer.play()}}};var Person=Class.create();Person.prototype={initialize:function(b,c,a){this.photo=b;this.tooltip=this.photo.photoManager.tooltip;this.json=c;this.name=c.n?c.n.strip():_unknown;this.gender=c.gender;this.isAlive=(c.isAlive!=""?c.isAlive:1);this.ftbSource=this.json.source==TAG_SOURCE_FTB;this.isNew=a;if(this.isNew){this.name="";this.ftbSource=false}this.canEdit=(this.photo.photoManager.canEdit&&!this.ftbSource);this.id=c.id;this.mark=new Rectangle(this,c);this.nameLink=this.photo.photoManager.findPersonLinkById(this.id);this.relationshipSpan=this.photo.photoManager.findRelationshipById(this.id);this.thumb=this.photo.photoManager.findPersonThumbById(this.id);this.deleteIconDiv=this.photo.photoManager.findDeleterById(this.id);this.render();this.setEvents()},render:function(){if(this.nameLink){this.personDiv=this.thumb.up().up()}else{this.personDiv=new Element("tr");var c=new Element("td",{valign:"top"});var b=new Element("td",{"class":"individualName"});var a=new Element("td",{"class":"individualMoreInfo"});this.personDiv.appendChild(c);this.personDiv.appendChild(b);this.personDiv.appendChild(a);this.thumb=new Element("img",{"class":"individualThumb"});c.appendChild(this.thumb);if(this.photo.isRealPhoto()){this.nameLink=new Element("a",{"class":"FL_LinkBold",href:"#",onclick:"return false"}).update(this.name.escapeHTML())}else{this.nameLink=new Element("span",{"class":"FL_LabelBold"}).update(this.name.escapeHTML())}b.appendChild(this.nameLink);if(this.canEdit){this.deleteIconDiv=new Element("img",{"class":"Clickable ClickableCloseBtnOnGray",vspace:"3",title:deleteThisTag,src:"/FP/Images/spacer.gif"});b.appendChild(this.deleteIconDiv)}this.relationshipSpan=new Element("span",{"class":"FL_LabelDimmed"});b.appendChild(new Element("br"));b.appendChild(this.relationshipSpan)}},deletePersonGifts:function(){try{this.personDiv.remove();this.photo.fixSepInPersonsTable()}catch(a){}this.mark.remove()},setEvents:function(){var a="";if(this.canEdit){if(this.isIdentified()){a=changeNameOrPosition}else{a=identifyThisPerson}}if(this.deleteIconDiv&&this.canEdit){this.deleteIconDiv.onmouseover=this.delete_icon_onmouseover.bindAsEventListener(this);this.deleteIconDiv.onmouseout=this.delete_icon_onmouseout.bindAsEventListener(this);this.deleteIconDiv.onclick=this.delete_icon_onclick.bindAsEventListener(this)}if(this.nameLink&&this.photo.isRealPhoto()){this.nameLink.onmouseover=this.onmouseover.bindAsEventListener(this);this.nameLink.onmouseout=this.onmouseout.bindAsEventListener(this);this.nameLink.onclick=this.onclick.bindAsEventListener(this);this.nameLink.title=a}if(this.thumb&&this.photo.isRealPhoto()){this.thumb.onmouseover=this.onmouseover.bindAsEventListener(this);this.thumb.onmouseout=this.onmouseout.bindAsEventListener(this);this.thumb.onclick=this.onclick.bindAsEventListener(this);this.thumb.title=a}},delete_icon_onmouseover:function(){this.deleteIconDiv.addClassName("ClickableCloseBtnOnGrayRoll");this.thumb.addClassName("person_thumb_to_delete");this.nameLink.addClassName("person_name_to_delete");if(this.relationshipSpan!=null){this.relationshipSpan.addClassName("person_relationship_to_delete")}this.selectPerson(true,true)},delete_icon_onmouseout:function(){if(this.photo.isConfirmWaiting){return}this.deleteIconDiv.removeClassName("ClickableCloseBtnOnGrayRoll");this.thumb.removeClassName("person_thumb_to_delete");this.nameLink.removeClassName("person_name_to_delete");if(this.relationshipSpan!=null){this.relationshipSpan.removeClassName("person_relationship_to_delete")}this.deselectPerson()},delete_icon_onclick:function(){this.photo.photoManager.closeOtherDialogs();this.delete_icon_onmouseover();this.photo.isConfirmWaiting=true;var a=deleteThisTagConfirm;switch(this.photo.imageFormat){case IMAGE_FORMAT_PHOTO:a=deleteThisTagConfirm;break;case IMAGE_FORMAT_VIDEO:a=deleteThisTagConfirmVideo;break;case IMAGE_FORMAT_DOCUMENT:a=deleteThisTagConfirmDocument;break;case IMAGE_FORMAT_AUDIO:a=deleteThisTagConfirmAudio;break}var b=(this.isIdentified()?a.replace(/%1/,this.name):deleteThisUnknownConfirm);if(!window.confirm(b)){this.photo.isConfirmWaiting=false;this.delete_icon_onmouseout();return}this.photo.isConfirmWaiting=false;this.deleteIconDiv.src=$("keywordsEditImgLoading").src;this.deleteIconDiv.setStyle({background:"none",width:"16px",height:"16px"});this.deleteIconDiv.setAttribute("width","16");this.deleteIconDiv.setAttribute("height","16");this.photo.photoManager.closeDialog();this.photo.currentPerson=this;this.photo.photoManager.deletePerson(true)},onmouseover:function(){if(this.photo.isEditStatus){return}this.highlightLink();this.selectPerson(true,true)},onmouseout:function(){if(this.photo.isEditStatus){return}this.unhighlightLink();this.deselectPerson()},highlightLink:function(a){if(this.photo.highlightedPerson!=null&&this.photo.highlightedPerson!=this){this.photo.highlightedPerson.unhighlightLink()}this.photo.highlightedPerson=this;if(this.nameLink){if(a){this.nameLink.removeClassName("selected_person");this.nameLink.addClassName("selected_person_perm")}else{this.nameLink.addClassName("selected_person")}}if(this.thumb){this.thumb.addClassName("selected_person_thumb")}},unhighlightLink:function(){if(this.photo.highlightedPerson==this){this.photo.highlightedPerson=null}if(this.nameLink){this.nameLink.removeClassName("selected_person");this.nameLink.removeClassName("selected_person_perm")}if(this.thumb){this.thumb.removeClassName("selected_person_thumb")}},selectPerson:function(b,a){this.mark.show(b,a)},selectPersonByRectangle:function(){if(this.photo.isEditStatus){return}this.highlightLink(true)},deselectPerson:function(a){this.mark.hide(a)},deselectPersonByRectangle:function(){if(this.photo.isEditStatus){return}this.unhighlightLink()},onclick:function(a){if(a){Event.stop(a)}if(!this.canEdit){return}this.mark.edited=true;this.deselectPerson();if(this==this.photo.currentPerson){this.photo.photoManager.closeDialog();return}this.photo.photoManager.closeOtherDialogs();this.photo.currentPerson=this;this.mark.isDisplayRectangleNone=false;this.mark.setMode()},setPerson:function(d){var j=this.isIdentified();var e=this.id;if(d.id){this.isNew=false}else{this.isNew=true}this.name=d.name?d.name:this.getName(d);this.id=d.id;this.nameLink.innerHTML=html_entity_encode(this.name);if(this.relationshipSpan!=null){this.relationshipSpan.innerHTML=(typeof d.relationship=="undefined"?"":html_entity_encode(d.relationship))}if((!j||e!=d.id||this.json.w==0||this.json.h==0)&&this.thumb){var l=this.thumb.up();this.thumb.remove();if(this.photo.isRealPhoto()){this.thumb=new Element("a",{"class":"individualThumb",href:"#"})}else{this.thumb=new Element("span",{"class":"individualThumb"})}var c=false;if(d.path){this.thumbInner=new Element("span");this.thumbInner2=new Element("img",{src:d.path,border:"0"});this.thumb.insert(this.thumbInner);this.thumbInner.insert(this.thumbInner2);l.insert(this.thumb)}else{if(this.mark.w>0&&this.mark.h>0){var r,q,t,v,f,g,b;var m=this.mark.ratio;var p=this.mark.w;var s=this.mark.h;var o=this.mark.x;var n=this.mark.y;if(p/s<0.75){r=40/(s*m)}else{r=30/(p*m)}q=Math.round(n*m*r);t=Math.round(o*m*r);v=Math.round((n+s)*m*r);f=Math.round((o+p)*m*r);var k=this.photo.photoImg.getDimensions();g=Math.round(k.width*m*r);b=Math.round(k.height*m*r);clipInfo="position:absolute;clip: rect("+q+"px,"+f+"px,"+v+"px,"+t+"px);top:"+(-q)+"px;left:"+(-t)+"px;width:"+g+"px;height:"+b+"px;";enclosingDivInfo="width:"+(f-t)+"px;height:"+(v-q)+"px;";this.thumbInner=new Element("span",{style:enclosingDivInfo});this.thumbInner2=new Element("img",{src:this.photo.photoImg.src,style:clipInfo,border:"0"});this.thumb.insert(this.thumbInner);this.thumbInner.insert(this.thumbInner2);l.insert(this.thumb)}else{var u=(d.isAlive?unknownSilhouette:unknownSilhouetteDeceased);if(d.gender=="M"){u=(d.isAlive?maleSilhouette:maleSilhouetteDeceased)}if(d.gender=="F"){u=(d.isAlive?femaleSilhouette:femaleSilhouetteDeceased)}this.thumb.insert(u);l.insert(this.thumb);c=true}}if(!c&&!d.isAlive){var a=new Element("img",{src:ribbonOfDeathURL,border:"0",style:"position:absolute;top:0px;"+displayLanguageDirection+":0px"});this.thumbInner.insert(a)}this.setEvents()}this.json=d;if(!j){this.photo.fixSepInPersonsTable(this.personDiv)}},getName:function(a){if(a.firstName.strip()==""){return a.lastName}if(a.lastName.strip()==""){return a.firstName}return a.firstName+" "+a.lastName},changeColor:function(){if(this.photo.isEditStatus){this.highlightLink(true)}else{this.unhighlightLink()}},isIdentified:function(){var a=parseInt(this.id);if(!isNaN(a)&&a>10000){return true}else{return false}},reposition:function(b,e){var c,a,d,g;if(this.mark.edited==false){var f=this.json;c=f.x;a=f.y;d=f.w;g=f.h}else{c=this.mark.x/b;a=this.mark.y/b;d=this.mark.w/b;g=this.mark.h/b}this.mark.x=Math.round(c*e);this.mark.y=Math.round(a*e);this.mark.h=Math.round(g*e);this.mark.w=Math.round(d*e);this.mark.initPositions()}};var Rectangle=Class.create();Rectangle.prototype={initialize:function(a,b){this.edited=false;this.person=a;this.photo=a.photo;this.container=this.photo.photoContainer;this.ratio=this.photo.ratio;this.x=Math.round(this.ratio*parseInt(b.x));this.y=Math.round(this.ratio*parseInt(b.y));this.h=Math.round(this.ratio*parseInt(b.h));this.w=Math.round(this.ratio*parseInt(b.w));this.tooltip=this.photo.photoManager.tooltip;this.currentCorner=null;this.borders=[];this.corners=[];this.render();this.setEvents();if(this.photo.isRealPhoto()){this.animationManager=new RectangleActionManager(this)}this.fadeTimerID=null},render:function(){this.rectangle=Tools.createDiv("rectangle");this.middle_border=Tools.createDiv("middle_border");this.inner_border=Tools.createDiv("inner_border");if(this.w==0||this.h==0){this.isDisplayRectangleNone=true;this.initDefaultSizes()}this.connector=Tools.createDiv("connector");if(this.photo.isRealPhoto()){this.renderRectangleBorder();this.rectangle_area=Tools.createDiv("rectangle_area");this.rectangle_area.style.zIndex=201;this.rectangle_area.style.position="relative";this.initPositions();this.container.appendChild(this.rectangle);this.rectangle.appendChild(this.rectangle_area);this.rectangle.appendChild(this.middle_border);this.rectangle.appendChild(this.inner_border);this.rectangle.appendChild(this.connector)}else{this.connector.style.position="absolute";this.connector.style.zIndex=201;var a=this.photo.photoContainer.getDimensions().width;var b=this.photo.photoContainer.getDimensions().height;var d=(b-144)/2-7;var c=(a-290)/2;if(d<0||isNaN(d)){d=0}if(c<0||isNaN(c)){c=0}this.connector.style.top=d+"px";this.connector.style.left=c+"px";this.container.appendChild(this.connector)}this.initCorners()},initDefaultSizes:function(){if(this.photo.isRealPhoto()){this.x=7;this.y=7;this.h=122;this.w=92}else{this.x=0;this.y=0;this.h=0;this.w=0}},renderRectangleBorder:function(){this.addBorder("left_edit_border");this.addBorder("top_edit_border");this.addBorder("bottom_edit_border");this.addBorder("right_edit_border")},addBorder:function(a){var b=Tools.createDiv(a);this.borders.push(b);this.rectangle.appendChild(b)},showEditBorder:function(){this.borders.each(function(a){a.style.display="block"}.bind(this))},hideEditBorder:function(){this.borders.each(function(a){a.style.display="none"}.bind(this))},showCorners:function(){this.corners.each(function(a){a.style.display="block"}.bind(this))},hideCorners:function(){this.corners.each(function(a){a.style.display="none"}.bind(this))},initCorners:function(){this.leftTopCorner=this.initCorner("left_top");this.leftBottomCorner=this.initCorner("left_bottom");this.rightTopCorner=this.initCorner("right_top");this.rightBottomCorner=this.initCorner("right_bottom")},initCorner:function(a){var b=new CornerBounder();b=b.initCorner(this,a);b.render();b.setPosition();this.corners.push(b.corner);return b},initPositions:function(){this.updatePositions();this.updateDimensions()},updateDimensions:function(){this.rectangle.style.width=this.w+3+"px";this.rectangle.style.height=this.h+3+"px";var a=Prototype.Browser.IE?4:0;this.middle_border.style.width=Math.max(this.w-3+a,0)+"px";this.middle_border.style.height=Math.max(this.h-3+a,0)+"px";this.inner_border.style.width=Math.max(this.w-5,0)+"px";this.inner_border.style.height=Math.max(this.h-5,0)+"px";if(this.photo.isEditStatus&&this.dashedMode){this.photo.positionDimmers(this)}},updatePositions:function(){this.rectangle.style.left=this.x+"px";this.rectangle.style.top=this.y+"px";this.middle_border.style.left=0+"px";this.middle_border.style.top=0+"px";this.inner_border.style.left=3+"px";this.inner_border.style.top=3+"px";if(this.photo.isEditStatus&&this.dashedMode){this.photo.positionDimmers(this)}},setEvents:function(){this.rectangle.onmouseover=this.onmouseover.bindAsEventListener(this);this.rectangle.onmouseout=this.onmouseout.bindAsEventListener(this);if(!this.person.canEdit){return}this.rectangle.onclick=this.onclick.bindAsEventListener(this)},unSetEvents:function(){this.rectangle.onmouseover=null;this.rectangle.onmouseout=null},show:function(f,e){if(this.dashedMode){return}if(this.isDisplayRectangleNone){return}if(this.rectangle.style.display=="block"){if(e){if(this.middle_border.hasClassName("green_border")){return}}else{if(!this.middle_border.hasClassName("green_border")){return}}}this.rectangle.addClassName("solid_border");if(e){this.addGreenClasses()}else{this.removeGreenClasses()}if(f&&!this.isFaden){this.rectangle.setOpacity(0.01);this.rectangle.style.display="block";this.middle_border.style.display="block";this.inner_border.style.display="block";this.inner_border.setOpacity(0.99);this.middle_border.setOpacity(0.99);var a=0;var d=8;var c=(Prototype.Browser.IE?100:10);var b=function(){this.rectangle.setOpacity(a/100);a+=c;if(a>=100){clearInterval(this.fadeTimerID);this.fadeTimerID=null;this.isFaden=true;this.rectangle.setOpacity(1);this.inner_border.setOpacity(1);this.middle_border.setOpacity(1)}}.bind(this);if(this.fadeTimerID!=null){clearInterval(this.fadeTimerID)}this.fadeTimerID=setInterval(b,d)}},hide:function(a){if(this.isDisplayRectangleNone){return}if(this.fadeTimerID!=null){clearInterval(this.fadeTimerID);this.rectangle.setOpacity(1);this.inner_border.setOpacity(1);this.middle_border.setOpacity(1);this.fadeTimerID=null}this.rectangle.removeClassName("solid_border");this.removeGreenClasses();this.rectangle.style.display="";this.isFaden=a;this.tooltip.hide()},onmouseover:function(b){if(this.dashedMode){return}var a=Event.element(b);Event.stop(b);if(a!=this.rectangle_area){return}if(this.photo.highlightedPerson!=null&&this.photo.highlightedPerson!=this.person){this.photo.highlightedPerson.mark.removeGreenSelection(this.photo.highlightedPerson.mark.middle_border)}this.person.selectPersonByRectangle();this.addGreenClasses();setTimeout(function(){if(this.middle_border.hasClassName("green_border")){this.tooltip.show(this.person.isIdentified()?this.person.name:clickToIdentifyThisPerson,this)}else{this.tooltip.hide()}}.bind(this),10);this.rectangle.style.zIndex=2001},onmouseout:function(b){var a=Event.element(b);this.removeGreenSelection(a)},removeGreenSelection:function(a){if(a!=this.middle_border){return}this.person.deselectPersonByRectangle();this.tooltip.hide();this.removeGreenClasses();this.rectangle.style.zIndex=105},addGreenClasses:function(){this.middle_border.addClassName("green_border");this.inner_border.addClassName("frame_around_green");this.rectangle.addClassName("frame_around_green")},removeGreenClasses:function(){this.middle_border.removeClassName("green_border");this.inner_border.removeClassName("frame_around_green");this.rectangle.removeClassName("frame_around_green")},onclick:function(){this.edited=true;this.tooltip.hide();if(this.photo.isStopMoving&&this.photo.isEditStatus){this.photo.isStopMoving=false;return}this.photo.photoManager.closeOtherDialogs();this.setMarks();this.setMode()},setMarks:function(){this.photo.isEditStatus?this.photo.selectAllMarks():this.photo.deselectAllMarks()},setMode:function(){if(this.photo.isEditStatus){this.hideDashed();this.photo.currentPerson=null;this.rectangle.onclick=this.onclick.bindAsEventListener(this)}else{this.showDashed();this.photo.currentPerson=this.person;this._onSelectedRectangle();this.rectangle.onclick=null}this.photo.isEditStatus=!this.photo.isEditStatus;this.person.changeColor()},_onSelectedRectangle:function(){var b=this.photo.photoManager.dialog_container;var a=this.photo.currentPerson;if(this.photo.isAddingPersonMode){a=null}this.photo.photoManager.dialog_manager.showDialog(a);b.parentNode.removeChild(b);this.connector.appendChild(b)},_onDeselectedRectangle:function(){this.photo.photoManager.dialog_manager.showDialog(this.photo.currentPerson)},showDashed:function(){this.showEditBorder();this.showCorners();this.photo.dimPhoto(this);Element.addClassName(this.rectangle,"diplay_block");this.middle_border.style.display="none";this.inner_border.style.display="none";this.dashedMode=true},hideDashed:function(){this.hideEditBorder();this.hideCorners();this.photo.undimPhoto();Element.removeClassName(this.rectangle,"diplay_block");this.dashedMode=false},remove:function(){if(this.photo.isRealPhoto()){this.container.removeChild(this.rectangle)}else{this.container.removeChild(this.connector)}if(this.photo.isEditStatus){this.photo.undimPhoto()}}};var CornerBounder=function(){};CornerBounder.prototype={LEFT_BOTTOM_CORNER:"left_bottom",RIGHT_BOTTOM_CORNER:"right_bottom",LEFT_TOP_CORNER:"left_top",RIGHT_TOP_CORNER:"right_top",initialize:function(a,b){this.rectangle=a;this.photo=a.photo;this.container=this.rectangle.rectangle;this.photoContainer=this.photo.photoContainer;this.mouseDown=false;this.stat=b},initCorner:function(a,b){switch(b){case this.LEFT_BOTTOM_CORNER:return new LeftBottomCorner(a,b);case this.RIGHT_BOTTOM_CORNER:return new RightBottomCorner(a,b);case this.LEFT_TOP_CORNER:return new LeftTopCorner(a,b);case this.RIGHT_TOP_CORNER:return new RightTopCorner(a,b)}},render:function(){var a="corner "+this.stat;this.corner=Tools.createDiv(a);this.corner.style.width="11px";this.corner.style.height="11px";this.container.appendChild(this.corner);this.setPosition();this.setEvents()},setEvents:function(){this.corner.onmousedown=this.mouseBtnDown.bindAsEventListener(this);this.photoContainer.onmouseup=this.mouseBtnUp.bindAsEventListener(this);this.photoContainer.onselectstart=this.preventHandler.bindAsEventListener(this)},mouseBtnDown:function(a){this.rectangle.currentCorner=this;this.mouseDown=true;this.x=a.clientX;this.y=a.clientY;if(this.photo.isEditStatus){this.photoContainer.onmousemove=this.mouseMove.bindAsEventListener(this)}},mouseUp:function(){this.mouseDown=false;this.photo.isStopMoving=true},mouseBtnUp:function(){this.mouseDown=false;this.photo.isStopMoving=true;this.photoContainer.onmousemove=null},outOfBounds:function(a){return !this.mouseDown},stopMouseMoveEvent:function(){this.photoContainer.onmousemove=null},preventHandler:function(a){if(this.photoContainer.select){this.photoContainer.select=false;return}if(a.preventDefault){a.preventDefault()}else{a.returnValue=false}},mouseMove:function(a){this.dx=this.x-a.clientX;this.dy=this.y-a.clientY;this.x=a.clientX;this.y=a.clientY;if(this.isHorisontalOutOfBounds||this.isVerticalOutOfBounds){this.moveLeft()}this.moveTop();if(this.rectangle.x<0){this.rectangle.x=0}if(this.rectangle.y<0){this.rectangle.y=0}this.updatePositions()},updatePositions:function(){this.rectangle.initPositions()},isHorisontalOutOfBounds:function(){var b=this.rectangle.x-this.dx;var a=b<0;var c=b+this.rectangle.w>this.photoWidth-4;return a||c},isVerticalOutOfBounds:function(){var c=this.rectangle.y-this.dy;var b=c<0;var a=c+this.rectangle.h>this.photoHeight-4;return b||a}};var LeftBottomCorner=Class.create();LeftBottomCorner.prototype=Object.extend(new CornerBounder(),{setPosition:function(){this.corner.style.left="0px";this.corner.style.bottom="0px"},moveLeft:function(){this.rectangle.w+=this.dx;if(this.rectangle.w<25){this.rectangle.w=25;return}this.rectangle.x-=this.dx},moveTop:function(){this.rectangle.h-=this.dy;if(this.rectangle.h<25){this.rectangle.h=25}}});var LeftTopCorner=Class.create();LeftTopCorner.prototype=Object.extend(new CornerBounder(),{setPosition:function(){this.corner.style.left="0px";this.corner.style.top="0px"},moveLeft:function(){this.rectangle.w+=this.dx;if(this.rectangle.w<25){this.rectangle.w=25;return}this.rectangle.x-=this.dx},moveTop:function(){this.rectangle.h+=this.dy;if(this.rectangle.h<25){this.rectangle.h=25;return}this.rectangle.y-=this.dy}});var RightBottomCorner=Class.create();RightBottomCorner.prototype=Object.extend(new CornerBounder(),{setPosition:function(){this.corner.style.right="0px";this.corner.style.bottom="0px"},moveLeft:function(){this.rectangle.w-=this.dx;if(this.rectangle.w<25){this.rectangle.w=25}},moveTop:function(){this.rectangle.h-=this.dy;if(this.rectangle.h<25){this.rectangle.h=25}}});var RightTopCorner=Class.create();RightTopCorner.prototype=Object.extend(new CornerBounder(),{setPosition:function(){this.corner.style.right="0px";this.corner.style.top="0px"},moveLeft:function(){this.rectangle.w-=this.dx;if(this.rectangle.w<25){this.rectangle.w=25}},moveTop:function(){this.rectangle.h+=this.dy;if(this.rectangle.h<25){this.rectangle.h=25;return}this.rectangle.y-=this.dy}});var RectangleActionManager=Class.create();RectangleActionManager.prototype={initialize:function(a){this.rectangleObject=a;this.photo=a.photo;this.photoContainer=this.rectangleObject.photo.photoContainer;this.mouseDown=false;this.setEvents()},setEvents:function(){this.rectangleObject.rectangle_area.onmousedown=this.mouseBtnDown.bindAsEventListener(this);this.rectangleObject.rectangle_area.onmouseup=this.mouseUp.bindAsEventListener(this)},mouseBtnDown:function(a){var b=Event.element(a);if(b.className.indexOf("corner")!=-1){return}Event.stop(a);this.mouseDown=true;Element.addClassName(this.rectangleObject.rectangle,"moved");this.x=a.clientX;this.y=a.clientY;if(this.photo.isEditStatus){this.photoContainer.onmousemove=this.mouseMove.bindAsEventListener(this)}},mouseUp:function(){this.mouseDown=false;Element.removeClassName(this.rectangleObject.rectangle,"moved");this.photo.isStopMoving=true},updatePositions:function(){this.rectangleObject.updatePositions()},outOfBounds:function(a){return !this.mouseDown},stopMouseMoveEvent:function(){this.photoContainer.onmousemove=null},mouseMove:function(a){if(this.photo.isOutContainer&&this.photo.eventListener.isUnpress){return}if(this.outOfBounds(a)){this.stopMouseMoveEvent();return}this.dx=this.x-a.clientX;this.dy=this.y-a.clientY;this.x=a.clientX;this.y=a.clientY;this.moveLeft();this.moveTop();this.updatePositions()},moveLeft:function(){if(this.isHorisontalOutOfBounds()){return}this.rectangleObject.x-=this.dx},isHorisontalOutOfBounds:function(){this.photoWidth=this.photo.photoImg.width;var b=this.rectangleObject.x-this.dx;var a=b<0;var c=b+this.rectangleObject.w>this.photoWidth-4;return a||c},isVerticalOutOfBounds:function(){this.photoHeight=this.photo.photoImg.height;var c=this.rectangleObject.y-this.dy;var b=c<0;var a=c+this.rectangleObject.h>this.photoHeight-4;return b||a},moveTop:function(){if(this.isVerticalOutOfBounds()){return}this.rectangleObject.y-=this.dy}};var EventListener=Class.create();EventListener.prototype={initialize:function(){this.leftMouseKeyDown=false;this.main_container=window;if(Prototype.Browser.IE){this.main_container=document.body}Event.observe(this.main_container,"mousedown",this.main_container_onmousedown=this.onmousedown.bindAsEventListener(this));Event.observe(this.main_container,"mouseup",this.main_container_onmouseup=this.onmouseup.bindAsEventListener(this))},undoListening:function(){Event.stopObserving(this.main_container,"mousedown",this.main_container_onmousedown);Event.stopObserving(this.main_container,"mouseup",this.main_container_onmouseup)},onmousedown:function(){this.leftMouseKeyDown=true},onmouseup:function(){this.leftMouseKeyDown=false;this.isUnpress=true},setUnpress:function(){this.isUnpress=false},onmousemove:function(f){var c=f.clientX<=10;var b=f.clientY<=10;var d=f.clientX>document.width-10;var a=f.clientY>window.innerHeight-5;var g=c||b||d||a;if(g){this.isUnpress=true}}};var Serializer=Class.create();Serializer.prototype={initialize:function(b,a){this.photo=b;this.photoID=this.photo.pid;this.pathToScript=URL_TO_AJAX_CONTROLLER;this.saveIndividuals=a;this.ratio=this.photo.ratio},createXML:function(){var b=this.photo.json;if(!this.photo.photoManager.ftbSource){b.title=$F("titleEdit");b.date=$F("dateEdit");b.place=$F("placeEdit");b.notes=$F("notesEdit")}var a='<?xml version="1.0" encoding="UTF-8"?>';a+='<photo pid="'+this.photoID+'">';a+=b.title!=""?this.getCDATATag("title",b.title):"";a+=b.date!=""?this.getCDATATag("date",b.date):"";a+=b.place!=""?this.getCDATATag("place",b.place):"";a+=b.notes!=""?this.getCDATATag("note",b.notes):"";a+=this.getISODateXML(b.date);a+=this.getKeywordsXML($F("keywordsEdit"));if(this.saveIndividuals){a+=this.getIndividualsXML(this.photo.persons)}a+="</photo>";return a},getIndividualsXML:function(c){var a='<individuals n="'+c.length+'">';for(var b=0;b<c.length;b++){a+=this.getIndividualTag(c[b])}a+="</individuals>";return a},getIndividualTag:function(h){var b="";var e="</individual>";var g=h.json;var c,a,d,f;if(h.mark.edited==false){c=g.x;a=g.y;d=g.w;f=g.h}else{c=Math.round(h.mark.x/this.ratio);a=Math.round(h.mark.y/this.ratio);d=Math.round(h.mark.w/this.ratio);f=Math.round(h.mark.h/this.ratio)}b='<individual autoDetect="no" x="'+c+'" y="'+a+'" w="'+d+'" h="'+f+'" source="'+(g.source?g.source:TAG_SOURCE_WEB)+'" id="'+(h.isIdentified()?h.id:"")+'">';if(h.isNew){b+=this.getCDATATag("firstName",g.firstName);b+=this.getCDATATag("lastName",g.lastName);b+=this.getTag("gender",g.gender);b+=this.getTag("isAlive",g.isAlive);b+=this.getCDATATag("birthDate",g.birthDate);b+=this.getCDATATag("email",g.email);b+=this.getTag("externalPerson",g.personType);b+=this.getCDATATag("externalPersonDescription",g.decribeThisPerson)}return b+e},getISODateXML:function(a){if(a==""){return""}var b=Date.parseFormattedString(a);var c=b.getFullYear()+"-"+(b.getMonth()+1).toPaddedString(2)+"-"+b.getDate().toPaddedString(2)+"T00:00:00Z";return this.getCDATATag("isodate",c)},getKeywordsXML:function(d){if(d==""){return""}var c=d.split(", ");var a='<keywords n="'+c.length+'">';for(var b=0;b<c.length;b++){a+=this.getCDATATag("keyword",c[b])}a+="</keywords>";return a},getTag:function(a,b){return"<"+a+">"+b+"</"+a+">"},getCDATATag:function(a,b){return this.getTag(a,"<![CDATA["+b+"]]>")},saveXML:function(d,a,b){if(typeof b=="undefined"){anyTaggingDone=true}else{if(b==SCENARIO_VIEWPHOTO_EDIT_TITLE){anyPhotoEditDone=true}}this.saveCallback=d;this.errorCallback=a;var c="?act=save&siteID="+siteID;c+="&memberID="+currentUserAccountID;c+="&photoID="+this.photoID;if(typeof familyTreeID!="undefined"){c+="&familyTreeID="+familyTreeID}if(typeof b!="undefined"){c+="&scenario="+encodeURIComponent(b)}c+="&xml="+Base64.encode(this.createXML());new Ajax.Request(this.pathToScript,{method:"post",parameters:c,onComplete:this.onResponse.bindAsEventListener(this),onFailure:this.onFailure.bindAsEventListener(this),onException:this.onException.bind(this)})},onResponse:function(a){if(a.responseText=="Error"){if(this.errorCallback){this.errorCallback();return}}this.saveCallback(a.responseXML)},onFailure:function(a){alert(errorOccurred);if(this.errorCallback){this.errorCallback()}},onException:function(a,b){alert(errorOccurred);if(this.errorCallback){this.errorCallback()}}};var ExistingKeywordManager=Class.create();ExistingKeywordManager.prototype={initialize:function(){this.keywordInput=$("keywordsEdit");this.arrayOfKeywordsNames=$A();this.keywordContainer=$("keywordsList");if(this.keywordContainer!=null){this.keywordContainer.onclick=this.keywordClick.bindAsEventListener(this);this.arrayOfKeywords=$A(this.keywordContainer.getElementsByTagName("a"));for(var a=0;a<this.arrayOfKeywords.length;a++){this.arrayOfKeywordsNames[a]=this.arrayOfKeywords[a].innerHTML.unescapeHTML().toLowerCase()}this.keywordInput.onkeyup=this.highlightKeywords.bindAsEventListener(this);this.highlightKeywords()}},highlightKeywords:function(){var f=this.keywordInput.value.strip();var c=$A(f.toLowerCase().split(/\s*,\s*/));for(var e=0;e<this.arrayOfKeywordsNames.length;e++){var b=this.arrayOfKeywordsNames[e];var d=this.arrayOfKeywords[e];if(c.indexOf(b)!=-1){Element.addClassName(d,"keyword_selected")}else{Element.removeClassName(d,"keyword_selected")}}},keywordClick:function(b){var a=Event.element(b);if(a.tagName!="A"){return}this.addKeywordToInput(a.innerHTML.unescapeHTML());this.highlightKeywords()},addKeywordToInput:function(a){this.keywordInput.value+=this.getProperKeyword(a)},getProperKeyword:function(b){var c=this.keywordInput.value.strip();if(c==""){return b}var a=$A(c.split(/\s*,\s*/));if(a.indexOf(b)!=-1){return""}return", "+b}};var Tooltip=Class.create();Tooltip.prototype={initialize:function(a){this.container=a;this.render()},render:function(){this.tooltipDiv=Tools.createDiv("tooltip","tooltip");this.container.appendChild(this.tooltipDiv)},show:function(b,a){this.tooltipDiv.innerHTML=b;this.tooltipDiv.style.display="block";this.tooltipDiv.style.top=(a.y+a.h+6)+"px";this.tooltipDiv.style.left=Math.max(a.x+(a.w-this.tooltipDiv.offsetWidth)/2+3,0)+"px"},hide:function(){this.tooltipDiv.style.display="none"}};
