// cookie ----------------------------------------

var v_IE = (document.documentElement.getAttribute("style") == document.documentElement.style);
var v_class;
if(v_IE) v_class = "className";
if(!v_IE) v_class = "class";
function f_setCookie(key, val, param) {
cookieName = key + "=" + escape(val) + ";";
cookieName += "name=gtm;";
effectPath = "path=/;";
switch(param) {
case "temporary":
if(!v_IE) expiresTime = "expires=0";
if(v_IE) expiresTime = "expires=";
break;
default:
nowTime = new Date();
nowTime.setTime(nowTime.getTime() + (3000 * 1000 * 60 * 60 * 24));
expiresTime = "expires=" + nowTime.toGMTString();
break;
}
document.cookie = cookieName + effectPath + expiresTime;
}

// SwitchFontsize ----------------------------------------

var contentSwitchFontSize = {
conf : {
fontSize     : ["115%","100%","85%"],
switchId     : ["switchFontSizeBig", "switchFontSizeMedium", "switchFontSizeSmall"],
defoSizeId   : "switchFontSizeMedium",
targetAreaId : "contents",
targetAreaId2: "mailer1",
targetAreaId3: "mailer2",
targetAreaId4: "mailer3",
cookieName   : "FontSizeChange",
cookieLimit  : 30,
switchWriteArea : "font-change",
switchHTML      : '<ul><li id="switchFontSizeSmall" style="text-indent:-9999px;"><span>小</span></li><li id="switchFontSizeMedium" style="text-indent:-9999px;"><span>中</span></li><li id="switchFontSizeBig" style="text-indent:-9999px;"><span>大</span></li></ul>'
},
main : function(){
contentSwitchFontSize.setHTML();
contentSwitchFontSize.defo();
var i, j, switchItem = contentSwitchFontSize.conf.switchId;
for(i=0;i<switchItem.length;i++){
document.getElementById(switchItem[i]).onclick = contentSwitchFontSize.action;
}
},
setHTML : function(){
var fontsizeSwitch = document.createElement('div');
fontsizeSwitch.id  = "fontsizeControl";
fontsizeSwitch.innerHTML = contentSwitchFontSize.conf.switchHTML;
document.getElementById(contentSwitchFontSize.conf.switchWriteArea).appendChild(fontsizeSwitch);
},

defo : function(){
var i;
var switchId = contentSwitchFontSize.conf.switchId;
var targetAreaId = contentSwitchFontSize.conf.targetAreaId;
var targetAreaId2 = contentSwitchFontSize.conf.targetAreaId2;
var targetAreaId3 = contentSwitchFontSize.conf.targetAreaId3;
var targetAreaId4 = contentSwitchFontSize.conf.targetAreaId4;
var fontSize = contentSwitchFontSize.conf.fontSize;
cookieValue = this.getCookie() || contentSwitchFontSize.conf.defoSizeId;
for(i = 0; i < switchId.length; i++){
if(cookieValue == switchId[i]){
document.getElementById(targetAreaId).style.fontSize = fontSize[i];
if( document.getElementById(targetAreaId2) )
{
document.getElementById(targetAreaId2).contentWindow.document.body.style.fontSize = fontSize[i];
}
if( document.getElementById(targetAreaId3) )
{
document.getElementById(targetAreaId3).contentWindow.document.body.style.fontSize = fontSize[i];
}
if( document.getElementById(targetAreaId4) )
{
document.getElementById(targetAreaId4).contentWindow.document.body.style.fontSize = fontSize[i];
}
}
}
document.getElementById(cookieValue).className ="active";
},
action : function(){
var i;
var switchId = contentSwitchFontSize.conf.switchId;
var targetAreaId = contentSwitchFontSize.conf.targetAreaId
var targetAreaId2 = contentSwitchFontSize.conf.targetAreaId2
var targetAreaId3 = contentSwitchFontSize.conf.targetAreaId3
var targetAreaId4 = contentSwitchFontSize.conf.targetAreaId4
var fontSize = contentSwitchFontSize.conf.fontSize
for(i=0;i<switchId.length;i++){
var switchItem = document.getElementById(switchId[i]);
switchItem.className="";
if(this.id == switchId[i]){
document.getElementById(targetAreaId).style.fontSize = fontSize[i];
if( document.getElementById(targetAreaId2) )
{
document.getElementById(targetAreaId2).contentWindow.document.body.style.fontSize = fontSize[i];
}
if( document.getElementById(targetAreaId3) )
{
document.getElementById(targetAreaId3).contentWindow.document.body.style.fontSize = fontSize[i];
}
if( document.getElementById(targetAreaId4) )
{
document.getElementById(targetAreaId4).contentWindow.document.body.style.fontSize = fontSize[i];
}
}
}
this.className ="active";
contentSwitchFontSize.setCookie(this.id);
},
setCookie: function(data) {
var today = new Date();
today.setTime(today.getTime() + (1000 * 60 * 60 * 24 * Number(this.conf.cookieLimit)));
document.cookie = this.conf.cookieName + '=' + encodeURIComponent(data) + '; path=/; expires=' + today.toGMTString();
},
getCookie: function(m) {
return (m = ('; ' + document.cookie + ';').match('; ' + this.conf.cookieName + '=(.*?);')) ? decodeURIComponent(m[1]) : null;
}
}
Event.observe(window, "load", contentSwitchFontSize.main, false);

//RollOver ----------------------------------------

var RollOver = Class.create();
RollOver.prototype = {
initialize: function(option) {
var props = {
hclass : "imgover",
suffix : "_on"
};
if(option) for(var key in option) props[key] = option[key];
$$('img.'+props.hclass,'input.'+props.hclass).each(
function(el){
var osrc = el.getAttribute('src');
if (!osrc) return;
var hsrc = osrc.replace(/(\.gif|\.jpg)/,props.suffix+'$1');
(new Image()).src = hsrc;
el.observe("mouseover",function(){
el.setAttribute('src', hsrc);
}).observe("mouseout",function(){
el.setAttribute('src', osrc);
});
}
);
}
}
Event.observe(window,'load',function(){new RollOver();});


Event.observe(window, 'load', function() {
$$('a[href^="#"]:not([href="#"])').each(function(element) {
element.observe('click', function(event) {
new Effect.ScrollTo(this.hash.substr(1));
Event.stop(event);
}.bindAsEventListener(element))
})
});

