//
function getCookie(){
	zoom = "";
	cName = "FontSize=";
	tmpCookie = document.cookie + ";";
	start = tmpCookie.indexOf(cName);
	if (start != -1)
	{
		end = tmpCookie.indexOf(";", start);
		zoom = tmpCookie.substring(start + cName.length, end);
		document.getElementById(target).style.fontSize = zoom;
	} else {
		document.getElementById(target).style.fontSize = "100%";
	}
	//color
	var p;
	pName = "F_Color=";
	tmpCookie = document.cookie + ";";
	start = tmpCookie.indexOf(pName);
	if (start != -1)
	{
		end = tmpCookie.indexOf(";", start);
		p = tmpCookie.substring(start + pName.length, end);
		changeCSS(p);
	}
}


////文字拡大・縮小///////////////////////////
var target = "page";	//*文字拡大・縮小対象エリア（ID名）
//
function setCookie(s){
	cName = "FontSize=";
	exp = new Date();
	exp.setTime(exp.getTime() + 31536000000);
	document.cookie = cName + s + "; path=/; expires=" + exp.toGMTString();
}
//
function textSizeUp(){
	currentSize = document.getElementById(target).style.fontSize;
	if (!currentSize) {
		currentSize = "100%";
	}
	selectSize = "";
	if ( currentSize=="100%" || currentSize=="1.0em"){
		selectSize = "120%";
	} else if(currentSize=="120%") {
		selectSize = "140%";
	} else if(currentSize=="140%") {
		selectSize = "160%";
	} else if(currentSize=="160%") {
		selectSize = "180%";
	} else if(currentSize=="180%") {
		selectSize = "200%";
	} else if(currentSize=="200%") {
		alert("これ以上文字を拡大することはできません。");
		selectSize = "200%";
	} else {
		selectSize = "100%";
	}
	document.getElementById(target).style.fontSize = selectSize;
	setCookie(selectSize);
}

function textSizeDown(){
	currentSize = document.getElementById(target).style.fontSize;
	if (!currentSize) {
		currentSize = "100%";
	}
	selectSize = "";
	if ( currentSize=="200%" || currentSize=="2.0em"){
		selectSize = "180%";
	} else if(currentSize=="180%") {
		selectSize = "160%";
	} else if(currentSize=="160%") {
		selectSize = "140%";
	} else if(currentSize=="140%") {
		selectSize = "120%";
	} else if(currentSize=="120%") {
		selectSize = "100%";
	} else if(currentSize=="100%") {
		selectSize = "80%";
	} else if(currentSize=="80%") {
		selectSize = "60%";
	} else if(currentSize=="60%") {
		selectSize = "40%";
	} else if(currentSize=="40%") {
		alert("これ以上文字を縮小することはできません。");
		selectSize = "40%";
	} else {
		selectSize = "100%";
	}
	document.getElementById(target).style.fontSize = selectSize;
	setCookie(selectSize);
}

function textSizeDefault(){
	currentSize = document.getElementById(target).style.fontSize;
	selectSize = "100%";
	document.getElementById(target).style.fontSize = selectSize;
	setCookie(selectSize);
}




////色合いの変更　//////////////////////////////////////////////////////////////////////////////
var targetLINK  = "changecss";
var css_keyword = "color";
var dir_path = "/library/css/";			//CSSファイルを置いてあるディレクトリを絶対パスで指定すること
//
function setColorCookie(s){
	cName = "F_Color=";
	exp = new Date();
	exp.setTime(exp.getTime() + 31536000000);
	document.cookie = cName + s + "; path=/" + "; expires=" + exp.toGMTString();
}
//
function changeCSS(par) {
	if(!par || par=="") return;
	var target = document.getElementById(targetLINK);
	if(!target) {
		links = document.getElementsByTagName('link');
		for(var i=0;i<links.length;i++) {
			temp = links[i].href;
			chk = temp.indexOf(css_keyword);
			if(chk!=-1) {
				target = links[i];
				break;
			}
		}
	}
	//
	if(!target || !target.cloneNode) {
		alert('ご利用のブラウザでは色合いの変更機能はご利用いただけないようです.\n[Element]or[cloneNode Method] None');
		return;
	}
	//
	var css_path = dir_path + par;
	//
	var newNode = target.cloneNode(true);
	newNode.href = css_path;
	target.parentNode.replaceChild(newNode,target);
	//
	setColorCookie(par);
}


//
