ACMS.Dispatch=function(context){var Config=ACMS.Config;var Dispatch=arguments.callee;Dispatch.Utility(context);if(ACMS.Config.layout&&!ACMS.Dispatch.Layout.load)ACMS.Dispatch.Layout();$(Config.swfoMark,context).each(function(){Dispatch.swfobject(this)});if(ACMS.Config.eid){Dispatch.revisionIndex();Dispatch._revision()}$("a.updateTime",context).each(function(){Dispatch.updatetime(this)});$("a.updateDate",context).each(function(){Dispatch.updatedate(this)});$("#js-admin_action_box",context).each(function(){$("#adminBox",
this).removeClass("js-dragAdminBox")});$(":not(#js-admin_action_box) .js-dragAdminBox",context).each(function(){var $status=$.cookie("acms_config_admin_box_display_status");var $box=$(".js-dragAdminBox.normalBox");var $minBox=$(".js-dragAdminBox.minBox");$(this).draggable({cursor:"move",axis:"x",containment:"document",handle:".dragBoxHandle",opacity:0.7,drag:function(event,pr){var $disp="show";if($minBox.css("display")=="block")$disp="hide";$.cookie("acms_config_admin_box_display_status",$disp+":"+
pr.position.left,{path:"/"})}});if($status){$status=$status.split(":");var $display=$status[0];var $itemLeft=$status[1];if($display=="hide"){$minBox.css("left",parseInt($itemLeft));$box.hide();$minBox.show()}else{$box.css("left",parseInt($itemLeft));$minBox.hide();$box.show()}}else{$minBox.hide();$box.show()}});$(":not(#js-admin_action_box) .js-dragAdminBox .dragBoxToggle",context).each(function(){$(this).click(function(event){var $box=$(".js-dragAdminBox.normalBox");var $minBox=$(".js-dragAdminBox.minBox");
var $status="show:10";if($box.css("display")=="block"){var $itemLeft=$box.position().left+$box.width()-$minBox.width();if($itemLeft<0)$itemLeft=0;$minBox.css("left",$itemLeft);$box.slideUp(200,function(){$minBox.slideDown(200)});$status="hide:"+$itemLeft}else{var $itemLeft=$minBox.position().left-($box.width()-$minBox.width());if($itemLeft<0)$itemLeft=0;$box.css("left",$itemLeft);$minBox.slideUp(200,function(){$box.slideDown(200)});$status="show:"+$itemLeft}$.cookie("acms_config_admin_box_display_status",
$status,{path:"/"})})});$(".acms-admin-modal-show",context).each(function(){var target=$(this).data("target");var $target=$(context).find(target);if(!!$target.length){$target.addClass("out");$(this).click(function(){Dispatch.modal($target);return true})}});var $images=$(Config.ppMark,context),$caption;if($images.size()&&$(window).width()>Config.ppMinWindowSize&&(!Config.ppDisableMobile||!ACMS.Dispatch.Utility.browser().mobile)&&(!Config.ppDisableTablet||!ACMS.Dispatch.Utility.browser().tablet)){if(Config.ppCaption2Title)$images.each(function(){$caption=
$(this).parent().find("p.caption");if($caption.size())$(this).attr("title",$caption.text())});$images.prettyPhoto(Config.ppConfig)}else if(Config.ppWindowTarget)$images.attr("target",Config.ppWindowTarget);if($("pre").size()&&typeof ACMS.Library.googleCodePrettify==="function")ACMS.Library.googleCodePrettify();var $aImg=$(Config.adaptiveImageMark);if($aImg.size()){var resolved=false,$window=$(window);$aImg=$aImg.filter(function(){var $self=$(this),nowWidth=~~$self.attr("width"),baseWidth=~~$self.attr("data-width"),
src=$self.attr("src");return!(nowWidth>=baseWidth)&&src.indexOf("tiny-")!==-1});$window.resize(function(){if(!resolved&&$window.width()>Config.adaptiveImageSize){resolved=true;$aImg.each(function(i){var $self=$(this),width=~~$self.attr("data-width"),height=~~$self.attr("data-height"),src=$self.attr("src"),$div=$self.closest("div");if($div.get(0).className.indexOf("column-image-")!==-1)$div.css("width",width);$self.attr({width:width,height:height,src:src.replace("tiny-","")})})}}).resize()}$(Config.popupSettingMark,
context).each(function(){$(this).parent(".acms-admin-module-edit").show().parent().addClass("acms-admin-module-edit-wrapper");var $conf=Config.popupSettingConf;$(this).bind("click",function(){window.open(this.href,"popup_setting","width="+$conf.width+", height="+$conf.height+", status=no, scrollbars=yes");return false})});$(Config.moduleManagementMark,context).each(function(){$(this).parent(".acms-admin-module-edit").parent().addClass("acms-admin-module-edit-wrapper");$(this).bind("click",function(){var mid=
$(this).data("mid");edit=isFinite(mid)?"update":"insert";ACMS.Dispatch.showModuleDialog(edit,mid);return false})});var $moduleForm=$("#js-module_form");$(".js-module_form_trigger").unbind().bind("click",function(){$moduleForm.submit();return false});$moduleForm.bind("submit",function(){var $form=$(this),$modalBody=$form.closest(".acms-admin-modal-body"),$modal=$modalBody.closest("#js-module_management"),$iframe=$('iframe[name="js-ajaxPostData"]');$iframe.unbind().bind("load",function(){var res=$iframe.contents(),
$res=$(".acms-admin-modal-body",res);$modalBody.html($res.html());Dispatch($modal);$form[0].reset();if(!$(".acms-admin-alert.acms-admin-alert-danger").length&&!Config.layout)if(confirm(Config.moduleManagementReloadMsg))window.location.reload()})});$(".js-acms-tooltip",context).click(function(){Dispatch._tooltip(this);return false});$(".js-acms-tooltip-hover",context).hover(function(){Dispatch._tooltip(this,true);return false},function(){Dispatch._tooltip(this,false);return false});$.each(Config.hsArray.concat({mark:Config.hsMark,
config:Config.hsConfig}),function(){Config.hsConfig=this.config;$(this.mark,context).each(function(){Dispatch.highslide(this)})});$(Config.ckeMark,context).each(function(){Dispatch.ckeditor(this)});$.each(Config.biggerlinkArray.concat({mark:Config.biggerlinkMark,conf:Config.biggerlinkConf}),function(){Config.biggerlinkConf=this.conf;$(this.mark,context).each(function(){Dispatch.biggerlink(this)})});$.each(Config.bxsliderArray.concat({mark:Config.bxsliderMark,conf:Config.bxsliderConf}),function(){Config.bxsliderConf=
this.conf;$(this.mark,context).each(function(){Dispatch.bxslider(this)})});$.each(Config.autoHeightConfArray.concat({mark:Config.autoHeightMark}),function(){$(this.mark,context).each(function(){Dispatch.autoheight()})});Dispatch.autoheightR();$.each(Config.dpicArray.concat({mark:Config.dpicMark,config:Config.dpicConfig}),function(){Config.dpicConfig=this.config;$(this.mark,context).each(function(){Dispatch.datepicker(this)})});$(Config.fieldgroupSortableMark,context).each(function(){Dispatch.fieldgroupSortable(this)});
$.each(Config.emoArray.concat({mark:Config.emoMark,toolbar:Config.emoToolbar,config:Config.emoConfig}),function(){Config.emoToolbar=this.toolbar;Config.emoConfig=this.config;$(this.mark,context).each(function(){Dispatch.emoditor(this)})});var $s2dReady=$(ACMS.Config.s2dReadyMark,context);if($s2dReady.size()){var region="";if(ACMS.Config.s2dRegion)region="&region="+ACMS.Config.s2dRegion;ACMS.Library.googleLoadProxy("maps","3",{callback:function(){$s2dReady.each(function(){Dispatch._static2dynamic(this)})},
other_params:"sensor="+Config.Gmap.sensor+region})}$(Config.s2dMark,context).each(function(){Dispatch.static2dynamic(this)});var $s2dYolpReady=$(ACMS.Config.s2dYolpReadyMark,context);if($s2dYolpReady.size())ACMS.Library.yahooLoadProxy({callback:function(){$s2dYolpReady.each(function(){Dispatch._static2dynamic_yolp(this)})}});$(Config.s2dYolpMark,context).each(function(){Dispatch.static2dynamic_yolp(this)});$.each(Config.accordionArray.concat({mark:Config.accordionMark,config:Config.accordionConfig}),
function(){Config.accordionConfig=this.config;$(this.mark,context).each(function(){Dispatch.accordion(this)})});$.each(Config.tabsArray.concat({mark:Config.tabsMark,config:Config.tabsConfig}),function(){Config.tabsConfig=this.config;$(this.mark,context).each(function(){Dispatch.tabs(this)})});$.each(Config.acmsTabsArray.concat({mark:Config.acmsTabsMark,config:Config.acmsTabsConfig}),function(){Config.acmsTabsConfig=this.config;$(this.mark,context).each(function(){Dispatch.acmsTabs(this)})});$(Config.acmsAlertCloseMark,
context).each(function(){Dispatch.acmsAlertClose(this)});$.each(Config.acmsAlertCloseArray.concat({mark:Config.acmsAlertCloseMark,config:Config.acmsAlertCloseConfig}),function(){Config.acmsAlertCloseConfig=this.config;$(this.mark,context).each(function(){Dispatch.acmsAlertClose(this)})});$.each(Config.faderArray.concat({mark:Config.faderMark,config:Config.faderConfig}),function(){Config.faderConfig=this.config;$(this.mark,context).each(function(){Dispatch.fader(this)})});$.each(Config.toggleArray.concat({mark:Config.toggleMark,
config:Config.toggleConfig}),function(){Config.toggleConfig=this.config;$(this.mark,context).each(function(){Dispatch.toggle(this)})});try{if(1&&ACMS.Config.webStorage==="on"&&typeof localStorage!=="undefined"){var key=ACMS.Config.delStorage;if(key)if(ACMS.Config.webWtorageCapacity==="limitless")if(ACMS.Config.webStorageType==="session")sessionStorage.removeItem(key);else if(ACMS.Config.webStorageType==="local")localStorage.removeItem(key);else{sessionStorage.clear();localStorage.clear()}else{sessionStorage.clear();
localStorage.clear()}}}catch(e){}Dispatch.Postinclude(context);Dispatch.Linkmatchlocation(context);$(Config.validatorFormMark,context).each(function(){Dispatch.validator(this)});$(Config.rolloverImgMark,context).each(function(){Dispatch.rollover(this)});$(Config.scrollToMark,context).each(function(){Dispatch.scrollto(this)});$(Config.select2textMark,context).each(function(){Dispatch.select2text(this)});$(Config.zebraMark,context).each(function(){Dispatch.zebra(this)});$(Config.placeholderMark,context).each(function(){Dispatch.placeholder(this)});
if(!("placeholder"in document.createElement("input")))$("[placeholder]",context).each(function(){Dispatch.crossBrowserPlaceholder(this)});$(Config.incrementalSearchMark,context).each(function(){Dispatch.incrementalSearch(this)});$(Config.hoverMark,context).each(function(){Dispatch.hover(this)});$(Config.clickSelectionInputTextMark,context).each(function(){Dispatch.selection(this)});$(Config.countupMark,context).each(function(){Dispatch.countup(this)});$(Config.externalFormButtonMark,context).each(function(){Dispatch.ExternalSubmit(this)});
var $viewing=$('a[href="'+encodeURI(document.location.href)+'"]',context);if($viewing.size()){$viewing.filter(Config.viewingMark).each(function(){if($(this).attr("id"))return true;if($(this).parent().attr("id"))return true;$(this).parent().attr("id",Config.viewingId);$(this).parent().addClass(Config.viewingClass)});$viewing.filter(Config.viewingEraseMark).each(function(){var display=$(this).css("display");if(display.indexOf("block")!==-1)return true;$(this).after($(this).html());$(this).remove()})}var innerlinkPtn=
new RegExp("https?://("+Config.domains.replace(/,/g,"|")+")/");$(Config.linkOutsideBlankMark,context).each(function(){if(innerlinkPtn.exec(this.href))return true;$(this).attr("target","_blank")});if(1&&"https:"==document.location.protocol&&!location.href.match(/admin\/(.*)$/))$(Config.linkHttpsDisablerMark,context).each(function(){this.href=this.href.replace(/https:\/\//,"http://")});else $(Config.linkHttpsEnablerMark,context).each(function(){this.href=this.href.replace(/http:\/\//,"https://")});
$(".selectLink",context).change(function(){var url=$(":selected",this).val(),admin;if(url!==""&&url.indexOf("http")===0){if(location.href.match(/admin\/(.*)$/)){admin=RegExp.$1;if(admin.match(/^[a-z]+_edit\//))admin=admin.replace(/^([a-z]+)_(edit\/.*)$/,"$1_index");url=url.replace(/admin\/.*$/,"admin/"+admin)}location.href=url}}).show();if(Config.sid&&$.cookie(Config.session))$('a[href*="/'+Config.session+"/"+Config.sid+'"]',context).click(function(){this.href=this.href.replace("/"+Config.session+
"/"+Config.sid,"/"+Config.session+"/"+$.cookie(Config.session))});$(Config.observeFileSizeMark,context).each(function(){Dispatch._observefilesize(this)});if(Config.admin||$("#js-module_management").length)if($(':input[name^="ACMS_POST_Entry_Insert"], :input[name^="ACMS_POST_Entry_Update"], :input[name^="ACMS_POST_Form2_Update"], :input[name^="ACMS_POST_Entry_Add"]',context).size()){Dispatch.Edit(context);if(Config.admin==="entry_editor")Dispatch.Admin(context)}else Dispatch.Admin(context);if($(".js-edit_inplace",
context).length)ACMS.Load.Dispatch.Edit._inplace(function(){Dispatch.Edit(context)});if($(".js-direct-unit",context).length){$(".js-direct-unit",context).unbind("click");$(".js-direct-unit",context).click(function(){ACMS.Dispatch.Edit._direct(this);return false})}};
ACMS.Dispatch.Linkmatchlocation=function(context){var Config=ACMS.Config;var Linkmatchlocation=arguments.callee;$.each(Config.linkMatchLocationArray.concat({mark:Config.linkMatchLocationMark,type:"part",className:Config.linkMatchLocationClass},{mark:Config.linkMatchLocationFullMark,type:"full",className:Config.linkMatchLocationFullClass},{mark:Config.linkMatchLocationBlogMark,type:"blog",className:Config.linkMatchLocationBlogClass},{mark:Config.linkMatchLocationCategoryMark,type:"category",className:Config.linkMatchLocationCategoryClass},
{mark:Config.linkMatchLocationEntryMark,type:"entry",className:Config.linkMatchLocationEntryClass}),function(){var mark=this.mark;var type=this.type;Config.linkMatchLocationClass=this.className;$(mark,context).each(function(){Linkmatchlocation[type](this)})})};
ACMS.Dispatch.Postinclude=function(context){var Config=ACMS.Config;var Postinclude=arguments.callee;$.each(Config.postIncludeArray.concat({mark:Config.postIncludeOnsubmitMark,type:"submit",method:Config.postIncludeMethod,effect:Config.postIncludeEffect,effectSpeed:Config.postIncludeEffectSpeed},{mark:Config.postIncludeOnreadyMark,type:"ready",method:Config.postIncludeMethod,effect:Config.postIncludeEffect,effectSpeed:Config.postIncludeEffectSpeed,delay:Config.postIncludeReadyDelay},{mark:Config.postIncludeOnBottomMark,
type:"bottom",method:Config.postIncludeMethod,effect:Config.postIncludeEffect,effectSpeed:Config.postIncludeEffectSpeed,offset:Config.postIncludeOffset},{mark:Config.postIncludeOnIntervalMark,type:"interval",method:Config.postIncludeMethod,effect:Config.postIncludeEffect,effectSpeed:Config.postIncludeEffectSpeed,interval:Config.postIncludeIntervalTime}),function(){var type=this.type;Config.postIncludeMethod=this.method;Config.postIncludeEffect=this.effect;Config.postIncludeEffectSpeed=this.effectSpeed;
if(type==="bottom")Config.postIncludeOffset=this.offset;if(type==="interval")Config.postIncludeIntervalTime=this.interval;if(type==="ready")Config.postIncludeReadyDelay=this.delay;$(this.mark,context).each(function(){Postinclude[type](this)})})};
ACMS.Dispatch.ExternalSubmit=function(elm){var form=elm;if("undefined"!=typeof form.returnValue)if(!form.returnValue)return false;var target=form;if(form.target){var $target=$(form.target);if(!$target.size())return false;target=$target[0]}if($(target).size()){form.target="_self";$(target).click(function(){form.submit()})}else return false};
ACMS.Dispatch.scrollto=function(elm){$(elm).click(function(){var hash=elm.hash.slice(1),$target;var offset=$(elm).data("offset");var $setting={};if(!(typeof offset!="number"&&typeof offset!="string"))$setting={offset:offset};if(!!hash){$target=$('[name="'+hash+'"]'+", "+"#"+hash);ACMS.Library.scrollToElm($target,$setting)}else ACMS.Library.scrollToElm(null,$setting);return false})};ACMS.Dispatch.biggerlink=function(elm){(function(conf){$(elm).biggerlink(conf)})(ACMS.Config.biggerlinkConf)};
ACMS.Dispatch.bxslider=function(elm){(function(conf){$(elm).bxSlider(conf);$(elm).show()})(ACMS.Config.bxsliderConf)};ACMS.Dispatch.autoheight=function(){$(ACMS.Config.autoHeightConfArray).each(function(){for(var i in this)$(ACMS.Config.autoHeightMark+" "+i).autoheight({column:this[i],clear:1})})};
ACMS.Dispatch.autoheightR=function(){(function(conf){var timer=false,offset=conf.offset,style=conf.style==="height"?"height":"min-height";$(window).resize(function(){if(timer!==false)clearTimeout(timer);timer=setTimeout(function(){var $boxAry=$(ACMS.Config.autoHeightRMark),containerWidth=$boxAry.parent().width(),currentWidth=0,count=0,maxHeight=0,rowAry=[];$boxAry.css(style,0);_.each($boxAry,function(v){var $box=$(v),boxWidth=$box.outerWidth(true),tmpHeight=$box.outerHeight(true);if(containerWidth-
(currentWidth+boxWidth)<-1){_.each(rowAry,function(box){$(box).css(style,maxHeight+offset)});currentWidth=0;count=0;maxHeight=0;rowAry=[]}if(tmpHeight>maxHeight)maxHeight=tmpHeight;rowAry.push($box);currentWidth+=boxWidth;count++});_.each(rowAry,function(box){$(box).css(style,maxHeight+offset)})},200)}).trigger("resize")})(ACMS.Config.autoHeightRConf)};ACMS.Dispatch.datepicker=function(elm){(function(config){$(elm).datepicker(config)})(ACMS.Config.dpicConfig)};ACMS.Dispatch.accordion=function(elm){(function(config){$(elm).accordion(config)})(ACMS.Config.accordionConfig)};
ACMS.Dispatch.tabs=function(elm){(function(config){$(elm).tabs(config)})(ACMS.Config.tabsConfig)};
ACMS.Dispatch.acmsTabs=function(elm){(function(config){var $tabs=$();var $panels=$();var $expr=$("a[href^=#]",elm);$expr.each(function(){var panel=$(this).attr("href");$tabs=$tabs.add(this);$panels=$panels.add($(panel));$(this).addClass(config.tabClass);$(this).click(function(){$tabs.removeClass(config.activeClass);$(this).addClass(config.activeClass);$panels.hide();$(panel).show();return false})});$panels.hide();$expr.filter(":first").click();if(config.readyMark!=""&&"undefined"!=typeof config.readyMark){$expr.filter("a[href="+
config.readyMark+"]").click();$expr.filter(config.readyMark).click()}})(ACMS.Config.acmsTabsConfig)};ACMS.Dispatch.acmsAlertClose=function(elm){(function(config){$(elm).click(function(){var $alert=$(this).parent(config.target);$alert.remove()})})(ACMS.Config.acmsAlertCloseConfig)};
ACMS.Dispatch.fader=function(elm){(function(config){var $head=$(elm);var $body=$(elm.href.replace(/^[^#]+/,""));if("hide"==config.initial){$body.not(config.readyMark).hide();if("none"!=$body.css("display"))$head.addClass(config.activeClass)}else if("show"==config.initial)$body.show();$head.click(function(){if("slide"==config.effect)if("none"==$body.css("display")){$head.addClass(config.activeClass);$body.slideDown(config.speed)}else{$head.removeClass(config.activeClass);$body.slideUp(config.speed)}else if("fade"==
config.effect)if("none"==$body.css("display")){$body.fadeIn(config.speed);$head.addClass(config.activeClass)}else{$body.fadeOut(config.speed);$head.removeClass(config.activeClass)}return false})})(ACMS.Config.faderConfig)};
ACMS.Dispatch.toggle=function(elm){(function(config){var $head=$(elm).find(config.toggleHead);var $ready=$(elm).find(config.readyMark);var $hide=$(elm).find(config.hideMark);$ready.show();$hide.hide();$head.click(function(){if($ready.css("display")=="none")$hide.fadeOut(config.speed,function(){$ready.fadeIn(config.speed)});else $ready.fadeOut(config.speed,function(){$hide.fadeIn(config.speed)});return false})})(ACMS.Config.toggleConfig)};
ACMS.Dispatch.swfobject=function(elm){if(!$("dl.flashvars, dl.params, dl.attributes, dl.embed",elm).size())return true;var flashvars=ACMS.Library.dl2object($("dl.flashvars",elm));var params=ACMS.Library.dl2object($("dl.params",elm));var attributes=ACMS.Library.dl2object($("dl.attributes",elm));var embed=ACMS.Library.dl2object($("dl.embed",elm));swfobject.embedSWF(embed.swfUrlStr,$(elm).attr("id"),embed.widthStr,embed.heightStr,embed.swfVersionStr,ACMS.Config.jsRoot+"swfobject/expressInstall.swf",
flashvars,params,attributes)};
ACMS.Dispatch.revisionIndex=function(context){$(".js-get_revisions").unbind().bind("click",function(){var $revisionBox=$("#js-revision_index");var $backdrop=$(".acms-admin-modal-backdrop");var eid=ACMS.Config.eid;if(!$backdrop.length)$backdrop=$($.parseHTML('<div class="acms-admin-modal-backdrop"></div>')).hide().appendTo("body");var code='            <div id="js-edit_inplace-detail" class="acms-admin-modal out">                <div class="acms-admin-modal-dialog large">                    <div class="acms-admin-modal-content">                        <div class="acms-admin-modal-header">                            <i class="acms-admin-modal-hide acms-admin-icon-delete"></i>                            <h3>\u30d0\u30fc\u30b8\u30e7\u30f3\u4e00\u89a7</h3>                        </div>                        <div class="acms-admin-modal-body">                            <div class="acms-admin-padding-small"></div>                        </div>                    </div>                </div>            </div>';if(!$revisionBox.length)$revisionBox=
$($.parseHTML(code)).appendTo("body");else{$revisionBox.empty().remove();$revisionBox=$($.parseHTML(code)).appendTo("body")}$.ajax({type:"GET",url:ACMS.Library.acmsLink({eid:eid,tpl:"ajax/revision-index.html",Query:{hash:Math.random().toString()}},true),dataType:"html",success:function(res){$raw=$($.parseHTML(res));if($revisionBox.length){$("body").css("overflow","hidden");$revisionBox.find(".acms-admin-modal-body > .acms-admin-padding-small").append($raw);$revisionBox.show();$backdrop.show();setTimeout(function(){$revisionBox.removeClass("out").addClass("in")},
1)}ACMS.Config.postIncludeEffect="fade";ACMS.Dispatch($revisionBox);var closeFn=function(){$("body").css("overflow","");$backdrop.fadeOut();$revisionBox.removeClass("in").addClass("out");setTimeout(function(){$revisionBox.hide()},500);return false};$(".acms-admin-modal-hide").bind("click",closeFn);$revisionBox.click(function(event){var click=event.target;if($(click).hasClass("acms-admin-modal"))closeFn()})}})})};
ACMS.Dispatch.modal=function($modal){var $backdrop=$(".acms-admin-modal-backdrop");var $hideBtn=$(".acms-admin-modal-hide");if(!$backdrop.length)$backdrop=$($.parseHTML('<div class="acms-admin-modal-backdrop"></div>')).hide().appendTo("body");$("body").css("overflow","hidden");$modal.show();$backdrop.show();setTimeout(function(){$modal.removeClass("out").addClass("in")},1);var closeFn=function(){$("body").css("overflow","");$modal.removeClass("in").addClass("out");$backdrop.fadeOut();setTimeout(function(){$modal.hide()},
500)};$hideBtn.click(closeFn);$modal.click(function(event){var click=event.target;if($(click).hasClass("acms-admin-modal"))closeFn()})};
ACMS.Dispatch.showModuleDialog=function(type,mid,$indexTpl,callback){var query={edit:type,mid:mid},tpl;if(type=="insert")tpl="ajax/module/edit.html";else if(type==="index"){tpl="ajax/module/index.html";query={edit:type,mid:mid,tpl:$indexTpl}}else if(type==="update")tpl="ajax/module/edit.html";$.ajax({type:"GET",url:ACMS.Library.acmsLink({tpl:tpl,Query:query},true),dataType:"html",success:function(res){var $modalBox=$($.parseHTML(res)).appendTo("body"),$backdrop=$($.parseHTML('<div class="acms-admin-modal-backdrop"></div>')).hide().appendTo("body");
if($modalBox.length){$("body").css("overflow","hidden");setTimeout(function(){$backdrop.show();$modalBox.show();$modalBox.removeClass("out").addClass("in")},200);var zIndex=$(".acms-admin-modal-backdrop").length*1E5;$backdrop.css("z-index",zIndex);$modalBox.css("z-index",zIndex+1);ACMS.Dispatch($modalBox)}$(".acms-admin-modal-hide").bind("click",function(){closeFn($modalBox,$backdrop)});$modalBox.click(function(event){var click=event.target;if($(click).hasClass("acms-admin-modal"))closeFn($modalBox,
$backdrop)});$(".js-layout_select_module_id").bind("click",{modal:$modalBox,backdrop:$backdrop},selectModule);$(".js-acms_layout_edit_module, .js-acms_layout_create_module").unbind("click").bind("click",{modal:$modalBox},editModule)}});var selectModule=function(event){var mid=$(this).data("mid");var tpl=$(this).closest("tr").find("[name^=template]").val();$.ajax({type:"GET",url:ACMS.Library.acmsLink({tpl:"ajax/module/view.html",Query:{mid:mid,tpl:tpl,layout:"edit"}},true),dataType:"html",success:function(res){callback(res,
mid,tpl)},complete:function(){if(event.data)closeFn(event.data.modal,event.data.backdrop);else closeFn($indexTpl,$(".acms-admin-modal-backdrop"))}})};var editModule=function(event){var mid=$(this).data("mid"),edit=isFinite(mid)?"update":"insert";ACMS.Dispatch.showModuleDialog(edit,mid,event.data.modal,callback)};var closeFn=function($modalBox,$backdrop){var getMid=isFinite($(".getMid").val())?$(".getMid").val():mid;var query={mid:getMid};if($indexTpl)$.ajax({type:"GET",url:ACMS.Library.acmsLink({tpl:"ajax/module/index.html",
Query:query},true),dataType:"html",success:function(res){var $table=$indexTpl.find(".js-module_index_table"),$res=$(res).find(".js-module_index_table");$table.html($res.html());ACMS.Dispatch($indexTpl);$(".js-layout_select_module_id").bind("click",selectModule);$(".js-acms_layout_edit_module, .js-acms_layout_create_module").unbind("click").bind("click",{modal:$indexTpl},editModule)}});$("body").css("overflow","");window.location.hash="";$backdrop.fadeOut(150,function(){$backdrop.remove()});$modalBox.removeClass("in").addClass("out");
setTimeout(function(){$modalBox.remove()},500);return false}};ACMS.Dispatch.updatedate=function(elm){$(elm).click(function(){$("#"+$(elm).attr("rel")).val(date());return false});function date(){var D=new Date;var Y=D.getFullYear().toString();var m=(D.getMonth()+1).toString();var d=D.getDate().toString();if(1>=m.length)m="0"+m;if(1>=d.length)d="0"+d;return Y+"-"+m+"-"+d}};
ACMS.Dispatch.updatetime=function(elm){$(elm).click(function(){$("#"+$(elm).attr("rel")).val(time());return false});function time(){var d=new Date;var h=d.getHours().toString();var m=d.getMinutes().toString();var s=d.getSeconds().toString();if(1>=h.length)h="0"+h;if(1>=m.length)m="0"+m;if(1>=s.length)s="0"+s;return h+":"+m+":"+s}};
ACMS.Dispatch.rollover=function(elm){$(elm).each(function(){var s=elm.src;var i=s.lastIndexOf(".");if(0>i)i=s.length;var o=s.substring(0,i)+ACMS.Config.rolloverImgSuffix+s.substring(i);(new Image).src=o;elm.s=s;elm.o=o;$(elm).hover(function(){this.src=this.o},function(){this.src=this.s})})};
ACMS.Dispatch.static2dynamic=function(elm){function s2dMap(){var region="";if(ACMS.Config.s2dRegion)region="&region="+ACMS.Config.s2dRegion;ACMS.Library.googleLoadProxy("maps","3",{callback:function(){ACMS.Dispatch._static2dynamic(elm)},other_params:"sensor="+ACMS.Config.Gmap.sensor+region})}$(elm).click(function(){s2dMap()});window.setTimeout(function(){if(elm.getAttribute("width")>ACMS.Config.s2dMaxSize)s2dMap()},300)};ACMS.Dispatch.static2dynamic_yolp=function(elm){$(elm).click(function(){ACMS.Library.yahooLoadProxy({callback:function(){ACMS.Dispatch._static2dynamic_yolp(elm)}})})};
ACMS.Dispatch.validator=function(elm){$(ACMS.Config.validatorOverlookMark,elm).click(function(){$(this).addClass("js--clicked")});$(elm).submit(function(){return ACMS.Dispatch._validate(this)})};ACMS.Dispatch.select2text=function(elm){var self=elm;var aryValue=[];$elm=$(":selected",self);if(!$elm.size())$elm=$("option:first-child",self);$elm.each(function(){aryValue.push($(this).text())});$(self).replaceWith(aryValue.join(","))};
ACMS.Dispatch.zebra=function(elm){var tag=elm.tagName.toLowerCase();switch(tag){case "table":$("tr:nth-child(odd)",elm).addClass(ACMS.Config.zebraOddClass);$("tr:nth-child(even)",elm).addClass(ACMS.Config.zebraEvenClass);break;case "ul":case "ol":$("li:nth-child(odd)",elm).addClass(ACMS.Config.zebraOddClass);$("li:nth-child(even)",elm).addClass(ACMS.Config.zebraEvenClass);break;case "dl":$("dt:nth-child(odd)",elm).addClass(ACMS.Config.zebraOddClass);$("dt:nth-child(even)",elm).addClass(ACMS.Config.zebraEvenClass);
$("dd:nth-child(odd)",elm).addClass(ACMS.Config.zebraOddClass);$("dd:nth-child(even)",elm).addClass(ACMS.Config.zebraEvenClass);break}};
ACMS.Dispatch.placeholder=function(elm){var $self=$(elm);$.data(elm,"placeholder-string",$self.attr("title"));$.data(elm,"placeholder-color",$self.css("color"));switch($self.val()){case "":$self.val($.data(elm,"placeholder-string"));case $.data(elm,"placeholder-string"):$self.css("color",ACMS.Config.placeholderColor);break}$self.focus(function(){if($(this).val()==$.data(this,"placeholder-string")){$(this).val("");$(this).css("color",$.data(this,"placeholder-color"))}});$self.blur(function(){if($(this).val()==
""){$(this).val($.data(this,"placeholder-string"));$(this).css("color",ACMS.Config.placeholderColor)}});$self.parents().filter("form").submit(function(){if($self.val()==$.data(elm,"placeholder-string"))$self.val("");return true})};
ACMS.Dispatch.incrementalSearch=function(elm){var $target=$(elm);var $input=$(Config.incrementalSearchBoxMark);var $item=$(Config.incrementalSearchElementMark,elm);$input.keyup(function(){var search=this.value.split(" ");for(var i=0;i<$item.length;i++){var itemName=$($item[i]).text();if(itemName.match(new RegExp(search[0],"i"))){$($item[i]).show();if(search.length>1)for(var j=1;j<search.length;j++)if(!itemName.match(new RegExp(search[j],"i")))$($item[i]).hide()}else $($item[i]).hide()}return false});
if($input.val().length)$input.keyup()};
ACMS.Dispatch.crossBrowserPlaceholder=function(elm){var $self=$(elm),placeholderText=$self.attr("placeholder"),placeholderColor="#999",defaultColor=$self.css("color");$self.focus(function(){if($self.val()===placeholderText)$self.val("").css("color",defaultColor)}).blur(function(){if($self.attr("type")!=="password"&&$self.val().replace(/[\s\t\n\r]/g,"")==="")$self.val(placeholderText).css("color",placeholderColor);else if($self.val()===placeholderText)$self.css("color",placeholderColor)}).blur().parents("form").submit(function(){if($self.val()===
placeholderText)$self.val("")})};ACMS.Dispatch.hover=function(elm){(function(className){$(elm).hover(function(){$(this).addClass(className)},function(){$(this).removeClass(className)})})(ACMS.Config.hoverClass)};ACMS.Dispatch.selection=function(elm){$(elm).click(function(){$(this).select();return false})};
ACMS.Dispatch.countup=function(elm){$(elm).bind("keydown change",function(){var $self=$(this),length=$self.val().length,max=$self.data("max"),target=$self.data("label-target");$target=$(target),active=ACMS.Config.countupMarkOver;$target.html(length);if(length>max){$target.addClass(active);$self.addClass(active)}else{$target.removeClass(active);$self.removeClass(active)}}).trigger("change")};
ACMS.Dispatch.fieldgroupSortable=function(elm){var Config=ACMS.Config;var $sortable=$(elm);var $insert=$sortable.find(Config.fieldgroupSortableItemInsertMark);var $anchor=$sortable.find(Config.fieldgroupSortableItemTemplateMark);var $maxSize=$sortable.find(Config.fieldgroupSortableItemMaxMark).val();if($insert.size()&&$anchor.size()){var $template=$anchor.clone();$anchor.find(":input").attr("disabled","disabled");$anchor.hide();number($sortable);$insert.click(function(){if($maxSize==parseInt($maxSize)){var count=
$sortable.find(Config.fieldgroupSortableItemMark).size();if(count>$maxSize){alert(Config.fieldgroupSortableItemOverflowMessage1+$maxSize+Config.fieldgroupSortableItemOverflowMessage2);return false}}var $clone=$template.clone();var $map=$(".js-map-editable",$clone);if($map.size()){var region="";if(ACMS.Config.s2dRegion)region="&region="+ACMS.Config.s2dRegion;ACMS.Library.googleLoadProxy("maps","3",{callback:function(){$map.each(function(){ACMS.Dispatch.Edit.map(this)})},other_params:"sensor="+ACMS.Config.Gmap.sensor+
region})}var $yolp=$(".js-yolp-editable",$clone);if($yolp.size())ACMS.Library.yahooLoadProxy({callback:function(){$map.each(function(){ACMS.Dispatch.Edit.yolp(this)})}});var $addFormUnitTypeLabel=$("#formUnitType option:selected").text();var $addFormUnitTypeValue=$("#formUnitType option:selected").val();if($addFormUnitTypeValue&&$addFormUnitTypeLabel&&$clone.find(".form-label")){$clone.find(".form-label").text($addFormUnitTypeLabel);$clone.find('input[name*="formbuild_type"]').val($addFormUnitTypeValue);
switch($addFormUnitTypeValue){case "text":case "textarea":$clone.find(".select-value-box").hide();break;case "radio":case "select":case "multiSelect":case "checkbox":$block.find(".textTypeOnly").hide();break;default:$clone.find(".inputFormBody").hide();break}}$clone.removeClass(Config.fieldgroupSortableItemTemplateMark.substr(1));$clone.show();$clone.find(Config.fieldgroupSortableItemDeleteMark).click(function(){var msg=Config.fieldgroupSortableItemDeleteMessage;if(!msg.length||confirm(msg)){detouch($sortable);
$(this).parents(Config.fieldgroupSortableItemMark).remove();number($sortable);touch($sortable)}return false});$anchor.before($clone);number($sortable);$clone.find(Config.fieldgroupSortableItemHandleMark).css("cursor","pointer");ACMS.Dispatch($clone);return false});var n=0;$sortable.find(Config.fieldgroupSortableItemMark).each(function(){if("none"==$(this).css("display"))return true;n++});if(!n){var $clone=$template.clone();$clone.removeClass(Config.fieldgroupSortableItemTemplateMark.substr(1));$(':input[name$="]"]',
$clone).each(function(){this.name=this.name.replace(/\[\d*\]/,"[0]")});ACMS.Dispatch($clone);$anchor.before($clone)}$sortable.find(Config.fieldgroupSortableItemDeleteMark).click(function(){var msg=Config.fieldgroupSortableItemDeleteMessage;if(!msg.length||confirm(msg)){detouch($sortable);$(this).parents(Config.fieldgroupSortableItemMark).remove();number($sortable);touch($sortable)}return false})}$sortable.find(Config.fieldgroupSortableItemHandleMark).css("cursor","pointer");$sortable.sortable({items:Config.fieldgroupSortableItemMark,
handle:Config.fieldgroupSortableItemHandleMark,axis:"y",start:function(event,ui){detouch($sortable)},stop:function(event,ui){number($sortable);touch($sortable);ACMS.Dispatch($sortable)}});function touch(context){$.each(Config.emoArray.concat({mark:Config.emoMark,toolbar:Config.emoToolbar,config:Config.emoConfig}),function(){Config.emoToolbar=this.toolbar;Config.emoConfig=this.config;$(this.mark,context).each(function(){ACMS.Dispatch.emoditor(this)})})}function detouch(context){$("textarea",context).each(function(){var editor=
$(this).data("emoditor");if(editor)editor.destroy();$(this).removeData("emoditor")});return context}function number($sortable){var $rows=$sortable.find(Config.fieldgroupSortableItemMark).not(Config.fieldgroupSortableItemTemplateMark);var n=0;$rows.each(function(){$(':input[name$="]"]',this).each(function(){this.name=n+"-"+this.name});n++});n=0;$rows.each(function(){$(':input[name$="]"]',this).each(function(){this.name=this.name.replace(/\[\d*\]/,"["+n+"]")});n++});n=0;$rows.each(function(){var regex=
new RegExp("^"+n+"-");$(':input[name$="]"]',this).each(function(){this.name=this.name.replace(regex,"")});n++})}};
ACMS.Dispatch.acmsAdminTabs=function(elm){var $tabs=$();var $panels=$();var $expr=$("a[href^=#]",elm);function buildTab(panel){var $panel=$(panel);var hash=panel.replace(/^#/,"");$panels.hide();$panel.show();$("#js-tooltip").remove();if(location.hash!=panel){$panel.attr("id","");location.hash=panel;$panel.attr("id",hash)}$('textarea[name^="text_text_"]').trigger("keyup");return false}$expr.each(function(){var panel=$(this).attr("href");$tabs=$tabs.add(this);$panels=$panels.add($(panel));$(this).addClass("js-acms_tab");
$(this).click(function(){$tabs.removeClass("js-acms_tab-active");$(this).addClass("js-acms_tab-active");buildTab(panel);return false})});$panels.hide();if(_.contains(["blog_edit","user_edit","category_edit","module_edit"],ACMS.Config.admin)){setTimeout(function(){$(window).scrollTop(0)},200);if(!location.hash){$expr.filter(":first").click();$expr.filter("a[href=js-ready-acms_tabs]").click();$expr.filter(".js-ready-acms_tabs").click()}else{buildTab(location.hash);$expr.filter("a[href="+location.hash+
"]").addClass("js-acms_tab-active")}}else{$expr.filter(":first").click();$expr.filter("a[href=js-ready-acms_tabs]").click();$expr.filter(".js-ready-acms_tabs").click()}};
