jQuery(document).ready(function(a){a("input.upload_button").live("click",function(){var b=a(this).prev(),c=a(this);tb_show("","media-upload.php?post_id=0&type=image&TB_iframe=true&width=700");window.send_to_editor=function(d){imgurl=a("a","<div>"+d+"</div>").attr("href");b.val(imgurl);b.change();c.hasClass("upload-button")||($image_preview=b.parents(".sortItem").find(".ss-ImageSample"),0<$image_preview.length&&$image_preview.attr("src",imgurl));tb_remove()};return!1});var e=function(){var b=a(this).children("option:selected").text();
    ""==b&&(b=a(this).children().children("option:selected").text());0>=a(this).parent().find("span").length&&a(this).before("<span></span>");a(this).parent().children("span").replaceWith("<span>"+b+"</span>")};a(".select_wrapper select").each(e).change(e);a(".upload_img_url").change(function(){var b=a(this).val(),c=a(this).parent().siblings(".upload_img_preview");/(http|ftp|https):\/\/[a-zA-Z0-9@?^=%&amp;:/~+#-_.]*.(gif|jpg|jpeg|png|ico)/.test(b)?c.html('<img src="'+b+'" style="max-width:600px; max-height:300px;" />'):
    c.html("")}).change();a(".submit [type=submit]").on("click",function(){a(".wp-editor-wrap.tmce-active .switch-html").click(function(){a(this).addClass("yit_switch_changed")}).click();a(".yit_switch_changed").removeClass("yit_switch_changed").next().click()});a(".typography_container").yit_panel_typography();a(".number_container .number").each(function(){var b=a(this).data("min")?a(this).data("min"):null,c=a(this).data("max")?a(this).data("max"):null;value=a(this).val();a(this).spinner({min:b,max:c,
    defaultValue:value,interval:1})});a(".onoff_container span").on("click",function(){var b=a(this).prev("input");b.attr("checked")?b.attr("checked",!1).attr("value",0).removeClass("onoffchecked"):b.attr("checked",!0).attr("value",1).addClass("onoffchecked");b.change()});a(".slider_container .ui-slider-horizontal").each(function(){var b=a(this).data("val"),c=a(this).data("min"),d=a(this).data("max"),f=a(this).data("step"),g=a(this).data("labels");a(this).slider({value:b,min:c,max:d,range:"min",step:f,
    slide:function(b,c){a(this).find("input").val(c.value);a(this).siblings(".feedback").find("strong").text(c.value+g)}})});a(".rm_colorpicker .colorpicker_container").each(function(){var b=a(this).data("color"),c=a(this);a(this).ColorPicker({color:b,onShow:function(b){a(b).fadeIn(500);return!1},onHide:function(b){a(b).fadeOut(500);return!1},onChange:function(a,b){c.find("div").css("backgroundColor","#"+b);c.next("input").attr("value","#"+b)}})});a(".rm_bg-preview").each(function(){var b=a(this);a(this).attr("id");
    ("custom"==b.find("select").val()||""==a(this).find("select").val())&&b.find(".bg-preview div").hide();a(this).find("select").change(function(){"custom"==a(this).val()||""==a(this).val()?b.find(".bg-preview div").hide():b.find(".bg-preview div").css("background-image","url("+a("option:selected",this).val()+")").show()});var c=b.find(".colorpicker_container div").css("background-color"),d=b.find(".colorpicker_container");d.ColorPicker({color:c,onShow:function(b){a(b).fadeIn(500);return!1},onHide:function(b){a(b).fadeOut(500);
        return!1},onChange:function(b,c){a(d).find("div").css("backgroundColor","#"+c);a(d).next("input").attr("value","#"+c)}})});a(".rm_connectedlist").each(function(){var b=a(this).find("ul"),c=a(this).find(":hidden");b.sortable({connectWith:b,update:function(){var d={};b.each(function(){var b={};a(this).children().each(function(){b[a(this).data("option")]=a(this).text()});d[a(this).data("list")]=b});c.val(JSON.stringify(d).replace(/[\\"']/g,"\\$&").replace(/\u0000/g,"\\0"))}}).disableSelection()})});
