',class:"tag_div_hidden",styles:{width:parseInt(n)-4+"px",height:parseInt(o)-4+"px",top:i+"px",left:s+"px"}}).inject($("media_photo_div")),new Element("div",{id:"tag_label_"+t,html:e,class:"tag_label",styles:{display:"none",top:parseInt(i)+parseInt(o)+10+"px",left:s+"px"}}).inject($("media_photo_div")),$("tag_"+t).addEvent("mouseover",function(){a.showTag(t)}),$("tag_"+t).addEvent("mouseout",function(){a.hideTag(t)})},showTag:function(t){$("tag_"+t).className="tag_div",$("tag_label_"+t).style.display="block"},hideTag:function(t){$("tag_"+t).className="tag_div_hidden",$("tag_label_"+t).style.display="none"},addTag:function(){var n;this.isTagging||(this.isTagging=!0,this.newtag=new MooCrop("media_photo"),(n=$("media_photo_tagform").inject(this.newtag.wrapper)).setStyles({top:this.newtag.crop.bottom+10,left:this.newtag.crop.right+10,display:"block"}),this.newtag.addEvent("onBegin",function(t,e,i,s){n.setStyle("display","none")}),this.newtag.addEvent("onCrop",function(t,e,i,s){n.setStyles({top:e.bottom+10,left:e.right+10,display:"none"})}),this.newtag.addEvent("onComplete",function(t,e,i,s){n.setStyle("display","block")}))},cancelTag:function(){this.isTagging&&($("media_photo_tag").value="",$("media_photo_tagform").inject("media_photo_div").setStyle("display","none"),this.newtag.removeOverlay.bind(this.newtag)(),this.isTagging=!1)},saveTag:function(t){var e,i,s,n;this.isTagging&&(s=this.options.object_owner&&this.options.object_owner_id?(e=this.options.object_owner,i=this.options.object_owner_id,""):(i=e="",this.Base.Owner.user_info.user_username),n=this,new Request.JSON({url:this.options.ajaxURL,method:this.options.ajaxMethod,secure:this.options.ajaxSecure,data:{task:"tag_do",ajax:!0,mediatag_user_id:t,mediatag_text:$("media_photo_tag").value,mediatag_x:this.newtag.crop.top,mediatag_y:this.newtag.crop.left,mediatag_height:this.newtag.crop.height,mediatag_width:this.newtag.crop.width,user:s,object_owner:e,object_owner_id:i,type:this.options.type,media_id:this.options.media_id,media_dir:this.options.media_dir},onComplete:function(t){$type(t.mediatag_id)&&n.insertTag(t.mediatag_id,t.mediatag_link,t.mediatag_text,t.mediatag_x,t.mediatag_y,t.mediatag_width,t.mediatag_height,t.mediatag_user_username)}}).send(),$("media_photo_tag").value="",$("media_photo_tagform").inject("media_photo_div").setStyle("display","none"),this.newtag.removeOverlay.bind(this.newtag)(),this.isTagging=!1)},removeTag:function(t){var e,i,s;s=this.options.object_owner&&this.options.object_owner_id?(e=this.options.object_owner,i=this.options.object_owner_id,""):(i=e="",this.Base.Owner.user_info.user_username);new Request.JSON({url:this.options.ajaxURL,method:this.options.ajaxMethod,secure:this.options.ajaxSecure,data:{task:"tag_remove",ajax:!0,mediatag_id:t,user:s,object_owner:e,object_owner_id:i,type:this.options.type,media_id:this.options.media_id}}).send();$("tag_"+t).destroy(),$("tag_label_"+t).destroy(),$("full_tag_"+t).destroy(),0==this.tags.indexOf(t)&&$("tag_comma_"+this.tags[1])&&$("tag_comma_"+this.tags[1]).destroy(),this.tags.splice(this.tags.indexOf(t),1),0==this.tags.length&&($("media_tags").style.display="none")}});var MooCrop=new Class({calculateHandles:!0,current:{},options:{maskColor:"black",maskOpacity:".3",handleColor:"#FFFFFF",handleWidth:"5px",handleHeight:"5px",cropBorder:"1px dashed #FFFFFF",min:{width:50,height:50},showMask:!0,showHandles:!1},initialize:function(t,e){if(this.setOptions(e),this.img=$(t),"img"!=this.img.get("tag"))return!1;this.resizeFunc=this.refresh.bindWithEvent(this),this.removeFunc=this.removeListener.bind(this),this.buildOverlay(),this.setup()},setup:function(){$(this.cropArea).setStyles({width:this.options.min.width,height:this.options.min.height,top:(this.img.height-this.options.min.height)/2,left:(this.img.width-this.options.min.width)/2}),this.current.crop=this.crop=this.getCropArea(),this.handleWidthOffset=this.options.handleWidth.toInt()/2,this.handleHeightOffset=this.options.handleHeight.toInt()/2,this.fixBoxModel(),this.drawMasks(),this.positionHandles()},getCropArea:function(){var t=this.cropArea.getCoordinates();return t.left-=this.offsets.x,t.right-=this.offsets.x,t.top-=this.offsets.y,t.bottom-=this.offsets.y,t},fixBoxModel:function(){var t=this.boxDiff=(this.crop.width-this.options.min.width)/2,e=this.bounds={top:t,left:t,right:this.img.width+2*t,bottom:this.img.height+2*t,width:this.options.min.width+2*t,height:this.options.min.height+2*t};this.wrapper.setStyles({width:e.right,height:e.bottom,background:"url("+this.img.src+") no-repeat "+t+"px "+t+"px"}),this.north.setStyle("width",e.right),this.south.setStyle("width",e.right)},activate:function(t,e){t.stop(),this.current={x:t.page.x,y:t.page.y,handle:e,crop:this.current.crop},"NESW"!=this.current.handle||this.options.showHandles||this.hideHandles(),this.fireEvent("onBegin",[this.img.src,this.getCropInfo(),this.bounds,e]),document.addEvent("mousemove",this.resizeFunc),document.addEvent("mouseup",this.removeFunc)},removeListener:function(){"NESW"!=this.current.handle||this.options.showHandles||this.showHandles(),document.removeEvent("mousemove",this.resizeFunc),document.removeEvent("mouseup",this.removeFunc),this.crop=this.current.crop,this.fireEvent("onComplete",[this.img.src,this.getCropInfo(),this.bounds,this.current.handle])},refresh:function(t){var e=this.current.x-t.page.x,i=this.current.y-t.page.y,s=this.bounds,n=this.crop,o=this.current.handle,a={},r=2