function handleRemoveImage(){$$(".wj_images li").invoke("stopObserving","mouseover"),$$(".wj_images li").invoke("stopObserving","mouseout"),$$(".wj_images li").invoke("observe","mouseover",function(){$(this).select("span.delete-wrap").first().show()}),$$(".wj_images li").invoke("observe","mouseout",function(){$(this).select("span.delete-wrap").first().hide()}),$$(".wj_images li .delete").invoke("observe","click",function(){removeImage($(this).innerHTML),$(this).stopObserving("click")})}function setDefaultTheme(e){var t=e.up().previous(".wysija_theme").readAttribute("rel");return wysijaAJAX.task="setDefaultTheme",wysijaAJAX.theme=t,wysijaAJAX._wpnonce=wysijanonces.campaigns.setDefaultTheme,WYSIJA_AJAX_POST({success:function(){$$(".wj_themes .default").invoke("removeClassName","selected"),$(e).addClassName("selected")},loading_message:wysijatrans.theme_setting_default,success_message:wysijatrans.theme_saved_default}),!1}function handleRemoveTheme(){$$(".wj_themes li").invoke("stopObserving","mouseover"),$$(".wj_themes li").invoke("stopObserving","mouseout"),$$(".wj_themes li").invoke("observe","mouseover",function(){$(this).down("span.delete-wrap").show(),$(this).down("span.default-wrap").show()}),$$(".wj_themes li").invoke("observe","mouseout",function(){$(this).down("span.delete-wrap").hide(),$(this).down(".default-wrap").hide()}),$$(".wj_themes li .delete").invoke("observe","click",function(){removeTheme($(this).innerHTML),$(this).stopObserving("click")})}function handleDefaultTheme(){$$(".wj_themes li .default").invoke("observe","click",function(){$$(".wj_themes li .default.selected").length>0&&$$(".wj_themes li .default.selected").first().up().hide(),setDefaultTheme(this)})}function handleSwitchTheme(){$$("a.wysija_theme").invoke("observe","click",function(e){switchThemeWYSIJA(e)})}function removeTheme(e){return confirm(wysijatrans.abouttodeletetheme.replace("%1$s",e))&&($("wysija-theme-"+e).remove(),wysijaAJAX.task="deleteTheme",wysijaAJAX.themekey=e,wysijaAJAX._wpnonce=wysijanonces.campaigns.deleteTheme,WYSIJA_AJAX_POST()),!0}function removeImage(e){var t=wysijaIMG.unset(e);return void 0!==t&&$("wysija-img-"+e).remove(),saveIQS(),!0}function addImage(e){var t=new Element("img",{width:80,height:80,wysija_height:e.height,wysija_width:e.width,wysija_src:e.url,src:e.thumb_url}),i=new Element("a",{wysija_type:"image","class":"wysija_item"}).update(t),s=new Element("li",{id:"wysija-img-"+e.identifier,"class":"new"}).update(i);return s.insert('<span class="delete-wrap" style="display:none;"><span class="delete">'+e.identifier+"</span></span>"),s.insert('<span class="default-wrap" style="display:none;"><span class="default">'+e.identifier+"</span></span>"),$("wj-images-quick").insert({top:s}),handleRemoveImage(),wysijaIMG.set(e.identifier,e),saveIQS(),!0}function imagesTabPostHandler(){return updateImagesToolbarSize()}function updateImagesToolbarSize(){var e=document.viewport.getDimensions().height,t=$("wpadminbar").getLayout().get("margin-box-height"),i=$("wpfooter").getLayout().get("margin-box-height"),s=$("wj-images-quick"),a=s.getLayout(),n=$("wysija_toolbar").getLayout().get("margin-box-height")-a.get("margin-box-height"),o=$("wysija-app").getLayout(),r=o.get("margin-box-height")-o.get("height"),h=$("wpbody-content").getLayout().get("height")-o.get("margin-box-height"),l=e-t-i-n-r-h;s.setStyle({height:l+"px"})}var wysijaIMG=$H(),ajaxOver=!0;document.observe("dom:loaded",function(){void 0!=$("wysija-upload-browse")&&$("wysija-upload-browse").observe("click",function(){return WysijaPopup.open($(this).innerHTML,$(this).readAttribute("href2")),!1}),void 0!=$("wysija-themes-browse")&&$("wysija-themes-browse").observe("click",function(){return WysijaPopup.open($(this).innerHTML,$(this).readAttribute("href2")),!1}),void 0!=$("wysija_divider_settings")&&$("wysija_divider_settings").observe("click",function(){return WysijaPopup.open(wysijatrans.dividerSelectionTitle,$(this).readAttribute("href2")),!1}),handleRemoveImage(),handleRemoveTheme(),handleSwitchTheme(),handleDefaultTheme(),$$(".wysija_toolbar_tabs a").invoke("observe","click",function(){$$(".wysija_toolbar_tabs a").invoke("removeClassName","selected"),$$(".wj_images, .wj_content, .wj_styles, .wj_themes").invoke("hide"),$$(".wj_"+$(this).readAttribute("rel"))[0].show(),$(this).addClassName("selected");var e=window[$(this).readAttribute("rel")+"TabPostHandler"];return"function"==typeof e&&e(),!1}),Event.observe(window,"resize",function(){updateImagesToolbarSize()})});