/**
 * SAKURA Creative Inc. Utility Functions.
 *
 * http://www.sakura-creative.com/
 *
 * Copyright (c) 2009 SAKURA Creative Inc.
 *
 * $Id: sc_utils.js 9:51 2009/10/12 Kaoru Ishikura $
 */

(function(){var window=this,undefined;var isMSIE=/*@cc_on!@*/false;var isMSIE6=typeof document.documentElement.style.maxHeight==="undefined"?true:false;var isSafari=window.getMatchedCSSRules&&typeof CharacterData!="function";var addListener=(function(){if(window.addEventListener){return function(elem,type,func){elem.addEventListener(type,func,false);return true}}else{if(window.attachEvent){return function(elem,type,func){elem.attachEvent("on"+type,func);return true}}else{return function(){return false}}}})();var removeListener=(function(){if(window.removeEventListener){return function(elem,type,func){elem.removeEventListener(type,func,false);return true}}else{if(window.detachEvent){return function(elem,type,func){elem.detachEvent("on"+type,func);return true}}else{return function(){return false}}}})();function getElemPosition(e){var elem=document.getElementById(e);if(!elem){return false}elem.elemX=elem.offsetLeft;elem.elemY=elem.offsetTop;var myParent=elem.offsetParent;while(myParent){elem.elemX+=myParent.offsetLeft;elem.elemY+=myParent.offsetTop;myParent=myParent.offsetParent}return e}var getMousePosition=(function(){if(document.all){return function(){return{x:window.event.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft),y:window.event.clientY+(document.documentElement.scrollTop||document.body.scrollTop)}}}else{if(document.getElementById){return function(e){return{x:e.pageX,y:e.pageY}}}else{return function(){return{x:undefined,y:undefined}}}}})();var getScrollPosition=(function(){if(window.pageXOffset!==undefined){return function(){return{x:window.pageXOffset,y:window.pageYOffset}}}else{if(document.documentElement&&document.documentElement.scrollLeft!==undefined||document.body&&document.body.scrollLeft!==undefined){return function(){return{x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}}}else{return function(){return{x:undefined,y:undefined}}}}})();var getWindowSize=(function(){if(document.documentElement&&document.documentElement.clientWidth!==undefined||document.body&&document.body.clientWidth!==undefined){return function(){return{x:document.documentElement.clientWidth||document.body.clientWidth,y:document.documentElement.clientHeight||document.body.clientHeight}}}else{if(window.innerWidth!==undefined){return function(){return{x:window.innerWidth,y:window.innerHeight}}}else{return function(){return{x:undefined,y:undefined}}}}})();var getScreenSize=(function(){if(screen.availWidth!==undefined){return function(){return{x:screen.availWidth,y:screen.availHeight}}}else{return function(){return{x:undefined,y:undefined}}}})();var getScrollSize=(function(){if(document.documentElement&&document.documentElement.scrollWidth!==undefined||document.body&&document.body.scrollWidth!==undefined){return function(){return{x:document.documentElement.scrollWidth||document.body.scrollWidth,y:document.documentElement.scrollHeight||document.body.scrollHeight}}}else{if(document.width!==undefined){return function(){return{x:document.width,y:document.height}}}else{return function(){return{x:undefined,y:undefined}}}}})();var appendStyleSheet=(function(){if(document.createStyleSheet){return function(path){document.createStyleSheet(path);return true}}else{if(document.createElement){return function(path){var tag=document.createElement("link");tag.setAttribute("href",path);tag.setAttribute("media","all");tag.setAttribute("type","text/css");tag.setAttribute("rel","stylesheet");document.getElementsByTagName("head")[0].appendChild(tag);return true}}else{return function(){return false}}}})();var removeStyleSheet=(function(){if(document.getElementsByTagName){return function(name){var parent=document.getElementsByTagName("head")[0],flg=false;for(var i=0,len=parent.childNodes.length;i<len;i++){var node=parent.childNodes[i];if(node.nodeName.toLowerCase()==="link"&&node.getAttribute("href")!==null&&node.getAttribute("href").lastIndexOf(name)!==-1){parent.removeChild(node);if(isMSIE&&!document.documentMode){var tagStyle=document.getElementsByTagName("body")[0].style,cache=tagStyle.marginBottom;tagStyle.marginBottom="1px";tagStyle.marginBottom=cache}flg=true;break}}return flg}}else{return function(){return false}}})();function getKeyCode(e){if(document.all){return{keyNum:event.keyCode,keyName:String.fromCharCode(event.keyCode)}}else{if(e&&document.getElementById){return{keyNum:e.charCode||e.keyCode,keyName:String.fromCharCode(e.charCode||e.keyCode)}}else{return false}}}function setCookie(name,val,days,path,domain,secure){if(!navigator.cookieEnabled||!name){return false}var date=new Date();date.setTime(date.getTime()+((days||-1)*24*60*60*1000));var expires=";expires="+date.toGMTString();var isCookie=name+"="+escape(val)+expires+";path="+(path||"/")+";domain="+(domain||"")+";"+(secure||"");document.cookie=isCookie;return true}function getCookie(name){if(!navigator.cookieEnabled||!name){return undefined}var isCookie=document.cookie;if(!isCookie){return undefined}name+="=";var nameLen=isCookie.indexOf(name);if(nameLen!=-1){nameLen+=name.length;var eof=isCookie.indexOf(";",nameLen);if(eof==-1){eof=isCookie.length}return unescape(isCookie.substring(nameLen,eof))}else{return undefined}}function stopPropagation(e){if(e&&e.stopPropagation){e.stopPropagation();return true}else{if(window.event){window.event.cancelBubble=true;return true}else{return false}}}function preventDefault(e){if(e&&e.preventDefault){e.preventDefault();return true}else{if(window.event){window.event.returnValue=false;return true}else{return false}}}function toBool(expr){return !!expr}var setStyle=(function(){if(document.all||document.getElementById){return function(elem,styles){var elemStyle=elem.style;if(typeof(styles)==="string"){elemStyle.cssText+=";"+styles;return true}for(var prop in styles){if(prop=="opacity"){elemStyle.opacity=(styles[prop]==1||styles[prop]==="")?"":(styles[prop]<0.1)?0:styles[prop]}else{if(prop=="float"){elemStyle[typeof(elemStyle.cssFloat)!=="undefined"?"cssFloat":"styleFloat"]=styles[prop]}else{elemStyle[prop]=styles[prop]}}}return true}}else{return function(){return false}}})();var getStyle=(function(){if(document.defaultView&&document.defaultView.getComputedStyle){return function(elem,style){style=style||"";return document.defaultView.getComputedStyle(elem,null)}}else{if(document.all){return function(elem){return elem.currentStyle}}else{return undefined}}})();var getStyleBySelector=(function(){if(document.all&&document.styleSheets){return function(selector){for(var i=0,sheet;sheet=document.styleSheets[i++];){if(sheet.disabled){continue}for(var j=0,rule;rule=sheet.rules[j++];){if(rule.selectorText==selector){return rule}}}return undefined}}else{if(document.getElementById&&document.styleSheets){return function(selector){for(var i=0,sheet;sheet=document.styleSheets[i++];){if(sheet.disabled){continue}for(var j=0,rule;rule=sheet.cssRules[j++];){if(rule.selectorText==selector){return rule}}}return undefined}}else{return function(){return undefined}}}})();var addClassName=function(elm,className){var reg=new RegExp("(^| +)"+className+"($| +)");if(!reg.test(elm.className)){elm.className+=" "+className}};var removeClassName=function(elm,className){var reg=new RegExp("(^| +)"+className+"($| +)");elm.className=elm.className.replace(reg,"")};function setFontSize(id,name,days,path,domain){var elem=document.getElementById(id);var body=document.getElementsByTagName("body")[0];if(elem===null){return false}var fontSizeTable={"xx-small":"9px","x-small":"12px",small:"13px",medium:"16px",large:"19px","x-large":"24px","xx-large":"32px","100%":"12px"};var style=getStyle(elem);var orgFontSize=style.fontSize;orgFontSize=fontSizeTable[orgFontSize];if(orgFontSize===undefined){orgFontSize=style.fontSize}if(document.getElementById("resetFont")===null){return false}addListener(document.getElementById("resetFont"),"click",function(e){setCookie(name,orgFontSize,0,path,domain);removeClassName(body,"inc_font");if(isMSIE6){setElementMinHeight("message",114);setElementMinHeight("best5",114);setElementMinHeight("products",140,100)}stopPropagation(e);preventDefault(e);document.getElementById("resetFont").style.display="none";document.getElementById("increaseFont").style.display="block";return false});var isCookie=getCookie("scFontSize");if(isCookie!==undefined){addClassName(body,"inc_font");if(isMSIE6){setElementMinHeight("message",114);setElementMinHeight("best5",114);setElementMinHeight("products",140,100)}document.getElementById("increaseFont").style.display="none";document.getElementById("resetFont").style.display="block"}else{document.getElementById("increaseFont").style.display="block";document.getElementById("resetFont").style.display="none"}addListener(document.getElementById("increaseFont"),"click",function(e){aa(1.2);addClassName(body,"inc_font");if(isMSIE6){setElementMinHeight("message",114);setElementMinHeight("best5",114);setElementMinHeight("products",140,100)}document.getElementById("increaseFont").style.display="none";document.getElementById("resetFont").style.display="block";stopPropagation(e);preventDefault(e);return false});function aa(bbbb){var style=getStyle(elem);var curFontSize=style.fontSize;curFontSize=fontSizeTable[curFontSize];if(curFontSize===undefined){curFontSize=style.fontSize}var curFontSizeNum=parseFloat(curFontSize,10);var newFontSize=curFontSizeNum*bbbb;setCookie(name,newFontSize,days,path,domain);return false}function setElementMinHeight(target,height,num){if(typeof target!=="string"){return false}var elm=document.getElementById(target);num=num!==undefined?num:height;if(elm===null||typeof height!=="number"||typeof num!=="number"){return false}elm=elm.getElementsByTagName("a");for(i=0,len=elm.length;i<len;i++){elm[i].style.height=elm[i].clientHeight<height?num+"px":"auto"}return true}}addListener(window,"load",function(){scPrintMode("/data/packages/default/css/common/print.css",["import_palette.css","cms.css","extend.css","ie6.css"]);setFontSize("contents","scFontSize",30,"/","hikari-renaissance.com")});function getQuerySting(){var ret=[],parms=window.location.search.substring(1).split("&");for(var i=0,len=parms.length;i<len;i++){var pos=parms[i].indexOf("=");if(pos>0){var key=parms[i].substring(0,pos);var val=parms[i].substring(pos+1);ret[key]=val}}return ret}function showPrintPreview(){if(window.ActiveXObject==null||document.body.insertAdjacentHTML==null){return}var sWebBrowserCode='<object width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';document.body.insertAdjacentHTML("beforeEnd",sWebBrowserCode);var objWebBrowser=document.body.lastChild;if(objWebBrowser==null){return}objWebBrowser.ExecWB(7,1);document.body.removeChild(objWebBrowser)}function scPrintMode(path,arrRmSheet,mode,parm){var query=[];mode=mode!==undefined?mode:"mode";parm=parm!==undefined?parm:"print";query=getQuerySting();if(!!query[mode]&&query[mode]===parm&&path!==undefined&&path!==""){var node=document.getElementsByTagName("body")[0],html=node.innerHTML;if(typeof(arrRmSheet)==="string"){removeStyleSheet(arrRmSheet)}else{if(typeof(arrRmSheet)==="object"){for(var str in arrRmSheet){removeStyleSheet(arrRmSheet[str])}}}appendStyleSheet(path);node.innerHTML='<div class="print_bar"><a href="#print" onclick="print(); return false;">印刷する</a></div>'+html}}})();

