ACMS.Dispatch.Utility=function(context){var Config=ACMS.Config;if(Config.unitFixAlign!="off"){$("div[class^=column-image], div[class^=column-file], div[class^=column-eximage]",context).each(function(){var $img=$("img",this);var width=$img.width();var offset=$img.outerWidth()-width;var style=$(this).attr("style");if(ACMS.Dispatch.Utility.browser().ltIE9)width=parseInt($img.attr("width"));if(width&&style===void 0&&!$(this).hasClass("js_notStyle"))$(this).width(width+offset);if(!$(this).next(".caption").size())$(this).addClass("nocaption")});
$("[class^=column-youtube-], [class^=column-video-]",context).each(function(){var $video=$("iframe",this);var width=$video.attr("width");var style=$(this).attr("style");if(width&&style===void 0&&!$(this).hasClass("js_notStyle"))$(this).width(width)});$("[class^=column-map], [class^=column-yolp]",context).each(function(){var region="";if(ACMS.Config.s2dRegion)region="&region="+ACMS.Config.s2dRegion;ACMS.Library.googleLoadProxy("maps","3",{callback:function(){var style=$(this).attr("style");if(style===
void 0&&!$(this).hasClass("js_notStyle"))$(this).width($(":first-child",this).width())}})});if(ACMS.Dispatch.Utility.browser_ie6()&&!$.boxModel){$(".column-image-center, .column-file-center, .column-youtube-center, .column-eximage-center, .column-media-center",context).css("width","100%");$(".column-map-center",context).wrap('<div style="text-align:center; width:100%"></div>')}}if(Config.unitGroupAlign){var timer;var clearClass=Config.unitGroupAlignClass;$(window).resize(function(){var $unitGroup=
$(Config.unitGroupAlignMark),containerWidth=$unitGroup.parent().width(),currentWidth=0,count=0;clearTimeout(timer);timer=setTimeout(function(){_.each($unitGroup,function(v){var $unit=$(v),unitW=$unit.outerWidth(true)-1;$unit.removeClass(clearClass);if(!$unit.prev().hasClass(Config.unitGroupAlignMark.substring(1))){currentWidth=0;count=0}if(1&&count>0&&containerWidth-(currentWidth+unitW)<-1){$unit.addClass(clearClass);currentWidth=unitW;count=1}else{currentWidth+=unitW;count++}})},Config.unitGroupAlignInterval)}).trigger("resize")}if(Config.keyword&&
!Config.admin){var searchKeywordTag=Config.searchKeywordMatchTag;if(!searchKeywordTag)searchKeywordTag="mark";$.each(Config.keyword.split(" "),function(j){var word=this;$(Config.searchKeywordHighlightMark,context).find("*").addBack().contents().filter(function(){if(this.nodeType===3){var elm=this;var text=elm.nodeValue;text=text.replace(new RegExp("("+word+")","ig"),"<"+searchKeywordTag+' class="'+Config.searchKeywordMatchClass+(parseInt(j,10)+1)+'">$1</'+searchKeywordTag+">");$(elm).before($.parseHTML(text));
$(elm).remove()}})})}$("[class*="+Config.toggleHeadClassSuffix+"]",context).css("cursor","pointer").click(function(){if(!(new RegExp("([^\\s]*)"+Config.toggleHeadClassSuffix)).test(this.className))return false;var mark=RegExp.$1;$target=$("."+mark+Config.toggleBodyClassSuffix);if(!$target.size())return false;$target.slideToggle();return false});$('[class*="'+Config.toggleBodyClassSuffix+'"]',context).hide();$("[class*="+Config.fadeHeadClassSuffix+"]",context).css("cursor","pointer").click(function(){if(!(new RegExp("([^\\s]*)"+
Config.fadeHeadClassSuffix)).test(this.className))return false;var mark=RegExp.$1;$target=$("."+mark+Config.fadeBodyClassSuffix);if(!$target.size())return false;"none"==$target.css("display")?$target.fadeIn():$target.fadeOut();return false});$('[class*="'+Config.fadeBodyClassSuffix+'"]',context).hide();var $link=$(Config.styleSwitchStyleMark,context);if($link.size()){var styleName=$.cookie("styleName");if(styleName)ACMS.Library.switchStyle(styleName,$link)}$(Config.styleSwitchMark,context).click(function(){ACMS.Library.switchStyle(this.rel,
$(Config.styleSwitchStyleMark));return false});$(Config.inputEvalValueMark,context).each(function(){$(this).val(eval($(this).val()))});$(Config.commentCookieMark,context).each(function(){if(!$.cookie("acms_comment_name"))return true;$("input:text[name=name]",this).val($.cookie("acms_comment_name"));$("input:text[name=mail]",this).val($.cookie("acms_comment_mail"));$("input:text[name=url]",this).val($.cookie("acms_comment_url"));$("input:password[name=pass]",this).val($.cookie("acms_comment_pass"));
$("input:checkbox[name=persistent]",this).attr("checked","checked")});$(Config.commentCookieUserMark,context).each(function(){if(!$.cookie("acms_user_name"))return true;var name=$.cookie("acms_user_name");var mail=$.cookie("acms_user_mail");var url=$.cookie("acms_user_url");if(!name)name="";if(!mail)mail="";if(!url)url="";$("input:text[name=name]",this).replaceWith("<strong>"+name+'</strong><input type="hidden" name="name" value="'+name+'" />');$("input:text[name=mail]",this).replaceWith("<strong>"+
mail+'</strong><input type="hidden" name="mail" value="'+mail+'" />');$("input:text[name=url]",this).replaceWith("<strong>"+url+'</strong><input type="hidden" name="url" value="'+url+'" />')});$(Config.readyFocusMark,context).focus();var $elm=$(Config.readyScrollMark,context);if($elm.size())ACMS.Library.scrollToElm($elm);$(Config.copyrightMark,context).click(function(){return hs.htmlExpand(this,{objectType:"iframe",wrapperClassName:"draggable-header",headingText:this.title,align:"center",width:$(window).width()*
0.5,height:$(window).height()*0.5,dimmingOpacity:0.75,dimmingDuration:25})});function msie_under8(){var _ua=ua();if(_ua.ltIE8||_ua.ltIE7||_ua.ltIE6)return true;else return false}};
ACMS.Dispatch.Utility.browser=function(){var _ua=function(){var browser=ACMS.Dispatch.Utility.getBrowser();var IE6,IE7,IE8,IE9=false;if(browser=="ie9")IE9=true;else if(browser=="ie8"){IE9=true;IE8=true}else if(browser=="ie7"){IE9=true;IE8=true;IE7=true}else if(browser=="ie6"){IE9=true;IE8=true;IE7=true;IE6=true}return{ltIE6:IE6,ltIE7:IE7,ltIE8:IE8,ltIE9:IE9,mobile:/^(.+iPhone.+AppleWebKit.+Mobile.+|^.+Android.+AppleWebKit.+Mobile.+)$/i.test(navigator.userAgent.toLowerCase()),tablet:/^(.+iPad;.+AppleWebKit.+Mobile.+|.+Android.+AppleWebKit.+)$/i.test(navigator.userAgent.toLowerCase())}}();
return _ua};ACMS.Dispatch.Utility.browser_ie6=function(){var _ua=ACMS.Dispatch.Utility.browser();if(_ua.ltIE6)return true;else return false};
ACMS.Dispatch.Utility.getBrowser=function(){var ua=window.navigator.userAgent.toLowerCase();var ver=window.navigator.appVersion.toLowerCase();var name="unknown";if(ua.indexOf("chrome")!=-1)name="chrome";else if(ua.indexOf("safari")!=-1)name="safari";else if(ua.indexOf("opera")!=-1)name="opera";else if(ua.indexOf("firefox")!=-1)name="firefox";else if(ua.indexOf("trident/7")!=-1)name="ie11";else if(ua.indexOf("msie")!=-1)if(ver.indexOf("msie 6.")!=-1)name="ie6";else if(ver.indexOf("msie 7.")!=-1)name=
"ie7";else if(ver.indexOf("msie 8.")!=-1)name="ie8";else if(ver.indexOf("msie 9.")!=-1)name="ie9";else if(ver.indexOf("msie 10.")!=-1)name="ie10";else name="ie";return name};ACMS.Dispatch.Utility.random=function(length){if(!length)length=8;var quotient=Math.floor(length/8);var remainder=length%8;var txt="";for(var i=0;i<quotient;i++)txt+=Math.random().toString(36).slice(-8);if(remainder>0){remainder*=-1;console.log(remainder);txt+=Math.random().toString(36).slice(remainder)}return txt};
ACMS.Dispatch.Utility.unloadAlert=function(context,selector,force){force=force||false;if(!!selector)selector=".js-admin_unload_alert, "+selector;var $adminForm=$(selector,context);if(!$adminForm.length)return false;var unload=function(){var onBeforeunloadHandler=function(e){e.returnValue=ACMS.i18n.unload.message1};window.addEventListener("beforeunload",onBeforeunloadHandler,false);$adminForm.bind("submit",function(){window.removeEventListener("beforeunload",onBeforeunloadHandler,false)})};if(force)unload();
else $adminForm.bind("keyup change",function(){unload()})};
ACMS.Dispatch.Utility.imgToDataURL=function(){var lgImageSize=ACMS.Config.lgImg,lgImgAry=lgImageSize.split(":"),lgImgSide=lgImgAry[0],lgImgSize=lgImgAry[1];var canvas=document.createElement("canvas"),ctx=canvas.getContext("2d"),srcSize={width:this.width,height:this.height},destSize=null,dataUrl=null,ratio=1,noResize=false,rad=0,dx=0,dy=0;EXIF.getData(this,function(){var exif=EXIF.getAllTags(this);if(!lgImgSide)if(srcSize.width>srcSize.height)lgImgSide="width";else lgImgSide="height";if(lgImgSide.substring(0,
1)==="h")if(srcSize.height<lgImgSize){destSize={width:srcSize.width,height:srcSize.height};noResize=true}else{ratio=lgImgSize/srcSize.height;destSize={width:srcSize.width*ratio,height:lgImgSize}}else if(srcSize.width<lgImgSize){destSize={width:srcSize.width,height:srcSize.height};noResize=true}else{ratio=lgImgSize/srcSize.width;destSize={width:lgImgSize,height:srcSize.height*ratio}}canvas.width=destSize.width;canvas.height=destSize.height;switch(exif.Orientation){case 8:canvas.width=destSize.height;
canvas.height=destSize.width;rad=-90*Math.PI/180;dy=canvas.height;break;case 3:rad=180*Math.PI/180;dx=canvas.width;dy=canvas.height;break;case 6:canvas.width=destSize.height;canvas.height=destSize.width;rad=90*Math.PI/180;dx=canvas.width;break}if(exif.Orientation===void 0)exif=false;if(rad!==0)ctx.setTransform(Math.cos(rad),Math.sin(rad),-Math.sin(rad),Math.cos(rad),dx,dy);ctx.drawImage(this,0,0,srcSize.width,srcSize.height,0,0,destSize.width,destSize.height);dataUrl=canvas.toDataURL(this.mime);if(this.callback)this.callback(this,
dataUrl,!noResize||this.force,exif)})};
