var colorpicker=null;jQuery(function(a){function e(){a("#title_position_block")["title"===a('input[name="post_content"]:checked').val()?"hide":"show"](),a("#title_tag_list")["title"===a('input[name="post_content"]:checked').val()?"show":"hide"](),0<a("#advanced:visible").length&&(0<a("#title_tag_list:hidden").length&&"list"===a('input[name="title_tag"]:checked').val()&&a('input[name="title_tag"][value="h2"]').attr("checked","checked"),"list"===a('input[name="title_tag"]:checked').val()?t(["image","author","category","readmore","divider","bgcolor"]):n(["image","author","category","readmore","divider","bgcolor"]))}function t(e){a.each(e,function(e,t){a("#"+t+"-block").hide()})}function n(e){a.each(e,function(e,t){a("#"+t+"-block").show()})}function i(){a("#image_block")[0<a('input[name="title_tag"][value="list"]:checked').length?"hide":"show"]()}function o(){var e=a('input[name="image_alignment"]:checked').val(),t=!0,n=32,i=325;"center"===e?i=564:"none"===e&&(t=!1),!0===t?(a("#image_width_block").show(),l(),slider.range=$R(n,i),slider.setValue(slider.value)):a("#image_width_block").hide()}function l(){var e=32,t=564,n=Math.min(Math.max(e,parseInt(a("#slider_info span").html())),t);slider=new Control.Slider("slider_handle","image_width_slider",{range:$R(e,t),slideValue:n,axis:"horizontal",onSlide:function(e){var t=parseInt(e,10);a("#slider_info").find("span").html(t),a("#image_width").val(t)},onChange:function(e){var t=parseInt(e,10);a("#slider_info").find("span").html(t),a("#image_width").val(t)}}),slider.setValue(n)}function c(){null===colorpicker&&(colorpicker=!0,a("input.color").modcoder_excolor({hue_bar:1,border_color:"#969696",anim_speed:"fast",round_corners:!1,shadow_size:2,shadow_color:"#f0f0f0",background_color:"#ececec",backlight:!1,label_color:"#333333",effect:"fade",show_input:!1,z_index:2e4,callback_on_open:function(){a("html, body").animate({scrollTop:a("#modcoder_colorpicker_wrapper:visible").offset().top},200)}}))}a("#toggle-advanced").toggle(function(){return a(this).html(wysijatrans.hide_advanced),a("#advanced").show(),l(),e(),o(),i(),c(),a(this).blur(),window.parent.WysijaPopup.setDimensions(),!1},function(){return a(this).html(wysijatrans.show_advanced),a("#advanced").hide(),a(this).blur(),window.parent.WysijaPopup.setDimensions(),!1}),a("#autopost-submit").click(function(){var t=[],n=["readmore","author_label","category_label"];return a("#autopost-form").serializeArray().each(function(e){n.include(e.name)&&(e.value=window.parent.Wysija.encodeHtmlValue(e.value)),t.push(e)}),wysijaAJAX.task="generate_auto_post",wysijaAJAX.wysijaData=t,jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(e){e.result!==undefined&&""!==e.result?window.parent.WysijaPopup.success(e.result):window.parent.WysijaPopup.cancel()}}),!1}),a('input[name="image_alignment"]').click(function(){o()}),a('input[name="post_content"]').click(function(){e(),i(),o()}),a('input[name="title_tag"]').click(function(){e(),i(),o()}),a("#post_type").change(function(){return a(".category_ids").val("").trigger("change"),!1}),a(function(){l(),e(),o(),i()})});