function PhotoNoteContainer(b,a){var c={element:b,dragresize:null,notes:new Array(),editing:false};for(var d in c){this[d]=(!a||typeof a[d]=="undefined")?c[d]:a[d]}}PhotoNoteContainer.prototype.DeleteNote=function(a){a.UnSelect();this.element.removeChild(a.gui.ElementRect);this.element.removeChild(a.gui.ElementNote);this.notes.remove(a)};PhotoNoteContainer.prototype.AddNote=function(a){if(!this.editing){this.notes[this.notes.length]=a;a.container=this;this.element.appendChild(a.gui.ElementRect);this.element.appendChild(a.gui.ElementNote)}};PhotoNoteContainer.prototype.HideAllNoteTexts=function(){for(var a=0;a<this.notes.length;a++){this.notes[a].HideNoteText()}};PhotoNoteContainer.prototype.DisableAllNotes=function(){for(var a=0;a<this.notes.length;a++){this.notes[a].DisableNote()}};PhotoNoteContainer.prototype.HideAllNotes=function(){for(var a=0;a<this.notes.length;a++){this.notes[a].HideNote()}};PhotoNoteContainer.prototype.ShowAllNotes=function(){for(var a=0;a<this.notes.length;a++){this.notes[a].ShowNote()}};PhotoNoteContainer.prototype.EnableAllNotes=function(){for(var a=0;a<this.notes.length;a++){this.notes[a].EnableNote()}};PhotoNoteContainer.prototype.DeleteAllNotes=function(){for(var a=0;a<this.notes.length;a++){this.notes[a].container.DeleteNote(this.notes[a])}};function PhotoNote(j,d,c,a,i,e,g){var f={text:j,text_pre:d,id:c,rect:g,selected:false,container:null,dragresize:null,oldRect:null,YOffset:10,XOffset:0,onsave:null,ondelete:null,gui:null,selectable:i,resizable:a,deletable:e};for(var b in f){this[b]=f[b]}this.CreateElements()}PhotoNote.prototype.Select=function(){if(!this.selectable){return}eigenes_created=true;if(!this.container.editing){this.ShowNoteText();this.dragresize.select(this.gui.ElementRect);this.selected=true;this.SetEditable(true)}};PhotoNote.prototype.UnSelect=function(){this.dragresize.deselect(false);this.selected=false;this.SetEditable(false);this.HideNoteText()};PhotoNote.prototype.Save=function(){this.oldRect=null;this.gui.TextTitle.innerHTML=this.text_pre+this.gui.TextBox.value.escapeHTML();this.text=this.gui.TextBox.value;this.UnSelect()};PhotoNote.prototype.Cancel=function(){if(this.id<0){if(foto_newnote_cancel_cb){foto_newnote_cancel_cb()}this.container.DeleteNote(this)}else{if(foto_editnote_cancel_cb){foto_editnote_cancel_cb()}if(this.oldRect!=null){this.rect=this.oldRect}this.oldRect=null;this.gui.TextBox.value=this.text_pre+this.text.escapeHTML();this.PositionNote();this.UnSelect()}eigenes_created=false};PhotoNote.prototype.ShowNoteText=function(){if(!this.container.editing){this.container.HideAllNoteTexts();this.container.DisableAllNotes();this.EnableNote();this.gui.ElementRect.style.border="1px solid #E8E8FF";this.gui.ElementRect.style.margin="0";this.gui.ElementNote.style.display="block"}};PhotoNote.prototype.DisableNote=function(){this.dragresize.enabled=false};PhotoNote.prototype.EnableNote=function(){if(!this.resizable){return}this.dragresize.enabled=true};PhotoNote.prototype.HideNoteText=function(){this.gui.ElementRect.style.border="0px solid #E8E8FF";this.gui.ElementRect.style.margin="1px";this.gui.ElementNote.style.display="none"};PhotoNote.prototype.HideNote=function(){this.gui.ElementRect.style.display="none";this.gui.ElementNote.style.display="none"};PhotoNote.prototype.ShowNote=function(){this.gui.ElementRect.style.display="block";this.gui.ElementNote.style.display="none"};PhotoNote.prototype.SetEditable=function(a){this.container.editing=a;if(a){this.gui.TextTitle.style.display="none";this.gui.EditArea.style.display="block";if(this.deletable){if(this.id<=0){this.gui.DeleteButton.style.display="none"}else{this.gui.DeleteButton.style.display="inline"}}this.HighlightTextbox()}else{this.gui.TextTitle.style.display="block";this.gui.EditArea.style.display="none"}};PhotoNote.prototype.HighlightTextbox=function(){if(this.gui.EditArea.style.display=="block"){var a=this.gui.TextBox;setTimeout(function(){try{a.focus();a.select()}catch(b){}},200)}};PhotoNote.prototype.CreateElements=function(){this.gui=new PhotoNoteGUI();var m=new Element("div");this.dragresize=new DragResize("dragresize",{allowBlur:false});m.className="fn-area";m.id="fn-area-new";var b=new Element("div");b.className="fn-area-blackborder";var e=new Element("div");e.className="fn-area-whiteborder";var g=this;var p=new Element("div");p.className="fn-area-inner";e.appendChild(p);addEvent(p,"mouseover",function(){g.ShowNoteText()});addEvent(p,"mouseout",function(){if(!g.selected){setTimeout(function(){g.HideNoteText()},250)}});addEvent(p,"mousedown",function(){if(!g.selected){g.Select()}});b.appendChild(e);m.appendChild(b);var l=new Element("div");l.className="fn-note";var a=new Element("div");a.className="fn-note-text";a.innerHTML=this.text_pre+this.text.escapeHTML();l.appendChild(a);var j=new Element("div");j.className="fn-note-edit";var f=new Element("div");f.className="fn-note-edit-text";var n=new Element("textarea");n.value=this.text;f.appendChild(n);j.appendChild(f);var k=new Element("div");var i=new Element("input");i.type="button";i.className="Butt";i.value=n_str_save;i.observe("click",function(r){if(g.onsave){var q=g.onsave(g);if(q>0){g.id=q;g.Save()}else{alert("error saving note");g.Cancel()}}else{alert("onsave must be implemented in order to *actually* save");g.Cancel()}r.stop()});k.appendChild(i);var d=new Element("input");d.type="button";d.className="CancelButt";d.value=n_str_cancel;d.observe("click",function(q){g.Cancel();q.stop()});k.appendChild(d);if(this.deletable){var c=new Element("input");c.type="button";c.className="CancelButt";c.value=n_str_delete;c.observe("click",function(r){if(g.ondelete){var q=g.ondelete(g);if(q){g.container.DeleteNote(g)}else{alert("error deleting note")}}else{alert("ondelete must be implemented in order to *actually* delete")}r.stop()});k.appendChild(c)}j.appendChild(k);l.appendChild(j);this.dragresize.isElement=function(q){if(q.className=="fn-area"){this.maxRight=g.container.element.offsetWidth-1;this.maxBottom=g.container.element.offsetHeight-1;return true}};this.dragresize.isHandle=function(q){if(q.className=="fn-area"){return true}};this.dragresize.ondragfocus=function(){g.gui.ElementRect.style.cursor="move"};this.dragresize.ondragblur=function(){g.gui.ElementRect.style.cursor="pointer"};this.dragresize.ondragstart=function(){if(g.oldRect==null){var q=g.rect;g.oldRect=new PhotoNoteRect(q.left,q.top,q.width,q.height)}};this.dragresize.ondragend=function(){g.HighlightTextbox()};this.dragresize.ondragmove=function(){g.rect.left=parseInt(this.element.style.left);g.rect.top=parseInt(this.element.style.top);g.rect.width=parseInt(this.element.style.width);g.rect.height=parseInt(this.element.style.height);g.PositionNote()};this.dragresize.apply(document);this.gui.ElementRect=m;this.gui.ElementNote=l;this.gui.EditArea=j;this.gui.TextBox=n;this.gui.TextTitle=a;this.gui.DeleteButton=c;this.PositionNote()};PhotoNote.prototype.PositionNote=function(){this.gui.ElementRect.style.left=this.rect.left+"px";this.gui.ElementRect.style.top=this.rect.top+"px";this.gui.ElementRect.style.width=this.rect.width+"px";this.gui.ElementRect.style.height=this.rect.height+"px";this.gui.ElementRect.firstChild.style.width=parseInt(this.gui.ElementRect.style.width)-2+"px";this.gui.ElementRect.firstChild.style.height=parseInt(this.gui.ElementRect.style.height)-2+"px";this.gui.ElementRect.firstChild.firstChild.style.width=parseInt(this.gui.ElementRect.style.width)-4+"px";this.gui.ElementRect.firstChild.firstChild.style.height=parseInt(this.gui.ElementRect.style.height)-4+"px";this.gui.ElementRect.firstChild.firstChild.firstChild.style.width=parseInt(this.gui.ElementRect.style.width)-6+"px";this.gui.ElementRect.firstChild.firstChild.firstChild.style.height=parseInt(this.gui.ElementRect.style.height)-6+"px";this.gui.ElementNote.style.left=this.rect.left+this.XOffset+"px";this.gui.ElementNote.style.top=this.rect.top+this.YOffset+this.rect.height+"px"};function PhotoNoteGUI(){this.ElementRect=null;this.ElementNote=null;this.TextTitle=null;this.EditArea=null;this.TextBox=null;this.DeleteButton=null}function PhotoNoteRect(d,c,b,a){this.left=d;this.top=c;this.width=b;this.height=a}PhotoNoteRect.prototype.toString=function(){return"left: "+this.left+", top: "+this.top+", width: "+this.width+", height: "+this.height};var aeOL=[];function addEvent(k,m,j,e){var d="addEventListener",i="on"+m,c="",g="";if(k[d]&&!e){return k[d](m,j,false)}k._c|=0;if(k[i]){c="_f"+k._c++;k[c]=k[i]}g="_f"+k._c++;k[g]=j;k[i]=function(b){b=b||window.event;var a=true;if(c){a=k[c](b)!=false&&a}a=k[g](b)!=false&&a;return a};aeOL[aeOL.length]={o:k,h:i}}addEvent(window,"unload",function(){for(var i=0;i<aeOL.length;i++){with(aeOL[i]){o[h]=null;for(var c=0;o["_f"+c];c++){o["_f"+c]=null}}}});function cancelEvent(a,b){a.returnValue=false;if(a.preventDefault){a.preventDefault()}if(b){a.cancelBubble=true;if(a.stopPropagation){a.stopPropagation()}}}function addLoadEvent(a){var b=window.onload;if(typeof window.onload!="function"){window.onload=a}else{window.onload=function(){b();a()}}}Array.prototype.clear=function(){this.length=0};Array.prototype.remove=function(c){var a=false;var d=[];for(var b=0;b<this.length;b++){if(this[b]==c){a=true}else{d.push(this[b])}}this.clear();for(var b=0;b<d.length;b++){this.push(d[b])}d=null;return a};function DragResize(b,a){var c={myName:b,enabled:true,handles:["tl","tm","tr","ml","mr","bl","bm","br"],isElement:null,isHandle:null,element:null,dragging:null,minWidth:10,minHeight:10,minLeft:0,maxRight:9999,minTop:0,maxBottom:9999,zIndex:1,mouseX:0,mouseY:0,lastMouseX:0,lastMouseY:0,mOffX:0,mOffY:0,elmX:0,elmY:0,elmW:0,elmH:0,allowBlur:true,ondragfocus:null,ondragstart:null,ondragmove:null,ondragend:null,ondragblur:null};for(var d in c){this[d]=(typeof a[d]=="undefined")?c[d]:a[d]}}DragResize.prototype.apply=function(a){var b=this;addEvent(a,"mousedown",function(c){b.mouseDown(c)});addEvent(a,"mousemove",function(c){b.mouseMove(c)});addEvent(a,"mouseup",function(c){b.mouseUp(c)})};DragResize.prototype.handleSet=function(elm,show){with(this){if(!elm._handle_tr){for(var h=0;h<handles.length;h++){var hDiv=new Element("div");hDiv.className=myName+" "+myName+"-"+handles[h];elm["_handle_"+handles[h]]=elm.appendChild(hDiv)}}for(var h=0;h<handles.length;h++){elm["_handle_"+handles[h]].style.visibility=show?"inherit":"hidden"}}};DragResize.prototype.select=function(newElement){with(this){if(!document.getElementById||!enabled){return}if(newElement&&(newElement!=element)&&enabled){element=newElement;element.style.zIndex=++zIndex;handleSet(element,true);elmX=parseInt(element.style.left);elmY=parseInt(element.style.top);elmW=element.offsetWidth;elmH=element.offsetHeight;if(ondragfocus){this.ondragfocus()}}}};DragResize.prototype.deselect=function(keepHandles){with(this){if(!document.getElementById||!enabled){return}if(!keepHandles){if(ondragblur){this.ondragblur()}handleSet(element,false);element=null}dragging=null;mOffX=0;mOffY=0}};DragResize.prototype.mouseDown=function(e){with(this){if(!document.getElementById||!enabled){return true}var elm=e.target||e.srcElement,newElement=null,newHandle=null,hRE=new RegExp(myName+"-([trmbl]{2})","");while(elm){if(elm.className){if(!newHandle&&(hRE.test(elm.className)||isHandle(elm))){newHandle=elm}if(isElement(elm)){newElement=elm;break}}elm=elm.parentNode}if(element&&(element!=newElement)&&allowBlur){deselect(false)}if(newElement&&(!element||(newElement==element))){cancelEvent(e);select(newElement,newHandle);dragging=newHandle;if(dragging&&ondragstart){this.ondragstart()}}}};DragResize.prototype.mouseMove=function(e){with(this){if(!document.getElementById||!enabled){return true}mouseX=e.pageX||e.clientX+document.documentElement.scrollLeft;mouseY=e.pageY||e.clientY+document.documentElement.scrollTop;var diffX=mouseX-lastMouseX+mOffX;var diffY=mouseY-lastMouseY+mOffY;mOffX=mOffY=0;lastMouseX=mouseX;lastMouseY=mouseY;if(!dragging){return true}var hClass=dragging&&dragging.className&&dragging.className.match(new RegExp(myName+"-([tmblr]{2})"))?RegExp.$1:"";var rs=0,dY=diffY,dX=diffX;if(hClass.indexOf("t")>=0){rs=1;if(elmH-dY<minHeight){mOffY=(dY-(diffY=elmH-minHeight))}else{if(elmY+dY<minTop){mOffY=(dY-(diffY=minTop-elmY))}}elmY+=diffY;elmH-=diffY}if(hClass.indexOf("b")>=0){rs=1;if(elmH+dY<minHeight){mOffY=(dY-(diffY=minHeight-elmH))}else{if(elmY+elmH+dY>maxBottom){mOffY=(dY-(diffY=maxBottom-elmY-elmH))}}elmH+=diffY}if(hClass.indexOf("l")>=0){rs=1;if(elmW-dX<minWidth){mOffX=(dX-(diffX=elmW-minWidth))}else{if(elmX+dX<minLeft){mOffX=(dX-(diffX=minLeft-elmX))}}elmX+=diffX;elmW-=diffX}if(hClass.indexOf("r")>=0){rs=1;if(elmW+dX<minWidth){mOffX=(dX-(diffX=minWidth-elmW))}else{if(elmX+elmW+dX>maxRight){mOffX=(dX-(diffX=maxRight-elmX-elmW))}}elmW+=diffX;window.status="diffX:"+diffX}if(dragging&&!rs){if(elmX+dX<minLeft){mOffX=(dX-(diffX=minLeft-elmX))}else{if(elmX+elmW+dX>maxRight){mOffX=(dX-(diffX=maxRight-elmX-elmW))}}if(elmY+dY<minTop){mOffY=(dY-(diffY=minTop-elmY))}else{if(elmY+elmH+dY>maxBottom){mOffY=(dY-(diffY=maxBottom-elmY-elmH))}}elmX+=diffX;elmY+=diffY}with(element.style){left=elmX+"px";width=elmW+"px";top=elmY+"px";height=elmH+"px"}if(window.opera&&document.documentElement){var oDF=document.getElementById("op-drag-fix");if(!oDF){var oDF=new Element("input");oDF.id="op-drag-fix";oDF.style.display="none";document.body.appendChild(oDF)}oDF.focus()}if(ondragmove){this.ondragmove()}cancelEvent(e)}};DragResize.prototype.mouseUp=function(e){with(this){if(!document.getElementById||!enabled){return}if(ondragend){this.ondragend()}deselect(true)}};