function Annotation(){this.mContainer;this.mAnnotation;this.mAnnotationReadOnlyContainer;this.mManager;this.mMediaId;this.mAnnotationId;this.mColor;this.mGroupId;this.mMediaGroups;this.mUserId;this.mCurrentPosX;this.mCurrentPosY;this.mReferencePosX;this.mReferencePosY;this.mReferenceImageSize=$(new Array());this.mPanelPosX;this.mPanelPosY;this.mHidden=true;this.mMenuHidden=$(new Array());this.mGroupChanged=false;this.mReadOnly=true;this.mAnnotationChanged=false;this.CLASSNAME="annotation";this.PRIVATE_ANNOTATION=-1;this.COLLECTION_ANNOTATION=0;this.DEFAULT_X_POSITION=0;this.DEFAULT_Y_POSITION=0;this.DEFAULT_TEXT="";this.DEFAULT_WIDTH=300;this.DEFAULT_HEIGHT=200;this.EDIT_ANNOTATION_TEXT="Edit annotation";this.DELETE_ANNOTATION_TEXT="Delete annotation";this.SELECT_ANNOTATION_ACCESS_TEXT="Select annotation access";this.SELECT_ANNOTATION_COLOR_TEXT="Select annotation color";this.SAVE_ANNOTATION_TEXT="Save annotation";this.mColorMenu=new Object();this.mColorMenu.Blue="0591FC";this.mColorMenu["Lime Green"]="7DC622";this.mColorMenu.Orange="FFBC37";this.mColorMenu.Yellow="FFF400";this.mColorMenu.Red="FE0001";this.mColorMenu.Turquoise="01FFFF";this.mColorMenu.Mauve="9596C6";this.mColorMenu.Tan="C9A46F";this.mColorMenu.Olive="A8A502";this.mColorMenu["Light Blue"]="9FCFF3";this.mColorMenu.Magenta="FF00FE";this.COLOR_MENU_INDEX=0;this.GROUP_MENU_INDEX=1;this.NO_MENU_INDEX=-1;this.ANNOTATION_MARKER_CLASSNAME="annotationMarker";this.ANNOTATION_EDITABLE_CONTAINER_CLASSNAME="annotationEditableContainer";this.ANNOTATION_READ_ONLY_CONTAINER_CLASSNAME="annotationReadOnlyContainer";this.ANNOTATION_CONTROLS_CONTAINER_CLASSNAME="annotationControlsContainer";this.ANNOTATION_EXPANDED_CONTAINER_CLASSNAME="annotationExpandedContainer";this.ANNOTATION_MESSAGE_CONTAINER_CLASSNAME="annotationMessageContainer";this.ANNOTATION_CLOSE_BUTTON_CLASSNAME="annotationCloseButton";this.ANNOTATION_EDIT_BUTTON_CLASSNAME="annotationEditButton";this.ANNOTATION_GROUP_BUTTON_CLASSNAME="annotationGroupButton";this.ANNOTATION_DELETE_BUTTON_CLASSNAME="annotationDeleteButton";this.ANNOTATION_COLOR_BUTTON_CLASSNAME="annotationColorButton";this.ANNOTATION_SUBMIT_BUTTON_CLASSNAME="annotationSubmitButton";this.ANNOTATION_GROUP_LIST_CLASSNAME="annotationGroupList";this.ANNOTATION_COLOR_LIST_CLASSNAME="annotationColorList";this.ANNOTATION_COLOR_MENU_ID="AnnotationColorMenu";this.ANNOTATION_ID="Annotation";this.SUMMARY_CLASSNAME="annotationContainer";this.CLASSNAME_RIGHT_POINTER="rightPointer";this.CLASSNAME_LEFT_POINTER="leftPointer";this.mFunctionEditAnnotation;this.mFunctionRemoveAnnotation;this.mGroupId=this.PRIVATE_ANNOTATION;this.init=function(){this.mMenuHidden[this.COLOR_MENU_INDEX]=true;this.mMenuHidden[this.GROUP_MENU_INDEX]=true;this.mAnnotation=$(document.createElement("div"));this.mAnnotationMarker=$(document.createElement("div"));this.mAnnotationExpandedContainer=$(document.createElement("div"));this.mAnnotationReadOnlyContainer=$(document.createElement("div"));this.mAnnotationReadOnlyText=$(document.createElement("p"));this.mAnnotationEditableContainer=$(document.createElement("div"));this.mAnnotationControlsContainer=$(document.createElement("div"));this.mAnnotationGroupsContainer=$(document.createElement("div"));this.mAnnotationColorsContainer=$(document.createElement("div"));this.mAnnotationMessageContainer=$(document.createElement("div"));this.mAnnotationInput=$(document.createElement("textArea"));this.mAnnotationButtonEdit=$(document.createElement("a"));this.mAnnotationButtonSubmit=$(document.createElement("a"));this.mAnnotationButtonClose=$(document.createElement("a"));this.mAnnotationButtonDelete=$(document.createElement("a"));this.mAnnotationButtonGroup=$(document.createElement("a"));this.mAnnotationButtonColor=$(document.createElement("a"));this.mAnnotationIconEdit=$(document.createElement("img"));this.mAnnotationIconSubmit=$(document.createElement("img"));this.mAnnotationIconClose=$(document.createElement("img"));this.mAnnotationIconDelete=$(document.createElement("img"));this.mAnnotationIconGroup=$(document.createElement("img"));this.mAnnotationIconColor=$(document.createElement("img"));this.mAnnotationIconEdit.src="/luna/images/default/icon-edit.gif";this.mAnnotationIconSubmit.src="/luna/images/default/icon-save2.gif";this.mAnnotationIconClose.src="/luna/images/default/icon-close.gif";this.mAnnotationIconDelete.src="/luna/images/default/tree/icon-delete.gif";this.mAnnotationIconGroup.src="/luna/images/default/icon-edit-pref.gif";this.mAnnotationIconColor.src="/luna/images/default/icon-edit-color.gif";this.mAnnotationIconEdit.alt=this.EDIT_ANNOTATION_TEXT;this.mAnnotationIconSubmit.alt=this.SAVE_ANNOTATION_TEXT;this.mAnnotationIconDelete.alt=this.DELETE_ANNOTATION_TEXT;this.mAnnotationIconGroup.alt=this.SELECT_ANNOTATION_ACCESS_TEXT;this.mAnnotationIconColor.alt=this.SELECT_ANNOTATION_COLOR_TEXT;this.mAnnotationIconEdit.title=this.EDIT_ANNOTATION_TEXT;this.mAnnotationIconSubmit.title=this.SAVE_ANNOTATION_TEXT;this.mAnnotationIconDelete.title=this.DELETE_ANNOTATION_TEXT;this.mAnnotationIconGroup.title=this.SELECT_ANNOTATION_ACCESS_TEXT;this.mAnnotationIconColor.title=this.SELECT_ANNOTATION_COLOR_TEXT;this.mAnnotation.addClassName(this.SUMMARY_CLASSNAME);this.mAnnotationButtonSubmit.addClassName(this.ANNOTATION_SUBMIT_BUTTON_CLASSNAME);this.mAnnotationButtonEdit.addClassName(this.ANNOTATION_EDIT_BUTTON_CLASSNAME);this.mAnnotationButtonClose.addClassName(this.ANNOTATION_CLOSE_BUTTON_CLASSNAME);this.mAnnotationButtonDelete.addClassName(this.ANNOTATION_DELETE_BUTTON_CLASSNAME);this.mAnnotationButtonGroup.addClassName(this.ANNOTATION_GROUP_BUTTON_CLASSNAME);this.mAnnotationButtonColor.addClassName(this.ANNOTATION_COLOR_BUTTON_CLASSNAME);this.mAnnotationMarker.addClassName(this.ANNOTATION_MARKER_CLASSNAME);this.mAnnotationEditableContainer.addClassName(this.ANNOTATION_EDITABLE_CONTAINER_CLASSNAME);this.mAnnotationReadOnlyContainer.addClassName(this.ANNOTATION_READ_ONLY_CONTAINER_CLASSNAME);this.mAnnotationControlsContainer.addClassName(this.ANNOTATION_CONTROLS_CONTAINER_CLASSNAME);this.mAnnotationExpandedContainer.addClassName(this.ANNOTATION_EXPANDED_CONTAINER_CLASSNAME);this.mAnnotationMessageContainer.addClassName(this.ANNOTATION_MESSAGE_CONTAINER_CLASSNAME);this.mAnnotationButtonEdit.appendChild(this.mAnnotationIconEdit);this.mAnnotationButtonSubmit.appendChild(this.mAnnotationIconSubmit);this.mAnnotationButtonClose.appendChild(this.mAnnotationIconClose);this.mAnnotationButtonDelete.appendChild(this.mAnnotationIconDelete);this.mAnnotationButtonGroup.appendChild(this.mAnnotationIconGroup);this.mAnnotationButtonColor.appendChild(this.mAnnotationIconColor);this.mAnnotationEditableContainer.appendChild(this.mAnnotationInput);this.mAnnotationControlsContainer.appendChild(this.mAnnotationButtonEdit);this.mAnnotationControlsContainer.appendChild(this.mAnnotationButtonEdit);this.mAnnotationControlsContainer.appendChild(this.mAnnotationButtonDelete);this.mAnnotationGroupsContainer.appendChild(this.mAnnotationButtonGroup);this.mAnnotationColorsContainer.appendChild(this.mAnnotationButtonColor);this.mAnnotationControlsContainer.appendChild(this.mAnnotationGroupsContainer);this.mAnnotationControlsContainer.appendChild(this.mAnnotationColorsContainer);this.mAnnotationControlsContainer.appendChild(this.mAnnotationButtonSubmit);this.mAnnotationControlsContainer.appendChild(this.mAnnotationButtonClose);this.mAnnotationReadOnlyContainer.appendChild(this.mAnnotationReadOnlyText);this.mAnnotationExpandedContainer.appendChild(this.mAnnotationControlsContainer);this.mAnnotationExpandedContainer.appendChild(this.mAnnotationReadOnlyContainer);this.mAnnotationExpandedContainer.appendChild(this.mAnnotationEditableContainer);this.mAnnotationExpandedContainer.appendChild(this.mAnnotationMessageContainer);this.mAnnotation.appendChild(this.mAnnotationMarker);this.mAnnotation.appendChild(this.mAnnotationExpandedContainer);this.mContainer.appendChild(this.mAnnotation);this.mAnnotation.annotation=this;this.mAnnotation.id=this.ANNOTATION_ID;this.mAnnotation.style.position="absolute";this.mAnnotation.style.top=this.DEFAULT_X_POSITION+"px";this.mAnnotation.style.left=this.DEFAULT_Y_POSITION+"px";this.mAnnotation.style.zIndex=1;this.mAnnotation.style.display="block";this.mAnnotationReadOnlyText.style.margin="10px";this.mAnnotationMessageContainer.hide();this.mAnnotationExpandedContainer.style.display="none";this.mAnnotationExpandedContainer.style.width=this.DEFAULT_WIDTH+"px";this.mAnnotationEditableContainer.style.display="none";this.mAnnotationControlsContainer.style.display="none";this.mAnnotationControlsContainer.style.backgroundColor="#EEEEEE";this.mAnnotationInput.value=this.DEFAULT_TEXT;this.setColor();var A=this;this.mAnnotationInput.onblur=function(){A.setbg("white")};this.mAnnotationInput.onkeyup=function(){A.mAnnotationChanged=true};this.mAnnotationButtonSubmit.onclick=function(){A.save()};this.mAnnotationButtonDelete.onclick=function(){A.deleteAnnotation(A.mAnnotationId)};this.mAnnotationButtonGroup.onmouseover=function(){if(!A.mAnnotationMessageContainer.visible()){A.renderMenu(A.GROUP_MENU_INDEX)}};this.mAnnotationButtonColor.onmouseover=function(){if(!A.mAnnotationMessageContainer.visible()){A.renderMenu(A.COLOR_MENU_INDEX)}};this.mAnnotationMarker.onclick=function(B){if(A.mHidden==true){A.renderMenu(A.NO_MENU_INDEX);A.showAnnotationInfo();A.mHidden=false}else{A.hideAnnotationInfo();A.mHidden=true;A.renderMenu(A.NO_MENU_INDEX)}YAHOO.util.Event.removeListener(A.mAnnotation,"mouseout",Static_Annotation_Container_MouseOut)};this.mAnnotationInput.onfocus=function(){A.setbg("#EEEEEE")};this.mAnnotationButtonClose.onclick=function(){if((A.mAnnotationId==undefined)||A.mAnnotationChanged){A.showConfirmationContainer("You are about to close this annotation without saving any changes.");A.hideAnnotationEditable();A.updateExpandedContainer()}else{A.hideAnnotationInfo();A.mHidden=true;A.renderMenu(A.NO_MENU_INDEX);YAHOO.util.Event.removeListener(A.mAnnotation,"mouseout",Static_Annotation_Container_MouseOut)}};this.mAnnotationButtonEdit.onclick=function(){A.hideAnnotationReadOnly();A.showAnnotationEditable();A.showAnnotationButtons();A.renderMenu(A.NO_MENU_INDEX);YAHOO.util.Event.removeListener(A.mAnnotationControlsContainer,"mouseover",Static_Annotation_Controls_MouseOver);YAHOO.util.Event.removeListener(A.mAnnotationControlsContainer,"mouseout",Static_Annotation_Controls_MouseOut);YAHOO.util.Event.addListener(A.mAnnotation,"mouseout",Static_Annotation_Container_MouseOut)};if(this.mAnnotationId!=0&&this.mReadOnly==false){YAHOO.util.Event.addListener(this.mAnnotationReadOnlyContainer,"mouseover",Static_Annotation_ReadOnly_MouseOver);YAHOO.util.Event.addListener(this.mAnnotationReadOnlyContainer,"mouseout",Static_Annotation_ReadOnly_MouseOut);YAHOO.util.Event.addListener(this.mAnnotationControlsContainer,"mouseover",Static_Annotation_Controls_MouseOver);YAHOO.util.Event.addListener(this.mAnnotationControlsContainer,"mouseout",Static_Annotation_Controls_MouseOut)}YAHOO.util.Event.addListener(this.mAnnotationButtonDelete,"mouseover",Static_Annotation_Buttons_MouseOver);YAHOO.util.Event.addListener(this.mAnnotationButtonSubmit,"mouseover",Static_Annotation_Buttons_MouseOver);YAHOO.util.Event.addListener(this.mAnnotationButtonEdit,"mouseover",Static_Annotation_Buttons_MouseOver)};this.save=function(){if(!A){var A=this}if(!jshIsEmptyTrim(A.mAnnotationInput.value)){if(A.mAnnotationId==undefined){A.mAnnotationId=-9999}A.saveAnnotation(A.mAnnotationId,A.mMediaId,A.mReferencePosX,A.mReferencePosY,A.mReferenceImageSize[0],A.mReferenceImageSize[1],A.mAnnotationInput.value.stripScripts(),A.mGroupId,A.mColor);if(A.mGroupChanged&&A.mGroupId!=A.COLLECTION_ANNOTATION&&A.mGroupId!=A.PRIVATE_ANNOTATION){A.mManager.remove(A.mAnnotationId)}else{setTimeout(function(){A.hideAnnotationInfo()},1500);A.mHidden=true}A.mAnnotationChanged=false}};this.renderMenu=function(A){var C=false;for(var B=0;B<this.mMenuHidden.length;B++){if(B==A){if(this.mMenuHidden[B]==false){}else{this.mMenuHidden[B]=false;C=true}}else{this.mMenuHidden[B]=true}}this.updateGroupMenu();this.updateColorMenu();if(C){this.mAnnotationEditableContainer.hide()}};this.updateGroupMenu=function(){if(this.mMenuHidden[this.GROUP_MENU_INDEX]==false){var B=this.mAnnotationExpandedContainer.getElementsByClassName(this.ANNOTATION_GROUP_LIST_CLASSNAME);if(B.length<=0){var E=this.constructGroupInput();var G=$(document.createElement("div"));G.addClassName(this.ANNOTATION_GROUP_LIST_CLASSNAME);G.appendChild(E);this.mAnnotationExpandedContainer.appendChild(G)}}else{var D=this.mAnnotationExpandedContainer.getElementsByClassName(this.ANNOTATION_GROUP_LIST_CLASSNAME);if(D.length>0){var F=D[0].select("input");var A;for(var C=0;C<F.length;C++){if(F[C].checked){A=F[C].value;break}}this.mAnnotationExpandedContainer.removeChild(D[0]);if(A!=undefined&&this.mGroupId!=A){this.mGroupId=A;this.mGroupChanged=true}}}};this.updateColorMenu=function(){var A=this.mAnnotationExpandedContainer.getElementsByClassName(this.ANNOTATION_COLOR_LIST_CLASSNAME);if(A.length>0){this.mAnnotationExpandedContainer.removeChild(A[0])}if(this.mMenuHidden[this.COLOR_MENU_INDEX]==false){var B=this.constructColorInput();var C=$(document.createElement("div"));C.addClassName(this.ANNOTATION_COLOR_LIST_CLASSNAME);C.appendChild(B);this.mAnnotationExpandedContainer.appendChild(C)}};this.constructGroupInput=function(E){if(!E){E=$(document.createElement("form"))}E.style.overflowY="auto";E.style.maxHeight="200px";E.style.height="200px";E.style.minWidth="100px";E.style.margin="0";E.id="groupForm";for(var C=0;C<this.mMediaGroups.length;C++){var F=$(document.createElement("input"));F.type="radio";F.name="saveToMediaGroup";F.id="idmg_"+C;F.value=this.mMediaGroups[C].id;if(this.mGroupId&&this.mGroupId==this.mMediaGroups[C].id){F.checked=true}var G=" "+this.mMediaGroups[C].name;if(this.mMediaGroups[C].active=="true"){G+=" (Active Media Group)"}var B=document.createTextNode(G);var D=document.createElement("label");D.appendChild(B);if(C>0){var A=document.createElement("br");E.appendChild(A)}E.appendChild(F);E.appendChild(D);if(this.mGroupId>=0&&this.mGroupId==this.mMediaGroups[C].id){F.checked=true}}YAHOO.util.Event.addListener(E,"click",Static_Annotation_Group_Menu_Click);return E};this.constructColorInput=function(B){var E=$(document.createElement("div"));E.id=this.ANNOTATION_COLOR_MENU_ID;var D=$(document.createElement("ul"));D.id="item1";for(colorKey in this.mColorMenu){var A=$(document.createElement("li"));var C=document.createTextNode(colorKey);A.addClassName("item");A.appendChild(C);A.id=this.mColorMenu[colorKey];if(this.mColor&&this.mColor==this.mColorMenu[colorKey]){A.style.backgroundColor="#"+this.mColorMenu[colorKey]}YAHOO.util.Event.addListener(A,"mouseover",Static_Annotation_Color_Text_MouseOver);YAHOO.util.Event.addListener(A,"mouseout",Static_Annotation_Color_Text_MouseOut);YAHOO.util.Event.addListener(A,"click",Static_Annotation_Color_Text_Click);D.appendChild(A)}E.appendChild(D);return E};this.showMessageContainer=function(D){var I="";for(var E=0;E<this.mMediaGroups.length;E++){if(this.mMediaGroups[E].id==D){I=this.mMediaGroups[E].name}}this.hideAnnotationReadOnly();this.hideAnnotationButtons();this.renderMenu(this.NO_MENU_INDEX);if(this.mAnnotationMessageContainer.hasChildNodes()){while(this.mAnnotationMessageContainer.childNodes.length>=1){this.mAnnotationMessageContainer.removeChild(this.mAnnotationMessageContainer.firstChild)}}var C=$(document.createElement("p"));var F=$(document.createElement("button"));var H=$(document.createElement("button"));var G="You have selected to save this annotation to Media Group <b>"+I+"</b>. <br><br>If you did not open this image from that Media Group you will no longer see this annotation when you click save.<br><br>To view this annotation you must open it from <b>"+I+"</b>.";C.update(G);F.update("OK");H.update("Cancel");F.style.cssFloat="right";F.style.styleFloat="right";H.style.cssFloat="right";H.style.styleFloat="right";F.style.width="60px";H.style.width="60px";if(!A){var A=this}var B=A;F.onclick=function(){B.mGroupId=D;B.mGroupChanged=true;B.save()};H.onclick=function(){B.mAnnotationMessageContainer.hide();B.renderMenu(B.GROUP_MENU_INDEX);B.showAnnotationButtons();B.updateExpandedContainer()};this.mAnnotationMessageContainer.appendChild(C);this.mAnnotationMessageContainer.appendChild(H);this.mAnnotationMessageContainer.appendChild(F);this.mAnnotationMessageContainer.show()};this.showConfirmationContainer=function(B){this.hideAnnotationReadOnly();this.hideAnnotationButtons();this.renderMenu(this.NO_MENU_INDEX);if(this.mAnnotationMessageContainer.hasChildNodes()){while(this.mAnnotationMessageContainer.childNodes.length>=1){this.mAnnotationMessageContainer.removeChild(this.mAnnotationMessageContainer.firstChild)}}var G=$(document.createElement("p"));var F=$(document.createElement("button"));var C=$(document.createElement("button"));var E=B;F.style.cssFloat="right";F.style.styleFloat="right";C.style.cssFloat="right";C.style.styleFloat="right";F.style.width="70px";C.style.width="110px";G.update(E);F.update("Close");C.update("Save & Close");if(!D){var D=this}var A=D;F.onclick=function(){A.hideAnnotationInfo();A.mHidden=true;A.mAnnotationMessageContainer.hide()};C.onclick=function(){A.save();setTimeout(function(){A.mAnnotationMessageContainer.hide()},1500)};this.mAnnotationMessageContainer.appendChild(G);this.mAnnotationMessageContainer.appendChild(C);this.mAnnotationMessageContainer.appendChild(F);this.mAnnotationMessageContainer.show()};this.setManager=function(A){this.mManager=A};this.saveAnnotation=function(B,I,F,A,G,H,C,E,D){this.mFunctionEditAnnotation(B,I,F,A,G,H,C,E,D)};this.deleteAnnotation=function(A){this.mFunctionRemoveAnnotation(A,this.mMediaId)};this.setbg=function(A){this.mAnnotationInput.style.background=A};this.render=function(A){if(A){this.mContainer=A;this.init()}};this.setColor=function(){if(this.mColor){this.mAnnotationExpandedContainer.style.borderColor="#"+this.mColor}if(this.mColor){this.mAnnotationMarker.style.backgroundColor="#"+this.mColor}else{this.mAnnotationMarker.style.backgroundColor="orange"}};this.setReferenceImageSize=function(A,B){this.mReferenceImageSize[0]=A;this.mReferenceImageSize[1]=B};this.setReferencePosition=function(A,B){this.mReferencePosX=A;this.mReferencePosY=B};this.setCurrentPosition=function(A,B){this.mCurrentPosX=A;this.mCurrentPosY=B};this.setPanelPosition=function(A,B){this.mPanelPosX=A;this.mPanelPosY=B};this.setAnnotationInfo=function(A){this.mAnnotationReadOnlyText.update(A);this.mAnnotationInput.value=A};this.showAnnotationInfo=function(){this.mAnnotation.style.zIndex++;this.hideAnnotationButtons();this.mAnnotationReadOnlyText.show();this.mAnnotationEditableContainer.hide();this.mAnnotationExpandedContainer.show();this.updateExpandedContainer()};this.hideAnnotationInfo=function(){if(this.mAnnotationId==undefined){this.mManager.remove()}this.hideAnnotationExpanded();this.mAnnotation.style.zIndex--;YAHOO.util.Event.addListener(this.mAnnotationControlsContainer,"mouseover",Static_Annotation_Controls_MouseOver)};this.showAnnotationEditable=function(){this.mAnnotationReadOnlyText.hide();this.mAnnotationEditableContainer.show();this.updateExpandedContainer();this.mAnnotationInput.focus()};this.hideAnnotationReadOnly=function(){this.mAnnotationReadOnlyText.hide()};this.hideAnnotationEditable=function(){this.mAnnotationEditableContainer.hide()};this.hideAnnotationExpanded=function(){this.mAnnotationExpandedContainer.hide()};this.hideAnnotationButtons=function(){this.mAnnotationControlsContainer.hide();this.mAnnotationControlsContainer.style.zIndex=-1};this.showAnnotationButtons=function(){this.mAnnotationControlsContainer.show();this.mAnnotationControlsContainer.style.zIndex=5;this.mAnnotationButtonEdit.show();this.mAnnotationButtonSubmit.show();this.mAnnotationButtonClose.show();this.mAnnotationButtonDelete.show();this.mAnnotationButtonGroup.show();this.mAnnotationButtonColor.show()};this.showEditAndClose=function(){this.mAnnotationControlsContainer.show();this.mAnnotationControlsContainer.style.zIndex=5;this.mAnnotationButtonEdit.show();this.mAnnotationButtonClose.show();this.mAnnotationButtonDelete.hide();this.mAnnotationButtonGroup.hide();this.mAnnotationButtonColor.hide();this.mAnnotationButtonSubmit.hide()};this.updateMarker=function(){if((this.mPanelPosX!=NaN)&&(this.mPanelPosY!=NaN)){this.mAnnotation.style.left=this.mPanelPosX+"px";this.mAnnotation.style.top=this.mPanelPosY+"px"}};this.updateExpandedContainer=function(A){var B=this.mManager.mViewPortWidth;var G=this.mManager.mViewPortHeight;var F=this.mManager.mViewPortPosX;var E=this.mManager.mViewPortPosY;if(F+B-this.mPanelPosX<this.DEFAULT_WIDTH*0.9&&this.mPanelPosX-F>B/2){var D=(this.mAnnotationExpandedContainer.getWidth()-this.mAnnotationMarker.getWidth())*-1;this.mAnnotationExpandedContainer.style.left=D+"px"}else{this.mAnnotationExpandedContainer.style.left=""}var C=this.mAnnotationExpandedContainer.getHeight();if(E+G-this.mPanelPosY<C*0.9&&this.mPanelPosY-E>G/2){var H=(C)*-1;this.mAnnotationExpandedContainer.style.top=H+"px"}else{this.mAnnotationExpandedContainer.style.top=""}};this.calculateCurrentPosition=function(B,C,A,F,E,D){this.mCurrentPosX=Math.floor(this.mReferencePosX*(B/this.mReferenceImageSize[0]));this.mCurrentPosY=Math.floor(this.mReferencePosY*(C/this.mReferenceImageSize[1]));if(B>A){this.mPanelPosX=this.mCurrentPosX-this.xMin+E}else{this.mPanelPosX=this.mCurrentPosX+this.xMin+E}if(C>F){this.mPanelPosY=this.mCurrentPosY-this.yMin+D}else{this.mPanelPosY=this.mCurrentPosY+this.yMin+D}};this.calculateReferencePosition=function(A,B){this.mReferencePosX=Math.floor(this.mCurrentPosX*(this.mReferenceImageSize[0]/A));this.mReferencePosY=Math.floor(this.mCurrentPosY*(this.mReferenceImageSize[1]/B))};this.calculateTranslatedPosition=function(A,I,G,D,C,B,F,E){var H=$(new Array());if(A>G){H[0]=F+this.xMin-C}else{H[0]=F-this.xMin-C}if(I>D){H[1]=E+this.yMin-B}else{H[1]=E-this.yMin-B}this.mCurrentPosX=H[0];this.mCurrentPosY=H[1]};this.move=function(A,H,C,D,B,G,F,E){this.calculateOffsets(C,D,B,G,A,H);this.calculateCurrentPosition(C,D,B,G,F,E);if(!this.isWithinViewPort(B,G,F,E)){this.mAnnotation.style.display="none"}else{this.mAnnotation.style.display="block"}this.updateMarker();this.updateExpandedContainer()};this.isWithinViewPort=function(A,D,C,B){if((this.mPanelPosY>(B+D))||(this.mPanelPosY)<(B)||(this.mPanelPosX>(C+A))||(this.mPanelPosX)<(C)){return false}else{return true}};this.isOnImage=function(){if(this.mCurrentPosX<0||this.mCurrentPosY<0){return false}else{if(this.mCurrentPosX>this.mReferenceImageSize[0]||this.mCurrentPosY>this.mReferenceImageSize[1]){return false}else{return true}}};this.calculateOffsets=function(C,D,B,E,A,F){if(!A){A=B/2}if(!F){F=E/2}if(C>B){this.xMin=A-(B/2);this.xMax=A+(B/2)}else{this.xMin=A-(C/2);this.xMax=A+(C/2)}if(D>E){this.yMin=F-(E/2);this.yMax=F+(E/2)}else{this.yMin=F-(D/2);this.yMax=F+(D/2)}};this.setStackOrder=function(A){this.mAnnotation.style.zIndex=A};this.remove=function(){this.mContainer.removeChild(this.mAnnotation)};this.setFunctionEditAnnotation=function(A){this.mFunctionEditAnnotation=A};this.setFunctionRemoveAnnotation=function(A){this.mFunctionRemoveAnnotation=A}}function Static_Annotation_ReadOnly_MouseOver(D){var D=jshGetEvent(D);var A=jshGetSourceElement(D);var C=".annotationContainer";if(A.up(C).annotation){var B=A.up(C).annotation;if(B.mAnnotationReadOnlyText.visible()){B.showEditAndClose()}else{B.showAnnotationButtons()}B.updateExpandedContainer()}}function Static_Annotation_Controls_MouseOver(C){var C=jshGetEvent(C);var A=jshGetSourceElement(C);if(A.up(1).annotation){var B=A.up(1).annotation;if(B.mAnnotationReadOnlyText.visible()){B.showEditAndClose()}else{B.showAnnotationButtons()}}}function Static_Annotation_Controls_MouseOut(A){}function Static_Annotation_ReadOnly_MouseOut(C){var C=jshGetEvent(C);var A=jshGetSourceElement(C);if(A.up(2).annotation){var B=A.up(2).annotation;B.hideAnnotationButtons()}}function Static_Annotation_Group_Menu_Click(E){var E=jshGetEvent(E);var A=jshGetSourceElement(E);var D=".annotationContainer";var F=A.up().select("input");for(var B=0;B<F.length;B++){F[B].checked=false}if(A.up(D).annotation){var C=A.up(D).annotation;if(A.value>0&&C.mManager.mSourceMediaGroupId!=A.value){C.showMessageContainer(A.value);C.updateExpandedContainer()}else{A.checked=true;C.mGroupId=A.value;C.save()}}}function Static_Annotation_Color_Text_MouseOver(B){var B=jshGetEvent(B);var A=jshGetSourceElement(B);A.style.backgroundColor="#"+A.id}function Static_Annotation_Color_Text_MouseOut(D){var D=jshGetEvent(D);var A=jshGetSourceElement(D);var C=".annotationContainer";if(A&&A.up(C).annotation){var B=A.up(C).annotation;if(B.mColor&&B.mColor==B.mColorMenu[A.innerHTML]){}else{A.style.backgroundColor=""}}}function Static_Annotation_Color_Text_Click(D){var D=jshGetEvent(D);var A=jshGetSourceElement(D);var C=".annotationContainer";if(A.up(C).annotation){var B=A.up(C).annotation;if(A.id){B.mColor=A.id;B.renderMenu(B.COLOR_MENU_INDEX);B.save()}}}function Static_Annotation_Buttons_MouseOver(D){var D=jshGetEvent(D);var A=jshGetSourceElement(D);var C=".annotationContainer";if(A.up(C).annotation){var B=A.up(C).annotation;if(!B.mAnnotationMessageContainer.visible()){B.renderMenu(B.NO_MENU_INDEX);B.hideAnnotationReadOnly();B.showAnnotationEditable();B.showAnnotationButtons()}}}function Static_Annotation_Container_MouseOut(F){var C=F.relatedTarget;var F=jshGetEvent(F);var B=jshGetSourceElement(F);var E=".annotationContainer";var G=".annotationGroupList";var A=".annotationColorList";if(B.up(E).annotation){var D=B.up(E).annotation;if(B.descendantOf(C)){}else{if(C.up(G)&&C.descendantOf(C.up(G))){}else{if(C.up(A)&&C.descendantOf(C.up(A))){}else{if(!D.mAnnotationMessageContainer.visible()){D.hideAnnotationReadOnly();D.showAnnotationEditable();D.showAnnotationButtons();D.renderMenu(D.NO_MENU_INDEX)}}}}}};
