function gp_init_inline_edit(i){function d(b,a){var c=l(b);"undefined"!==typeof a&&c.val(a);return parseInt(c.val())}function l(b){return $("#gp_current_image input[name="+b+"]")}function j(b,a){e.posx=b=d("left",b);e.posy=a=d("top",a);f.css({"background-position":b+"px "+a+"px"});g=!0}function m(b,a,c){delete e.src;b!==n&&(e.src=b);f.css({"background-image":'url("'+b+'")'});$("#gp_current_image img").attr("src",b);0<a&&0<c&&(d("width",a),d("height",c),f.stop(!0,!0).animate({width:a,height:c}))}$gp.LoadStyle("/include/css/inline_image.css");
var p=gp_editing.get_path(i),f=gp_editing.get_edit_area(i);f.addClass("gp_image_edit");var n=f.attr("src"),g=!1,e={};loaded();gp_editing.editor_tools();$("#ckeditor_controls").prepend('<div id="gp_folder_options"></div>');gp_editor={save_path:p,checkDirty:function(){return g},gp_saveData:function(){return jQuery.param(e)+"&cmd=save_image"},resetDirty:function(){g=!1},updateElement:function(){}};i=strip_from(p,"?")+"?cmd=image_editor";$gp.jGoTo(i);var k=!1;gpresponse.image_options_loaded=function(){var b=
f.width(),a=f.height();d("orig_width",b);d("orig_height",a);m(n,b,a);var c=posy=mouse_startx=mouse_starty=pos_startx=pos_starty=0,h=!1;f.disableSelection();f.mousedown(function(a){a.preventDefault();h=!0;pos_startx=c=e.posx||0;pos_starty=posy=e.posy||0;mouse_startx=a.pageX;mouse_starty=a.pageY}).on("mouseleave mouseup",function(a){a.preventDefault();h=!1}).mousemove(function(a){h&&(c=pos_startx+a.pageX-mouse_startx,posy=pos_starty+a.pageY-mouse_starty,j(c,posy))});f.attr("src",gp_blank_img);$("#gp_current_image input").on("keyup keydown change paste",
function(){k&&clearTimeout(k);k=setTimeout(function(){g=!0;e.width=d("width");e.height=d("height");f.stop(!0,!0).animate({width:e.width,height:e.height});var a=d("left"),c=d("top");j(a,c)},400)})};gplinks.gp_gallery_add=function(b,a){a.preventDefault();var c=$(this).stop(!0,!0),h=c.data("width"),f=c.data("height");m(c.attr("href"),h,f);j(0,0);e.width=d("width");e.height=d("height");g=!0};gplinks.show_uploaded_images=function(){LoadImages(!1)};gplinks.deafult_sizes=function(){d("width",d("orig_width"));
d("height",d("orig_height"));l("width").change();j(0,0)};gpresponse.gp_gallery_images=function(){var b=$("#gp_upload_form");b.attr("action");b.find(".file").auto_upload({start:function(a,c){c.bar=$('<a name="gp_file_uploading">'+a+"</a>").appendTo("#gp_upload_queue");return!0},progress:function(a,c,b){a=Math.round(100*a);a=Math.min(98,a-1);b.bar.text(a+"% "+c)},finish:function(a,c,b){b=b.bar;b.text("100% "+c);var d=$(a),a=d.find(".status").val(),d=d.find(".message").val();"success"==a?(b.addClass("success"),
b.slideUp(1200),c=$("#gp_gallery_avail_imgs"),$(d).appendTo(c)):"notimage"==a?b.addClass("success"):(b.addClass("failed"),b.text(c+": "+d))},error:function(a,b,d){alert("error: "+d)}})}};