if(typeof KAJONA=="undefined"){alert("load kajona.js before!")}KAJONA.admin.ajax.saveImageCropping=function(e,c,d,b,g,a){var f="file="+g+"&intX="+e+"&intY="+c+"&intWidth="+d+"&intHeight="+b+"";KAJONA.admin.ajax.genericAjaxCall("mediamanager","saveCropping","&"+f,a)};KAJONA.admin.ajax.saveImageRotating=function(d,c,a){var b="file="+c+"&angle="+d+"";KAJONA.admin.ajax.genericAjaxCall("mediamanager","rotate","&"+b,a)};KAJONA.admin.ajax.createFolder=function(b,a){KAJONA.admin.ajax.genericAjaxCall("mediamanager","createFolder",b+"&folder="+a,function(e,c,d){if(c=="success"){if(e.indexOf("<error>")!=-1){KAJONA.admin.statusDisplay.displayXMLMessage(e)}else{KAJONA.admin.ajax.genericAjaxCall("mediamanager","partialSyncRepo",b,function(h,f,g){if(f=="success"){location.reload()}else{KAJONA.admin.statusDisplay.messageError("<b>Request failed!</b><br />"+h)}})}}else{KAJONA.admin.statusDisplay.messageError("<b>Request failed!</b><br />"+e)}})};KAJONA.admin.mediamanager={createFolder:function(c,b){var a=document.getElementById(c).value;if(a!=""){KAJONA.admin.ajax.createFolder(b,a)}}};KAJONA.admin.mediamanager.imageEditor={cropArea:null,fm_cropObj:null,fm_image_isScaled:true,showRealSize:function(){$("#fm_mediamanagerPic").attr("src",fm_image_rawurl+"&x="+(new Date()).getMilliseconds());this.fm_image_isScaled=false;this.hideCropping()},showPreview:function(){$("#fm_mediamanagerPic").attr("src",fm_image_scaledurl.replace("__width__",fm_image_scaledMaxWidth).replace("__height__",fm_image_scaledMaxHeight)+"&x="+(new Date()).getMilliseconds());this.fm_image_isScaled=true;this.hideCropping()},showCropping:function(){if(this.fm_cropObj==null){$("#fm_mediamanagerPic").Jcrop({},function(){KAJONA.admin.mediamanager.imageEditor.fm_cropObj=this});this.fm_cropObj.animateTo([120,120,80,80]);$("#accept_icon").attr("src",$("#accept_icon").attr("src").replace("icon_crop_acceptDisabled.gif","icon_crop_accept.png"));$("#fm_mediamanagerPic_wrap").bind("dblclick",function(a){KAJONA.admin.mediamanager.imageEditor.saveCropping()})}else{this.hideCropping()}},hideCropping:function(){if(this.fm_cropObj!=null){this.fm_cropObj.destroy();this.fm_cropObj=null;$("#fm_mediamanagerPic").css("visibility","visible");$("#accept_icon").attr("src",$("#accept_icon").attr("src").replace("icon_crop_accept.gif","icon_crop_acceptDisabled.png"))}},saveCropping:function(){if(this.fm_cropObj!=null){init_fm_crop_save_warning_dialog()}},saveCroppingToBackend:function(){jsDialog_1.hide();init_fm_screenlock_dialog();this.cropArea=this.fm_cropObj.tellSelect();if(fm_image_isScaled){var e=document.getElementById("fm_mediamanagerPic").width;var c=document.getElementById("fm_mediamanagerPic").height;var b=document.getElementById("fm_int_realwidth").value;var a=document.getElementById("fm_int_realheight").value;this.cropArea.x=Math.floor(this.cropArea.x*(b/e));this.cropArea.y=Math.floor(this.cropArea.y*(a/c));this.cropArea.w=Math.floor(this.cropArea.w*(b/e));this.cropArea.h=Math.floor(this.cropArea.h*(a/c))}var d=function(h,f,g){if(f=="success"){var i=KAJONA.admin.mediamanager.imageEditor;KAJONA.admin.statusDisplay.displayXMLMessage(h);i.fm_cropObj.destroy();i.fm_cropObj=null;$("#accept_icon").attr("src",$("#accept_icon").attr("src").replace("icon_crop_accept.gif","icon_crop_acceptDisabled.png"));$("#fm_image_dimensions").html(i.cropArea.w+" x "+i.cropArea.h);$("#fm_image_size").html("n.a.");$("#fm_int_realwidth").val(i.cropArea.w);$("#fm_int_realheight").val(i.cropArea.h);$("#fm_mediamanagerPic").css("visibility","visible");if(this.fm_image_isScaled){i.showPreview()}else{i.showRealSize()}i.cropArea=null;location.reload();hide_fm_screenlock_dialog()}else{KAJONA.admin.statusDisplay.messageError("<b>Request failed!</b>"+h);hide_fm_screenlock_dialog()}};KAJONA.admin.ajax.saveImageCropping(this.cropArea.x,this.cropArea.y,this.cropArea.w,this.cropArea.h,fm_file,d)},rotate:function(a){init_fm_screenlock_dialog();var b=function(f,c,e){if(c=="success"){var g=KAJONA.admin.mediamanager.imageEditor;KAJONA.admin.statusDisplay.displayXMLMessage(f);if(g.fm_cropObj!=null){g.fm_cropObj.destroy();g.fm_cropObj=null;$("#accept_icon").attr("src",$("#accept_icon").attr("src").replace("icon_crop_accept.gif","icon_crop_acceptDisabled.png"))}var i=fm_image_scaledMaxWidth;fm_image_scaledMaxWidth=fm_image_scaledMaxHeight;fm_image_scaledMaxHeight=i;if(g.fm_image_isScaled){g.showPreview()}else{g.showRealSize()}var d=$("#fm_int_realwidth").val();var h=$("#fm_int_realheight").val();$("#fm_int_realwidth").val(h);$("#fm_int_realheight").val(d);$("#fm_image_dimensions").html(h+" x "+d);hide_fm_screenlock_dialog()}else{KAJONA.admin.statusDisplay.messageError("<b>Request failed!</b>"+f);hide_fm_screenlock_dialog()}};KAJONA.admin.ajax.saveImageRotating(a,fm_file,b)}};