//【ここから】CSSロールオーバー画像のプリロード
var loadImages = new Array();
	loadImages[0] = "/common/frame/img/icon_01_d.gif";
	loadImages[1] = "/common/frame/img/icon_01_o.gif";
	loadImages[2] = "/common/frame/img/icon_02_d.gif";
	loadImages[3] = "/common/frame/img/icon_02_o.gif";
	loadImages[4] = "/common/frame/img/icon_04_o.gif";
	loadImages[5] = "/common/frame/img/icon_05_o.gif";
	loadImages[7] = "/common/frame/img/bg_04_o.gif";
	loadImages[8] = "/common/frame/img/bg_05_o.gif";
	loadImages[9] = "/common/frame/img/bg_06_o.gif";

function imgPreLoad() {
	var tmpImages = new Array();
	for (i=0; loadImages.length>i; i++) {
		tmpImages[i] = new Image();
		tmpImages[i].src = loadImages[i];
	}
}
//【ここまで】CSSロールオーバー画像のプリロード


//【ここから】画像ロールオーバー
function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");
		var imagesTmp = new Object();
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_d."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_d.", "_o."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_o.", "_d."));
				}
				imagesTmp[i] = new Image();
				imagesTmp[i].src = images[i].src.replace("_d.", "_o.");
			}
		}
		var input = document.getElementsByTagName("input");
		var inputTmp = new Object();
		for(var i=0; i < input.length; i++) {
			if(input[i].getAttribute("src") && input[i].getAttribute("src").match("_d."))
			{
				input[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_d.", "_o."));
				}
				input[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_o.", "_d."));
				}
				inputTmp[i] = new Image();
				inputTmp[i].src = input[i].src.replace("_d.", "_o.");
			}
		}
	}
}
//【ここまで】画像ロールオーバー


//【ここから】ポップアップリンク
function smartPopup() {
	if(document.getElementsByTagName) {
		var option = "width=500,height=600,status=1,location=1,menubar=0,scrollbars=1,resizable=1";
		var a = document.getElementsByTagName("a");
		for(var i=0; i < a.length; i++) {
			if(a[i].className.match("openWindow"))
			{
				a[i].onclick = function() {
					var popup = window.open(this.getAttribute("href"), "popup", option);
					popup.focus();
					return false;
				}
			}
			else if(a[i].className.match("closeWindow"))
			{
				a[i].onclick = function() {
					window.opener.focus();
					self.close();
					return true;
				}
			}
		}
		var area = document.getElementsByTagName("area");
		for(var i=0; i < area.length; i++) {
			if(area[i].className.match("openWindow"))
			{
				area[i].onclick = function() {
					var popup = window.open(this.getAttribute("href"), "popup", option);
					popup.focus();
					return false;
				}
			}
			else if(area[i].className.match("closeWindow"))
			{
				area[i].onclick = function() {
					window.opener.focus();
					self.close();
					return false;
				}
			}
		}
	}
}
//【ここまで】ポップアップリンク


//【ここから】フォントサイズ変更用CSSの切り替え
function setActiveStyleSheet(title) {
	var prevTitle = title==getActiveStyleSheet() ? false : getActiveStyleSheet();
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
			setButtonStatus(title, prevTitle);
		}
	}
}

function getActiveStyleSheet() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return null;
}

function getPreferredStyleSheet() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1
			 && a.getAttribute("rel").indexOf("alt") == -1
			 && a.getAttribute("title")
			 ) return a.getAttribute("title");
	}
	return null;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

function styleLoad() {
	var cookie = readCookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();

	if (document.getElementById("fontLarge")) {
		document.getElementById("fontLarge").onclick = function() {
			setActiveStyleSheet("fontLarge");
		}
	}
	if (document.getElementById("fontMedium")) {
		document.getElementById("fontMedium").onclick = function() {
			setActiveStyleSheet("fontMedium");
		}
	}
	if (document.getElementById("fontSmall")) {
		document.getElementById("fontSmall").onclick = function() {
			setActiveStyleSheet("fontSmall");
		}
	}

	setActiveStyleSheet(title);
}

function styleRegist() {
	var title = getActiveStyleSheet();
	createCookie("style", title, 365);
}

function setButtonStatus(title, prevTitle) {
	if (document.getElementById(title) && document.getElementById(title).nodeName.match(/img/i)) {
		var button = document.getElementById(title);
		button.onmouseover = null;
		button.onmouseout = null;
		button.src = button.src.replace("_d.", "_o.");
	}
	if (prevTitle && document.getElementById(prevTitle) && document.getElementById(prevTitle).nodeName.match(/img/i)) {
		var button = document.getElementById(prevTitle);
		button.setAttribute("src", button.getAttribute("src").replace("_o.", "_d."));
		button.onmouseover = function() {
			this.setAttribute("src", this.getAttribute("src").replace("_d.", "_o."));
		}
		button.onmouseout = function() {
			this.setAttribute("src", this.getAttribute("src").replace("_o.", "_d."));
		}
	}
}
//【ここまで】フォントサイズ変更用CSSの切り替え


/* 【ここから】イベントリスナーへ登録 */
if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
	window.addEventListener("load", smartPopup, false);
	window.addEventListener("load", imgPreLoad, false);
	window.addEventListener("load", styleLoad, false);
	window.addEventListener("unload", styleRegist, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
	window.attachEvent("onload", smartPopup);
	window.attachEvent("onload", imgPreLoad);
	window.attachEvent("onload", styleLoad, false);
	window.attachEvent("onunload", styleRegist, false);
}
/* 【ここまで】イベントリスナーへ登録 */
