function AnnotationManager(C,I,G,H,A,B,F,E,D){this.mContainer=$(C);this.mAnnotations=$(new Array());this.mAnnotationManager=this;this.mCount=-1;this.mMediaGroups=E;this.mSourceMediaGroupId;this.mCurrentUserId=-1;this.mCollectionPermissions=D;this.mViewPortWidth;this.mViewPortHeight;this.mViewPortPosX;this.mViewPortPosY;this.mImagePanelStackOrder=0;this.fetch=AnnotationManager_Fetch;this.fetchCount=AnnotationManager_FetchCount;this.fetchSingle=AnnotationManager_FetchSingle;this.move=AnnotationManager_Move;this.setStackOrder=AnnotationManager_SetStackOrder;this.process=AnnotationManager_Process;this.processSingle=AnnotationManager_ProcessSingle;this.removeAll=AnnotationManager_RemoveAll;this.remove=AnnotationManager_Remove;this.add=AnnotationManager_Add;this.setNewAnnotationId=AnnotationManager_SetNewAnnotationId;this.setMediaGroups=AnnotationManager_SetMediaGroups;this.setSourceMediaGroupId=AnnotationManager_SetSourceMediaGroupId;this.setAnnotationCount=AnnotationManager_SetAnnotationCount;this.setCollectionPermissions=AnnotationManager_SetCollectionPermissions;this.mFunctionFetchAnnotations=I;this.mFunctionFetchLegacyAnnotations=B;this.mFunctionEditAnnotation=G;this.mFunctionFetchAnnotation=H;this.mFunctionRemoveAnnotation=A;this.mFunctionAnnotationCount=F;this.PRIVATE_ANNOTATION=-1;this.COLLECTION_ANNOTATION=0;this.DEFAULT_COLOR="0591FC";this.setFunctionEditAnnotation=function(J){this.mFunctionEditAnnotation=J};this.setFunctionRemoveAnnotation=function(J){this.mFunctionRemoveAnnotation=J}}function AnnotationManager_Fetch(A){if(this.mAnnotations&&this.mAnnotations.length>0){this.removeAll()}if((A)&&(this.mFunctionFetchAnnotations)){this.mFunctionFetchAnnotations(A,this.mSourceMediaGroupId)}if((A)&&(this.mFunctionFetchLegacyAnnotations)){this.mFunctionFetchLegacyAnnotations(A)}}function AnnotationManager_FetchCount(A){if((A)&&(this.mFunctionAnnotationCount)){this.mFunctionAnnotationCount(A,this.mSourceMediaGroupId)}}function AnnotationManager_FetchSingle(A){if((A)&&(this.mFunctionFetchAnnotation)){this.mFunctionFetchAnnotation(A)}}function AnnotationManager_Edit(A){if((A)&&(this.mFunctionEditAnnotations)){this.mFunctionEditAnnotations(A)}}function AnnotationManager_Remove(B){if((B)&&(this.mFunctionRemoveAnnotation)){for(var A=0;A<this.mAnnotations.length;A++){if(this.mAnnotations[A].mAnnotationId==B){this.mAnnotations[A].remove();this.mAnnotations.splice(A,1);return }}}else{if(B==null){this.mAnnotations[this.mAnnotations.length-1].remove();this.mAnnotations.pop()}}return }function AnnotationManager_Move(I,H,E,C,A,D,G,F){for(var B=0;B<this.mAnnotations.length;B++){this.mAnnotations[B].move(I,H,E,C,A,D,G,F)}this.mViewPortWidth=A;this.mViewPortHeight=D;this.mViewPortPosX=G;this.mViewPortPosY=F}function AnnotationManager_Add(D,Q,P,K,G,A,I,M,L,J,H,F,E,C){var B=new Annotation();B.mMediaId=F;if(E==null){B.mGroupId=this.PRIVATE_ANNOTATION}else{B.mGroupId=E}if(C==null){B.mColor=this.DEFAULT_COLOR}else{B.mColor=C}B.mMediaGroups=$(new Array());B.mReadOnly=false;B.mMediaId=B.mMediaId.toString();var O=B.mMediaId.substr(0,B.mMediaId.sub("~","$",2).indexOf("~"));if(O!=null&&this.mCollectionPermissions&&this.mCollectionPermissions[O]){var N=new Object();N.id=this.COLLECTION_ANNOTATION;N.name="Collection (Everyone can see it)";N.active="false";B.mMediaGroups.push(N)}var N=new Object();N.id=this.PRIVATE_ANNOTATION;N.name="Private (Only I can see it)";N.active="false";B.mMediaGroups.push(N);B.mMediaGroups=B.mMediaGroups.concat(this.mMediaGroups);B.setManager(D);B.setPanelPosition(J,H);B.setReferenceImageSize(K,G);B.setFunctionEditAnnotation(this.mFunctionEditAnnotation);B.setFunctionRemoveAnnotation(this.mFunctionRemoveAnnotation);B.calculateOffsets(K,G,A,I,Q,P);B.calculateTranslatedPosition(K,G,A,I,M,L,J,H);B.calculateReferencePosition(K,G);if(!B.isOnImage()){return 0}B.render(this.mContainer);B.updateMarker();B.updateExpandedContainer(true);B.setStackOrder(this.mImagePanelStackOrder);this.mAnnotations.push(B);B.showAnnotationInfo();B.showAnnotationButtons();B.showAnnotationEditable();YAHOO.util.Event.removeListener(B.mAnnotationControlsContainer,"mouseover",Static_Annotation_Controls_MouseOver);YAHOO.util.Event.removeListener(B.mAnnotationControlsContainer,"mouseout",Static_Annotation_Controls_MouseOut);return 1}function AnnotationManager_SetStackOrder(A){this.mImagePanelStackOrder=A;for(var B=0;B<this.mAnnotations.length;B++){if(this.mAnnotations[B].mHidden==false){this.mAnnotations[B].setStackOrder(A+1)}else{this.mAnnotations[B].setStackOrder(A)}}}function AnnotationManager_RemoveAll(){for(var A=this.mAnnotations.length-1;A>=0;A--){this.mAnnotations[A].remove();this.mAnnotations.pop()}}function AnnotationManager_Process(F){var C;if(this.mAnnotations.length){C=this.mAnnotations.length}else{C=0}for(var B=0+C,A=0;B<F.length+C;B++,A++){this.mAnnotations[B]=new Annotation();this.mAnnotations[B].setManager(this.mAnnotationManager);this.mAnnotations[B].setReferencePosition(F[A].XPos,F[A].YPos);this.mAnnotations[B].setReferenceImageSize(F[A].imgWidth,F[A].imgHeight);this.mAnnotations[B].setFunctionEditAnnotation(this.mFunctionEditAnnotation);this.mAnnotations[B].setFunctionRemoveAnnotation(this.mFunctionRemoveAnnotation);this.mAnnotations[B].mColor=F[A].color;this.mAnnotations[B].mAnnotationId=F[A].id;this.mAnnotations[B].mMediaId=F[A].mediaId;this.mAnnotations[B].mGroupId=F[A].mgid;this.mAnnotations[B].mUserId=F[A].userId;if(this.mAnnotations[B].mUserId==this.mCurrentUserId){this.mAnnotations[B].mReadOnly=false}this.mAnnotations[B].mMediaGroups=$(new Array());this.mAnnotations[B].mMediaId=this.mAnnotations[B].mMediaId.toString();var D=this.mAnnotations[B].mMediaId.substr(0,this.mAnnotations[B].mMediaId.sub("~","$",2).indexOf("~"));if(D!=null&&this.mCollectionPermissions&&this.mCollectionPermissions[D]){var E=new Object();E.id=this.COLLECTION_ANNOTATION;E.name="Collection (Everyone can see it)";E.active="false";this.mAnnotations[B].mMediaGroups.push(E)}var E=new Object();E.id=this.PRIVATE_ANNOTATION;E.name="Private (Only I can see it)";E.active="false";this.mAnnotations[B].mMediaGroups.push(E);this.mAnnotations[B].mMediaGroups=this.mAnnotations[B].mMediaGroups.concat(this.mMediaGroups);this.mAnnotations[B].render(this.mContainer);this.mAnnotations[B].setAnnotationInfo(F[A].annotation)}this.setStackOrder(this.mImagePanelStackOrder)}function AnnotationManager_ProcessSingle(B){for(var A=0;A<this.mAnnotations.length;A++){if(B.id==this.mAnnotations[A].mAnnotationId){this.mAnnotations[A].setAnnotationInfo(B.annotation);this.mAnnotations[A].mColor=B.color;this.mAnnotations[A].mGroupId=B.mgid;this.mAnnotations[A].setColor();return }}}function AnnotationManager_SetNewAnnotationId(B){for(var A=0;A<this.mAnnotations.length;A++){if((this.mAnnotations[A].mAnnotationId==-9999||this.mAnnotations[A].mAnnotationId==undefined)&&B.id){this.mAnnotations[A].mAnnotationId=B.id;return }}}function AnnotationManager_SetAnnotationCount(A){this.mCount=A.count}function AnnotationManager_SetMediaGroups(A){this.mMediaGroups=A}function AnnotationManager_SetSourceMediaGroupId(A){this.mSourceMediaGroupId=A}function AnnotationManager_SetCollectionPermissions(A){this.mCollectionPermissions=A};
