navigation_blocked=false;last_date=0;bubbling_stack=[];last_event=null;originating_event=null;bubbling=false;end_bubbling="#contentHolder";end_bubbling2="div#contentHolder";css_backup=null;default_properties={"float":{container:"position"},clear:{container:"position"},display:{container:"position",clear:"true"},margin:{container:"position",hidden:"true",clear:"true"},"margin-left":{container:"position",hidden:"false"},"margin-right":{container:"position",hidden:"false"},"margin-top":{container:"position",hidden:"false"},"margin-bottom":{container:"position",hidden:"false"},position:{container:"position"},top:{container:"position",clear:"true"},right:{container:"position"},bottom:{container:"position"},left:{container:"position"},"z-index":{container:"position"},padding:{container:"dimensions",hidden:"true",clear:"true"},overflow:{container:"dimensions"},width:{container:"dimensions",clear:"true"},height:{container:"dimensions"},"font-size":{container:"text"},"line-height":{container:"text"},"font-family":{container:"text"},"text-align":{container:"text",clear:"true"},"list-style-type":{container:"text"},background:{container:"background"},opacity:{container:"background"},"-moz-box-shadow":{container:"background"},color:{container:"text"},"font-style":{container:"text"},"text-decoration":{container:"text"},"text-shadow":{container:"text"},"text-stroke":{container:"text"},"font-weight":{container:"text"},border:{container:"border"},"border-left":{container:"border",hidden:"true",clear:"true"},"border-right":{container:"border",hidden:"true"},"border-top":{container:"border",hidden:"true"},"border-bottom":{container:"border",hidden:"true"},"-moz-border-radius":{container:"border"},"padding-left":{container:"dimensions",hidden:"true",clear:"true"},"padding-right":{container:"dimensions",hidden:"true"},"padding-top":{container:"dimensions",hidden:"true"},"padding-bottom":{container:"dimensions",hidden:"true"}};iphone_fonts=["AppleGothic","HiraKakuProN-W6","HiraKakuProN-W3","ArialUnicodeMS","STHeitiK-Medium","STHeitiK-Light","DBLCDTempBlack","Helvetica-Oblique","Helvetica-BoldOblique","Helvetica","Helvetica-Bold","MarkerFelt-Thin","TimesNewRomanPSMT","TimesNewRomanPS-BoldMT","TimesNewRomanPS-BoldItalicMT","TimesNewRomanPS-ItalicMT","Verdana-Bold","Verdana-BoldItalic","Verdana","Verdana-Italic","Georgia-Bold","Georgia","Georgia-BoldItalic","Georgia-Italic","ArialRoundedMTBold","TrebuchetMS-Italic","TrebuchetMS","Trebuchet-BoldItalic","TrebuchetMS-Bold","STHeitiTC-Light","STHeitiTC-Medium","GeezaPro-Bold","GeezaPro","Courier","Courier-BoldOblique","Courier-Oblique","Courier-Bold","ArialMT","Arial-BoldMT","Arial-BoldItalicMT","Arial-ItalicMT","STHeitiJ-Medium","STHeitiJ-Light","ArialHebrew","ArialHebrew-Bold","CourierNewPS-BoldMT","CourierNewPS-ItalicMT","CourierNewPS-BoldItalicMT","CourierNewPSMT","Zapfino","AmericanTypewriter","AmericanTypewriter-Bold","STHeitiSC-Medium","STHeitiSC-Light","HelveticaNeue","HelveticaNeue-Bold","Thonburi-Bold","Thonburi"];skip_classes=["selected","hidden","widget_configuration","widget_content","ui-state-disabled","ui-sortable","ui-sortable-disabled","ui-draggable","ui-droppable","orderable","content_configuration","content_actions","offset-left","offset-top","offset-width","selected_item","action-configuration","dont-touch"];initialize_theming();function parse_html(){if(typeof theme=="undefined"){theme={}}css_tree={};var d="#contentHolder";var c=$("#contentHolder");forbidden_nodes={script:"",style:"",br:"",embed:"",object:""};var a=function(f){var g=$(f).attr("class");if(typeof g!="undefined"){g=g.split(" ").join(".")}for(var e=0;e<skip_classes.length;e++){g=g.replace(skip_classes[e],"")}g=g.replace(/^\.+|\.+$/g,"");return g};var b=function(j,f){if(j!="#contentHolder"){var p=$(j).parent()}var g=$(j).children();var k="";var n="";var o="";var m=((f!="")?f+" > ":"")+$(j)[0].nodeName.toLowerCase();m=m.replace(/\s{2,}/gi," ");var h=[];node_class=a(j);if(node_class!=""){m=m+"."+node_class}if(f!=""){css_tree[m]=(typeof theme[m]!="undefined")?theme[m]:{}}if($(j).attr("id")!=""){k=f+((f!="")?" > ":"div")+"#"+$(j).attr("id");h.push(k)}else{if(typeof node_class=="string"&&node_class!=""){k=m}else{k=m}}k=k.replace(/\s{2,}/gi," ");css_tree[k]=(typeof theme[k]!="undefined")?theme[k]:{};if(typeof node_class=="string"&&node_class!=""){n=m}if(typeof node_class=="string"&&node_class!=""){o=d+" "+$(j)[0].nodeName.toLowerCase()+"."+node_class}n=n.replace(/\s{2,}/gi," ");if((n!="")&&(n!=k)){if($(n).length>1){h.push(n);h[h.length]=n;css_tree[n]=(typeof theme[n]!="undefined")?theme[n]:{}}}h.push(m);if(h.length<2){h=null}$(j).data("selectors",h);for(var l=0;l<g.length;l++){var e=g[l];if(!($(e)[0].nodeName.toLowerCase() in forbidden_nodes)){b(e,k)}}};b(c,"")}function remove_white_spaces(){no_white_spaces={};for(var b in all_css){no_white_spaces[b]={};for(var e in all_css[b]){no_white_spaces[b][e]={};for(var c in all_css[b][e]){var d=c.replace(/\s{2,}/gi," ");try{no_white_spaces[b][e][d]=JSON.parse(JSON.stringify(all_css[b][e][c]))}catch(a){}}}}all_css=no_white_spaces}function reorder_css(){ordered_css=[];depth_index=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(var c in css_tree){var e=c.split(">");var d=e.length-1;if((e[e.length-1]).split("#").length>1){if(depth_index[d]>ordered_css.length){for(var a=ordered_css.length;a<depth_index[d];a++){ordered_css[a]=""}}ordered_css.splice(depth_index[d],0,c);for(var b=d+1;b<depth_index.length;b++){depth_index[b]++}}}for(var c in css_tree){var e=c.split(">");var d=e.length-1;if(depth_index[d]>ordered_css.length){for(var a=ordered_css.length;a<depth_index[d];a++){ordered_css[a]=""}}ordered_css.splice(depth_index[d],0,c);for(var b=d+1;b<depth_index.length;b++){depth_index[b]++}}}function clear_border_backup(){try{css_backup.elem=null}catch(a){}}function initialize_navigation(){unbind_content_containers();navigation_blocked=false;bind_elements();disable_widget_configuration();disable_structure();$(".content_configuration").addClass("hidden");$("#css_customization").addClass("hidden");$("#selector_container").addClass("hidden");$("#edit_menu").addClass("hidden");$(".hidden_configuration").addClass("hidden");initialize_ui_state();restore_outline();$("#style_only").trigger("click")}function initialize_content_customization(){bind_content_containers();navigation_blocked=false;bind_elements();disable_widget_configuration();disable_structure();$("#css_customization").addClass("hidden");$("#selector_container").addClass("hidden");$(".content_configuration.content").removeClass("hidden");$("#edit_menu").addClass("hidden");$("#all_pages").trigger("click");show_hidden_configuration();restore_outline();$("#structure_only").trigger("click")}function initialize_structure_mode(){unbind_content_containers();navigation_blocked=false;bind_elements();disable_widget_configuration();enable_structure();$(".content_configuration").addClass("hidden");$("#css_customization").addClass("hidden");$("#selector_container").addClass("hidden");$("#edit_menu").addClass("hidden");show_hidden_configuration();restore_outline();$("#structure_only").trigger("click")}function initialize_style_customization(){unbind_content_containers();navigation_blocked=true;bind_elements();disable_widget_configuration();disable_structure();$(".content_configuration").addClass("hidden");$(".content_configuration.style").removeClass("hidden");if(typeof view=="undefined"){$("#styling_structure").trigger("click")}show_hidden_configuration()}function save_structure_style(){for(var a in css_tree){$(a).data("background",$(a).css("background"));$(a).data("color",$(a).css("color"));if(!($(a).hasClass("selected_item"))){$(a).data("border",$(a).css("border"))}$(a).data("-moz-box-shadow",$(a).css("-moz-box-shadow"))}}function restore_structure_style(){try{clear_automagic()}catch(exception){}for(var elem in css_tree){var ui_elem=$(elem);var elem_type="";try{elem_type=$(ui_elem)[0].nodeName.toLowerCase()}catch(exception){}if(elem_type!="input"&&elem_type!="button"){eval('$("'+elem+"\").css({border:'none'})")}try{$(elem).css({background:$(elem).data("background")})}catch(exception){}try{$(elem).css({color:$(elem).data("color")})}catch(exception){}try{$(elem).css({border:$(elem).data("border")})}catch(exception){}try{$(elem).css("-moz-box-shadow",$(elem).data("-moz-box-shadow"))}catch(exception){}var changed_props=$(elem).data("changed_props");if(typeof changed_props!="undefined"){for(var i=0;i<changed_props.length;i++){var val=$(elem).data("changed_"+changed_props[i]);var changed_prop=changed_props[i];try{$(elem).css(changed_prop,val)}catch(exception){alert(exception)}}}}}function initialize_theming(){if(typeof theme=="undefined"){theme={}}if(typeof css_context=="undefined"){css_context="/"}all_css=JSON.parse(JSON.stringify(theme));view="normal";if(typeof theme["default"]!="undefined"){}if(typeof theme_id=="undefined"){theme_id="theme"}parse_html();clean_css();reorder_css();css_language_select="default";apply_css="default";$("#viewing_type .main_nav").click(function(){$("#viewing_type a").removeClass("view_selected");$(this).addClass("view_selected")});mode="navigate";save_structure_style();initialize_navigation();$(".main_nav").click(function(){$("#marketplace").addClass("hidden");$("#content_customization").addClass("hidden");$("#css_customization").addClass("hidden");$("#save_style").addClass("hidden");$("#edit_menu").addClass("hidden")});$("#navigate").click(function(){mode="navigate";initialize_navigation()});$("#structure").click(function(){mode="structure";initialize_structure_mode()});$("#customize").click(function(){mode="style";initialize_style_customization()});$("#customize_content").click(function(){mode="content";initialize_content_customization()});$("#view_design2",parent.document).click(function(){$("#customize").trigger("click")});remove_white_spaces();create_elem_table();$("embed").mouseup(function(){var a=$(this);$("#contentHolder").trigger("mouseup");while($(a).attr("id")==""){a=$(a).parent()}$(a).trigger("click")})}function bind_elements(){var b={"#container":"",body:"",".ui-draggable":"",".selected":""};if(typeof theme=="undefined"){theme={}}for(var a in css_tree){if(!(a in b)){if(navigation_blocked){$(""+a).each(function(){$(this).bind("click",{element:a,properties:default_properties,node:$(this)},bubbling_logic)})}else{$(""+a).each(function(){$(this).unbind("click",bubbling_logic);$(this).unbind("click",outline_element2)})}}}}function bubbling_logic(event){if(mode=="style"){$("#edit_menu").removeClass("hidden")}if(mode=="content"){$("#visibility_container").removeClass("hidden")}var bubbling_stack_checksum=function(){if(bubbling_stack.length==1){return true}for(var i=0;i<bubbling_stack.length;i++){var step=bubbling_stack[i];for(var property in step){count=step[property];if(count!=(bubbling_stack.length-i)){return false}}}return true};var update_bubbling_stack=function(elem){eval('bubbling_stack[bubbling_stack.length] = {"'+elem+'":0}');for(var i=0;i<bubbling_stack.length;i++){var step=bubbling_stack[i];for(var property in step){step[property]++}}};var in_bubbling_stack=function(elem){for(var i=0;i<bubbling_stack.length;i++){var step=bubbling_stack[i];for(var property in step){if(property==elem){return true}}}return false};var self=event.data.element;var properties=event.data.properties;var node=event.data.node;var elements=$(node).data("selectors");var not_bubbling=function(){originating_event=self;eval('bubbling_stack = [{"'+self+'":1}]');bubbling=false;if(elements!=null){var context_index=0;var context=elements[context_index];$(node).data("context_index",context_index);$(node).data("context",context);old_context=context;update_selector_text(context);outline_element2(selected_css);initialize_element_visibility(context);initialize_element_classes(context);$("#delete_element").bind("click",{elem:context},delete_element)}else{update_selector_text(self);outline_element2(selected_css);initialize_element_visibility(self);initialize_element_classes(self)}render_customization_controls(event);event.preventDefault();render_sms($(node));render_action($(node));return false};if(((originating_event==self))||bubbling){if(self==end_bubbling||self==end_bubbling2){update_selector_text(self);outline_element2(selected_css);initialize_element_visibility(self);initialize_element_classes(self);$("#delete_element").bind("click",{elem:self},delete_element);originating_event=null;bubbling_stack=[];bubbling=false;render_customization_controls(event);event.preventDefault();render_sms($(node));render_action($(node));return false}bubbling=true;if(bubbling_stack_checksum()){if(in_bubbling_stack(self)||skip){skip=false;return true}else{if(elements!=null){var context_index=0;var context=elements[context_index];$(node).data("context_index",context_index);$(node).data("context",context);update_selector_text(context);outline_element2(selected_css);initialize_element_visibility(context);initialize_element_classes(context);$("#delete_element").bind("click",{elem:context},delete_element)}update_bubbling_stack(self);render_customization_controls(event);bubbling=true;event.preventDefault();render_sms($(node));render_action($(node));return false}}}return not_bubbling()}function update_existing_selectors(c){var a=$(c).data("elem_key");$("#existing_selectors").empty();if(typeof element_css_table[a]!="undefined"){for(var b=0;b<element_css_table[a].length;b++){var d=$("<option value='"+element_css_table[a][b]+"'>"+element_css_table[a][b]+"</option>");$("#existing_selectors").append(d)}$("#existing_selectors").change(function(){$("#css_selector_preview").val($(this).val()).trigger("keyup")});$("#existing_selectors").trigger("change")}}function render_customization_controls(e){clear_controls();var d=e.data.node;var c=e.data.element;if(typeof $(d).data("context")!="undefined"){c=$(d).data("context").split(".ui-droppable")[0].split(".ui-draggable")[0]}var b=current_css_hierarchy;var a=e.data.properties;render_control(b);$(".css_link:first").trigger("click");$("#css_menu").removeClass("hidden");$("#css_selector").removeClass("hidden")}function update_color_elem(c){var d=function(e){$(b).val(e);$(b).trigger("keyup")};var b=c.data.elem;var a=$.farbtastic($("#colorpicker"));a.linkTo(d)}function update_image_elem(d){var c=d.data.elem;var a=d.data.container;var b=function(e,f){$(c).val("url("+$("img",$(f.draggable)).attr("src")+")");$(c).trigger("keyup")};$("[container='true']").each(function(){$(this).droppable("destroy")});$(a).droppable({accept:".pic",drop:b,})}function create_property_control(o,n,h,l,c){if(typeof l=="undefined"){l=false}if(typeof c=="undefined"){c=true}selected_css=selected_css.replace(/\s{2,}/gi," ");var j=null;if(n!=""){j=$("<div class='property "+o+" current'><span class='prop_name'>"+o+"</span></div>")}else{j=$("<div class='property "+o+"'><span class='prop_name'>"+o+"</span></div>")}var f=null;var a=null;try{n=n.trim()}catch(b){}var m=true;switch(o){case"color":f=$("<input type='text' style='width:5em' name='color_selection'></input>");$(f).bind("click",{elem:f},update_color_elem);if(n!=""){try{$(f).val(rgb2hex(n))}catch(b){$(f).val(n)}}else{var e=n;$(f).val(e)}$(f).bind("keyup",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("change",{val:$(f),prop:o,elem:h},update_preview);break;case"background":f=$("<input type='text'></input>");update_image_elem({data:{elem:$(f),container:$("#contentHolder")}});update_color_elem({data:{elem:$(f)}});if(n!=""){try{$(f).val(rgb2hex(n))}catch(b){$(f).val(n)}}else{var e=n;if(match_rgbcolor(e)){e=rgb2hex(e)}$(f).val(e)}$(f).bind("keyup",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);break;case"display":f=$("<select><option value='select'>select...</option><option value='block'>block</option><option value='inline'>inline</option><option value='none'>none</option></select>");$(f).val(n);$(f).bind("change",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);m=false;break;case"position":f=$("<select><option value='select'>select...</option><option value='relative'>relative</option><option value='fixed'>fixed</option><option value='absolute'>absolute</option></select>");$(f).val(n);$(f).bind("change",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);break;case"float":f=$("<select attr='aaa'><option value='select'>select...</option><option value='left'>left</option><option value='right'>right</option><option value='none'>none</option></select>");$(f).val(n);$(f).bind("change",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);m=false;break;case"clear":f=$("<select><option value='select'>select...</option><option value='none'>none</option><option value='left'>left</option><option value='right'>right</option></select>");$(f).val(n);$(f).bind("change",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);m=false;break;case"font-family":f=$("<select><option value='select'>select...</option></select>");for(var g=0;g<iphone_fonts.length;g++){var k=iphone_fonts[g];var d=$("<option value='"+k+"'>"+k+"</option>");$(f).append(d)}$(f).val(n);$(f).bind("change",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);break;case"font-weight":f=$("<select><option value='select'>select...</option><option value='normal'>normal</option><option value='bold'>bold</option></select>");$(f).val(n);$(f).bind("change",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);break;case"font-style":f=$("<select><option value='select'>select...</option><option value='normal'>normal</option><option value='italic'>italic</option></select>");$(f).val(n);$(f).bind("change",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);break;case"overflow":f=$("<select><option value='select'>select...</option><option value='hidden'>hidden</option><option value='auto'>auto</option><option value='scroll'>scroll</option></select>");$(f).val(n);$(f).bind("change",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);break;case"list-style-type":f=$("<select><option value='select'>select...</option><option value='none'>none</option><option value='circle'>circle</option><option value='disc'>disc</option><option value='square'>square</option></select>");$(f).val(n);$(f).bind("change",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);break;case"padding":case"margin-top":case"margin-left":case"margin-right":case"margin-bottom":case"padding-left":case"padding-right":case"padding-bottom":case"padding-top":case"top":case"right":case"bottom":case"left":case"opacity":case"margin":case"-moz-border-radius":case"line-height":case"text-stroke":case"z-index":f=$("<input type='text' style='width:6em'></input>");if(n!=""){$(f).val(n)}else{var e=n;$(f).val(e)}$(f).bind("keyup",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);break;case"width":case"height":case"font-size":f=$("<input type='text' style='width:6em'></input>");if(n!=""){$(f).val(n)}else{var e=n;$(f).val(e)}$(f).bind("keyup",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);m=false;break;case"text-align":f=$("<select><option value='select'>select...</option><option value='left'>left</option><option value='right'>right</option><option value='center'>center</option><option value='justify'>justify</option></select>");$(f).val(n);$(f).bind("change",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);break;case"border":case"border-left":case"border-right":case"border-top":case"border-bottom":case"text-decoration":case"text-shadow":case"-moz-box-shadow":f=$("<input type='text'></input>");$(f).val(n);$(f).bind("keyup",{val:$(f),prop:o,elem:h},update_preview);$(f).bind("blur",{val:$(f),prop:o,elem:h},update_preview);break}$(j).append(f);try{$(j).append(a)}catch(b){}try{$(j).append(color_palette)}catch(b){}if(!c){$("input,select",$(j)).attr("disabled","disabled")}$(".show_image_selector").click(function(){$("#image_media_conf").removeClass("hidden")});return j}function clear_controls(){$("#css_customization div.css_elem").empty()};