function gp_init_inline_edit(h,p,i){function m(){e.children("li").unbind("mouseenter.gp_edit, mouseleave.gp_edit, mousedown.gp_edit").bind("mouseenter.gp_edit",function(){var a=$(this).offset();d.show().css({left:a.left,top:a.top});j=this}).bind("mouseleave.gp_edit",function(){d.hide()}).bind("mousedown.gp_edit",function(){d.hide()})}function l(a,b){e.find(".gp_to_remove").remove();a.attr({name:g.img_name,rel:g.img_rel,title:""}).removeAttr("class");var c=$("<li>").append(a).append('<div class="caption"></div>');
b?b.replaceWith(c):e.append(c);m()}$gp.LoadStyle("/include/css/inline_image.css");var n={sortable_area_sel:".gp_gallery",img_name:"gallery",img_rel:"gallery_gallery"},g=$.extend(g,n,i);"undefined"!==typeof gp_gallery_options&&(g=$.extend(g,n,gp_gallery_options));var d=!1,k=!1,j=!1,e,i=gp_editing.get_path(h),f=gp_editing.get_edit_area(h);!1==f||!1==i||(gp_editor={save_path:i,destroy:function(){e.sortable("destroy");f.html(k.html());e.children("li").unbind("mouseenter.gp_edit, mouseleave.gp_edit, mousedown.gp_edit");
d.remove()},checkDirty:function(){e.removeClass("ui-sortable");var a=k.html().replace(/>[\s]+/g,">"),b=f.html().replace(/>[\s]+/g,">");if(a!=b)return e.addClass("ui-sortable"),!0;e.addClass("ui-sortable");return!1},gp_saveData:function(){var a=f.clone();a.find("li.holder").remove();a.find("ul").enableSelection().sortable("destroy").removeClass("ui-sortable").removeAttr("unselectable");a.find(".gp_nosave").remove();a=a.html();return"gpcontent="+encodeURIComponent(a)},resetDirty:function(){k=f.clone(!1);
k.find(".ui-sortable").removeClass("ui-sortable")},updateElement:function(){}},f.get(0).innerHTML=p.content,h=function(a,b,c){a.append('<a name="'+b+'"><img src="'+gpBase+'/include/imgs/blank.gif" height="16" width="16" class="'+c+'"/></a>')},e=f.find(g.sortable_area_sel),e.sortable({placeholder:"gp_drag_box",opacity:0.6,tolerance:"pointer",beforeStop:function(a,b){b.item.removeAttr("style").removeAttr("class")}}),e.disableSelection(),gp_editor.resetDirty(),strip_from(i,"?"),gp_editing.editor_tools(),
$("#ckeditor_top").html('<div id="gp_image_area"></div><div id="gp_upload_queue"></div>'),$("#ckeditor_controls").prepend('<div id="gp_folder_options"></div>'),LoadImages(!1),d=$('<span class="gp_gallery_edit gp_floating_area"></span>').appendTo("body").hide(),h(d,"gp_gallery_caption","page_edit"),h(d,"gp_gallery_rm","delete"),d.bind("mouseenter.gp_edit",function(){d.show()}).bind("mouseleave.gp_edit",function(){d.hide()}),m(),gplinks.gp_gallery_caption=function(a,b){b.preventDefault();d.hide();var c=
$(j),c=c.find(".caption").html()||c.find("a:first").attr("title"),c='<div class="inline_box" id="gp_gallery_caption"><form><h3>'+gplang.cp+'</h3><textarea name="caption" cols="40" rows="8">'+$gp.htmlchars(c)+'</textarea><p><input type="submit" name="cmd" value="'+gplang.up+'" class="gp_gallery_update" /> <input type="button" name="" value="'+gplang.ca+'" class="admin_box_close" /></p></form></div>';$gp.AdminBoxC(c)},gplinks.gp_gallery_rm=function(a,b){b.preventDefault();$(j).remove();d.hide()},gpinputs.gp_gallery_update=
function(a){a.preventDefault();var a=$(this.form).find("textarea").val(),b=$(j).find(".caption");b.html(a);a=b.html();$(j).find("a, img").attr("title",a);$gp.CloseAdminBox()},gplinks.gp_gallery_add=function(a,b){b.preventDefault();var c=$(this).stop(!0,!0);l(c.clone());c.parent().fadeTo(100,0.2).fadeTo(2E3,1)},gplinks.gp_gallery_add_all=function(a,b){b.preventDefault();$("#gp_gallery_avail_imgs a[name=gp_gallery_add]").each(function(){l($(this).clone())})},gpresponse.gp_gallery_images=function(){var a=
$("#gp_upload_form");a.attr("action");a.find(".file").auto_upload({start:function(b,a){a.bar=$('<a name="gp_file_uploading">'+b+"</a>").appendTo("#gp_upload_queue");a.holder=$('<li class="holder" style="display:none"></li>').appendTo(e);return!0},progress:function(b,a,e){b=Math.round(100*b);b=Math.min(98,b-1);e.bar.text(b+"% "+a)},finish:function(a,c,e){var d=e.bar;d.text("100% "+c);var f=$(a),a=f.find(".status").val(),f=f.find(".message").val();"success"==a?(d.addClass("success"),d.slideUp(1200),
c=$("#gp_gallery_avail_imgs"),c=$(f).appendTo(c).find("a[name=gp_gallery_add]"),l(c.clone(),e.holder)):"notimage"==a?d.addClass("success"):(d.addClass("failed"),d.text(c+": "+f))},error:function(a,c,d){alert("error: "+d)}})},gplinks.gp_file_uploading=function(){var a=$(this),b=!1;a.hasClass("failed")?b=!0:a.hasClass("success")&&(b=!0);b&&a.slideUp(700)},gpinputs.gp_gallery_folder_add=function(a,b){b.preventDefault();var c=this.form;LoadImages(c.dir.value+"/"+c.newdir.value)})};