isGlobleCommondBegin=true;var maxTryAddnoteTime=5;var tryAddnoteTime=0;var reTryTime=1000;var isOperation=false;var parentPhoto=null;var currentUserName="";var IE5=(document.getElementById&&document.all)?true:false;var W3C=(document.getElementById)?true:false;var photoLeft=0;var photoTop=0;var photoRight=0;var photoBottom=0;var noteList;var currentObject=null;var dragapproved=false;var small_div=9;var noModing=true;var xoff,yoff;var stp_h=false;var stp_v=false;var minW=minH=15;var mdn=false;var currn,cpa,ccn;var rightout=bottomout=false;var mouseX,mouseY;var nnflag=false;var did;var contentRightNow;var sessionname;var strS='
|
';var strE=' | |
 | |  |
';function deleteNote(){isOperation=true;showsaving();noteList.hideAllNote();document.getElementById("mode_txt").style.display="none";var A="/public/addnote/delnote.php";var B="userid="+currentUserId+"&did="+currentNote.id;var C=new Ajax.Request(A,{method:"get",parameters:B,onSuccess:delNoteOrNot,onFailure:showErrMsg});C=null}function delNoteOrNot(A){var B=createJson(A.responseText);if(B.success){document.getElementById("mode_txt").style.display="none";noteList.hideAllNote();noteList.refreshAllNote()}else{if(tryAddnoteTime'+sessionname+":"+contentRightNow+""+strE;noteList.children[C].rectdiv.style.border="2px groove white";noteList.hideAllNote();noteList.refreshAllNote()}else{alert("操作失败,请重试!")}}function saveNote(J){contentRightNow=document.getElementById("note_txt_value").value;contentRightNow=contentRightNow.replace(/\r\n/g,"
");contentRightNow=contentRightNow.replace(/\n/g,"
");var L=contentRightNow.replace(/(^\s*)|(\s*$)/g,"");if(L==""){alert("请添加标注内容!");return }isOperation=true;noteList.hideAllNote();document.getElementById("mode_txt").style.display="none";showsaving();contentRightNow=contentRightNow.replace(/ /g," ");contentRightNow=escape(contentRightNow);if(nnflag){var H=currentNote.rectdiv;var U=parseInt(H.style.left);var O=parseInt(H.style.top);var P=parseInt(H.style.left)+parseInt(H.style.width);var B=parseInt(H.style.top)+parseInt(H.style.height);var W=U-getObjectLeft(parentPhoto);var R=P-getObjectLeft(parentPhoto);var Q=O-getObjectTop(parentPhoto);var C=B-getObjectTop(parentPhoto);var F="/public/addnote/addnote.php";var M="userid="+currentUserId+"&did="+J+"&l="+W+"&t="+Q+"&r="+R+"&b="+C+"&content="+contentRightNow;var S=new Ajax.Request(F,{asynchronous:true,method:"post",parameters:M,onSuccess:function(Y){var Z=createJson(Y.responseText);if(Z.success){var X=Z.flag;document.getElementById("rect_"+did).id="rect_"+X;document.getElementById("txt_"+did).id="txt_"+X;document.getElementById("corner_"+did).id="corner_"+X;noteList.children[noteList.children.length-1].id=X;nnflag=false;noteList.hideAllNote();noteList.refreshAllNote();document.getElementById("mode_txt").style.display="none"}else{if(tryAddnoteTime'+sessionname+":"+contentRightNow+""+strE;noteList.children[Z].rectdiv.style.border="2px groove white";noteList.hideAllNote();noteList.refreshAllNote()}else{if(tryAddnoteTimeD){B=O.data[G];O.data[G]=O.data[I];O.data[I]=B;C=(O.data[G].right-O.data[G].left)*(O.data[G].bottom-O.data[G].top)}}}for(var G=0;G=getObjectRight(this.children[i].txtdiv)){tempright=getObjectRight(this.children[i].rectdiv)}else{tempright=getObjectRight(this.children[i].txtdiv)}temptop=getObjectTop(this.children[i].rectdiv);if(getObjectBottom(this.children[i].rectdiv)>=getObjectBottom(this.children[i].txtdiv)){tempbottom=getObjectBottom(this.children[i].rectdiv)}else{tempbottom=getObjectBottom(this.children[i].txtdiv)}if(mouseXtempleft&&mouseYtemptop){E=i;break}}}if(I.length>0){E=I[0];var F=parseInt(this.children[I[0]].rectdiv.style.left);var H=parseInt(this.children[I[0]].rectdiv.style.top);var D=parseInt(this.children[I[0]].rectdiv.style.width);var G=parseInt(this.children[I[0]].rectdiv.style.height);for(j=1;j=parseInt(this.children[I[j]].rectdiv.style.width)&&G>=parseInt(this.children[I[j]].rectdiv.style.height)){F=parseInt(this.children[I[j]].rectdiv.style.left);H=parseInt(this.children[I[j]].rectdiv.style.top);D=parseInt(this.children[I[j]].rectdiv.style.width);G=parseInt(this.children[I[j]].rectdiv.style.height);E=I[j]}}return this.children[E]}else{return null}};this.getCurrentNoteRect=function(){var D=-1;if(this.getCurrentNote()!=null){return this.getCurrentNote().rectdiv}else{return null}};this.getCurrentNoteTxt=function(){var D=-1;for(i=0;i-1){return this.children[D]}else{return null}};noteList=this}function newnote(A){if(isGlobleCommondBegin){return }if(document.getElementById("current")==null){return }if(!nnflag&&noModing){did=A;nnflag=true;noteList.addNote(A,10,10,90,90,"在此处添加标注 ...",true,true,"");currentNote=noteList.children[noteList.children.length-1];if(IE5){noteList.children[noteList.children.length-1].rectdiv.style.border="2px dashed white"}if(!IE5&&W3C){noteList.children[noteList.children.length-1].rectdiv.style.border="1px dashed white"}noteList.children[noteList.children.length-1].rectdiv.style.display="block";noteList.children[noteList.children.length-1].cornerdiv.style.display="block";parentPhoto=document.getElementById("current");photoLeft=getObjectLeft(parentPhoto);photoTop=getObjectTop(parentPhoto);$("mode_txt").style.left=photoLeft+10+"px";$("mode_txt").style.top=photoTop+95+"px";$("mode_txt").style.display="block";$("note_txt_value").value="在此处添加标注 ...";$("note_txt_value").select();$("note_txt_value").focus();$("mode_txt_delete").style.display="none";noModing=false}}function note(B,D,J,M,A,H,G,I,F,E,N,K,L){this.id=B;this.left=D;this.top=J;this.right=M;this.bottom=A;this.rleft=E;this.rtop=N;this.rright=K;this.rbottom=L;this.content=H;this.readonly=G;this.editmode=I;var C=set_textarea_width(F,H);this.txtdiv=make_txtdiv("txt_"+B,D,J,M,A,H,G,F,C);this.rectdiv=make_rectdiv("rect_"+B,D,J,M,A);this.cornerdiv=make_cornerdiv("corner_"+B,D,J,M,A);this.paint=function(){}}function set_textarea_width(G,D){G="12345678901234567890";var A=D.split("
");var C=A[0];for(i=0;igetCharsNumber(C)){C=A[i]}}var F=0;if(currentUserName!=G){F=getCharsNumber(G)}var B=getCharsNumber(C);var E;if(B>F){E=B*7}else{E=F*7}if(E>200){return(200)}else{return(E)}}function make_txtdiv(C,D,K,L,A,J,H,G,E){var B=document.createElement("DIV");var I="area_"+C;B.id=C;B.style.position="absolute";B.style.display="none";B.style.top=A+6+"px";B.style.left=D+"px";B.style.zIndex="1000";B.style.width=L-D+"px";B.style.height="30px";J=J.replace(/ /g," ");var F="";F=strS+''+J;if(currentUserName!=G){B.innerHTML=F+'
by '+G+"
"+strE}else{B.innerHTML=F+""+strE}document.body.appendChild(B);return B}function make_rectdiv(F,E,D,C,A){var B=document.createElement("DIV");B.id=F;B.style.position="absolute";B.style.display="none";B.style.border="2px groove white";B.style.overflow="hidden";if(IE5){B.style.borderWidth="2"}if(!IE5&&W3C){B.style.borderWidth="1"}B.style.top=D+"px";B.style.left=E+"px";if(IE5){B.style.backgroundColor="";B.style.filter="Alpha(opacity=100)"}B.style.width=C-E+"px";B.style.height=A-D+"px";document.body.appendChild(B);return B}function make_cornerdiv(F,E,D,C,A){var B=document.createElement("DIV");B.id=F;B.style.position="absolute";B.style.display="none";B.style.cursor="SE-resize";B.style.border="1px solid black";B.style.overflow="hidden";B.style.borderWidth="1";B.style.top=A-small_div+"px";B.style.left=C-small_div+"px";B.style.backgroundColor="#ffffff";B.style.zIndex="101";B.style.width=small_div+"px";B.style.height=small_div+"px";document.body.appendChild(B);return B}function move(A){if(isGlobleCommondBegin){return }if(isOperation){return }if(noteList!=undefined){A||(A=event);var C=mouseCoords(A);mouseX=C.x;mouseY=C.y;if(inPhotoRange(parentPhoto)||!noModing){noteList.showAllNote()}else{noteList.hideAllNote()}if(noModing){noteList.hideAllTxtAndCorner();noteList.getAllBorderBack();var B=noteList.getCurrentNote();if(B!=null){B.rectdiv.style.border="2px groove #FFFF2B";B.txtdiv.style.display="block";B.rectdiv.style.zIndex="100"}}else{if(currentObject!=null&&(currentObject==currentNote.cornerdiv||currentObject==currentNote.rectdiv)&&dragapproved){if(currentObject==currentNote.cornerdiv){var D=parseInt(currentNote.rectdiv.style.left)+minW;var G=parseInt(currentNote.rectdiv.style.top)+minH;var F=photoLeft+parentPhoto.width-1;var E=photoTop+parentPhoto.height-1}else{var D=photoLeft;var G=photoTop;var F=photoLeft+parentPhoto.width-1;var E=photoTop+parentPhoto.height-1}if(mouseX+xoff>D&&mouseX+xoff+parseInt(currentObject.style.width)G&&mouseY+yoff+parseInt(currentObject.style.height)getObjectLeft(A)&&mouseYgetObjectTop(A)){return true}else{return false}}function mouseCoords(A){if(A.pageX&&A.pageY){return{x:A.pageX,y:A.pageY}}return{x:A.clientX+document.documentElement.scrollLeft-document.body.clientLeft,y:A.clientY+document.documentElement.scrollTop-document.body.clientTop}}function inPhotoRange(A){if(mouseXgetObjectLeft(A)&&mouseYgetObjectTop(A)){return true}else{return false}}function cancelModeNote(){noModing=true;document.getElementById("mode_txt").style.display="none";noteList.refreshAllNote();nnflag=false}function cancleAllEvt(){document.onmousedown=null;document.onmousemove=null;document.onmouseup=null}function startAllEvt(){document.onmousedown=drags;document.onmousemove=move;document.onmouseup=stopdrags}function showErrMsg(){alert("操作失败,请刷新页面重试");tryAddnoteTime=0;closesaving()}function showsaving(){document.getElementById("saving").style.top=GetAbsoluteLocationEx(document.getElementById("current")).absoluteTop+GetAbsoluteLocationEx(document.getElementById("current")).offsetHeight/2-10;document.getElementById("saving").style.left=GetAbsoluteLocationEx(document.getElementById("current")).absoluteLeft+GetAbsoluteLocationEx(document.getElementById("current")).offsetWidth/2-50;document.getElementById("saving").innerHTML='
';document.getElementById("saving").style.display="block"}function closesaving(){document.getElementById("saving").innerHTML="";document.getElementById("saving").style.display="none";isOperation=false}function GetAbsoluteLocationEx(C){if(arguments.length!=1||C==null){return null}var B=C;var E=B.offsetTop;var F=B.offsetLeft;var D=B.offsetWidth;var A=B.offsetHeight;while(B=B.offsetParent){if(B.style.position=="absolute"||B.style.position=="relative"||(B.style.overflow!="visible"&&B.style.overflow!="")){break}E+=B.offsetTop;F+=B.offsetLeft}return{absoluteTop:E,absoluteLeft:F,offsetWidth:D,offsetHeight:A}}function getCharsNumber(C){var B=0;var A=0;for(B=0;B127||C.charCodeAt(B)==94){A=A+2}else{A=A+1}}return(A)}function ge(A){el=document.getElementById(A);return el}function htmtotext(A){A=A.replace(/
/g,"\n");A=A.replace(/
/g,"\n");A=A.replace(/
/g,"\n");A=A.replace(/ /g," ");return A}function limit_textarea(B,A){if(B.value.length>A){B.value=B.value.substring(0,A)}}