function initialize_css_customization(){$(".container_selection").click(function(){$(".mode").addClass("hidden");$("#css_customization").removeClass("hidden")});$("#css").click(function(){$("#style_all_pages").trigger("click");$("#css_styling_container").removeClass("hidden")});$("#content").click(function(){$("#sms2").removeClass("hidden")});$("#action").click(function(){$("#action_container").removeClass("hidden")});$("#scope").click(function(){$("#scope_container").removeClass("hidden")});$("#css_classes").click(function(){$("#css_classes_container").removeClass("hidden")});$("#selected_element").click(function(){$("#selector_container").removeClass("hidden")});$("#selector").click(function(){show_selector_view()});$(".show_color_palette").click(function(){$("#open_color_chooser").trigger("click")});$("#style_this_page").click(function(){apply_css=css_context;$(this).addClass("selected");$("#style_all_pages").removeClass("selected")});$("#style_all_pages").click(function(){apply_css="default";$(this).addClass("selected");$("#style_this_page").removeClass("selected")});$("#css_language_select").append($("<option value='default'>all languages</option>"));for(var f=0;f<languages.length;f++){var b=languages[f];for(var d in b){var e=d,g=b[d];if(e!="default"){var c=$("<option value='"+e+"'>"+g+"</option>");$("#css_language_select").append(c)}}}$("#css_language_select").change(function(){css_language_select=$(this).val();render_control(current_css_hierarchy)});$("#css_context_select").change(function(){apply_css=$(this).val();render_control(current_css_hierarchy)});$("#edit_css_path").click(function(){$("#selector_container").removeClass("hidden")});$("#this_page_option").attr("value",css_context);$("#show_text_css").click(function(){$(this).addClass("hidden");$("#show_form_css").removeClass("hidden");$("#css_configuration").addClass("hidden");$("#css_textarea").removeClass("hidden")});$("#show_form_css").click(function(){$(this).addClass("hidden");$("#show_text_css").removeClass("hidden");$("#css_configuration").removeClass("hidden");$("#css_textarea").addClass("hidden")})}function show_selector_view(){$("#css_styling_container").addClass("hidden");$("#sms2").addClass("hidden");$("#selector_container").removeClass("hidden")}function create_css_menu(){var a="";var b=function(h){$(".css_option").removeClass("css_selected");$(h.data.elem).addClass("css_selected");var g=$(".property."+$(h.data.elem).attr("links_to"));$(g).removeClass("hidden");$(g).parent().prepend($(g));control=create_property_control(h.data.prop,"",current_css_hierarchy,false);$(".property").each(function(){if(!$(this).hasClass("current")){$(this).remove()}});$("#"+$(h.data.elem).attr("container")).append(control)};for(prop in default_properties){var e=$("<a class='hidden css_option' links_to='"+prop+"' container='"+default_properties[prop].container+"'>"+prop+"</a>");$(e).bind("click",{elem:$(e),container:default_properties[prop].container,prop:prop},b);$("#option_selectors").append(e);a=default_properties[prop].container}var d=function(i){var h=i.data.elem;var g=$(h).attr("container");$(".css_option").addClass("hidden");$("a[container='"+g+"']").removeClass("hidden");$(".property").addClass("hidden");$("#css_menu .button").removeClass("mouseover");$(h).addClass("mouseover");$("#no_css").addClass("hidden");$(".css_option").removeClass("css_selected")};$("#css_menu .button").each(function(){$(this).bind("click",{elem:$(this)},d)});$("#current_styling").click(function(){$("#no_css").removeClass("hidden");$(".current").removeClass("hidden");$("#current").removeClass("hidden");if($(".current",$("#css_configuration")).length>0){$("#no_css").addClass("hidden")}});var c=function(h){var g=h.data.elem;$(".css_option").removeClass("mouseover");$(g).addClass("mouseover")};var f=function(g){$(".css_option").removeClass("mouseover")};$(".css_option").each(function(){$(this).bind("mouseover",{elem:$(this)},c);$(this).bind("mouseout",{elem:$(this)},f)})}function save_changed_css(){var a=$("#css_textarea").data("css_store");a=$("#css_textarea").val()}function render_control2(b){$("#css_textarea").attr("applies_to",b);if(typeof all_css[apply_css]=="undefined"){all_css[apply_css]={}}if(typeof all_css[apply_css][css_language_select]=="undefined"){all_css[apply_css][css_language_select]={}}if(all_css[apply_css][css_language_select][b]!="undefined"){$("#css_textarea").data("css_store",all_css[apply_css][css_language_select][b]);if(typeof all_css[apply_css][css_language_select][b]=="string"){$("#css_textarea").val(all_css[apply_css][css_language_select][b])}else{var a="";for(var c in all_css[apply_css][css_language_select][b]){if(all_css[apply_css][css_language_select][b][c]!=""){a+=c+":"+all_css[apply_css][css_language_select][b][c]+";\n"}}$("#css_textarea").val(a)}}else{$("#css_textarea").val("")}$("#css_textarea").bind("keyup",{},update_preview2);$("#css_textarea").bind("blur",{},update_preview2);$("#css_textarea").bind("change",{},update_preview2)}function update_preview(a){$(a.data.val).parent().addClass("current");$(".property.current").each(function(){var f=$(".prop_name",$(this)).html();var e=$(".prop_name",$(this)).next().val();var d=$("#css_textarea").val();var c=new RegExp(f+":[\\w\\s#%\\(\\)\\-,\\.]+;");var b=d.match(c);if(b!=null){$("#css_textarea").val(d.replace(b[0],f+":"+e+";"))}else{$("#css_textarea").val(d+=f+":"+e+";\n")}});update_preview2()}function update_preview2(){var selector=$("#css_textarea").attr("applies_to");var css=$("#css_textarea").val().replace(/\n{2,}/,"\n");var properties=css.split(";");for(var i=0;i<properties.length;i++){var property=properties[i].replace(/\n/gi,"").trim();if(property!=""){var tokens=property.split(":");if(tokens.length==2){tokens[0]=tokens[0].replace(/\n/gi,"");tokens[1]=tokens[1].replace(/\n/gi,"");eval("$('"+selector+"').css({'"+tokens[0]+"':'"+tokens[1]+"'})");if(tokens[0]=="width"||tokens[0]=="height"){$(selector).data(tokens[0],tokens[1]);$(selector).data("fixed_"+tokens[0],"fixed_"+tokens[1])}}}}all_css[apply_css][css_language_select][selector]=css}function render_control(e){$(".property").remove();temp_view=view;var d={name:null};var c=(typeof apply_css!="undefined")?apply_css:"default";var a=function(k,i,h){if(typeof h=="undefined"){h=true}if(k in default_properties){var j=default_properties[k]["container"];var f=$("#"+j);var g=create_property_control(k,i,e,false,h);if($("."+k).length>0){$("."+k).remove()}$(f).append(g)}};var b=function(k,h){if(typeof h=="undefined"){h=true}if(typeof k=="string"){var g=k.split(";");for(var f=0;f<g.length;f++){var j=g[f].replace(/\n/gi,"").trim();if(j!=""){var l=j.split(":");if(l.length==2){l[0]=l[0].replace(/\n/gi,"");l[1]=l[1].replace(/\n/gi,"");a(l[0],l[1],h)}}}}else{for(var m in k){a(m,k[m],h)}}};if(typeof all_css.preset!="undefined"){b(all_css.preset["default"][e])}if(typeof all_css[apply_css]!="undefined"&&typeof all_css[apply_css][css_language_select]!="undefined"){b(all_css[apply_css][css_language_select][e])}$(".css_option.css_selected").trigger("click");$("#current_styling").trigger("click");render_control2(e)};