////coolie設定//////////////////////////////////////////////////////////////////////////////
function getCookie(){
	//text
	zoom = "";
	siteName = "jwrc";
	tmpCookie = document.cookie + ";";
	start = tmpCookie.indexOf(siteName);
	if (start != -1)
	{
		end = tmpCookie.indexOf(";", start);
		zoom = tmpCookie.substring(start + siteName.length, end);
		document.body.style.fontSize = zoom;
	} else {
		//document.body.style.fontSize = "100%";
	}
	//color
	var p;
	pName = "tscColor=";
	tmpCookie = document.cookie + ";";
	start = tmpCookie.indexOf(pName);
	if (start != -1)
	{
		end = tmpCookie.indexOf(";", start);
		p = tmpCookie.substring(start + pName.length, end);
		changeCSS(p);
	}
}
////文字拡大・縮小//////////////////////////////////////////////////////////////////////////////
//function setCookie(s){
function setSize(s){
	siteName = "jwrc";
	exp = new Date();
	exp.setTime(exp.getTime() + 31536000000);
	document.cookie = siteName + s + "; path=/; expires=" + exp.toGMTString();
}
//
function textSizeUp(){
	currentSize = document.body.style.fontSize;
	if(!currentSize) currentSize = "100%";
	selectSize = "";
	if ( currentSize == "100%" ){
		selectSize = "110%";
	}
	else if ( currentSize == "70%" ){
		selectSize = "80%";
	}
	else if ( currentSize == "80%" ){
		selectSize = "90%";
	}
	else if ( currentSize == "90%" ){
		selectSize = "100%";
	}
	else if ( currentSize == "110%" ){
		selectSize = "120%";
	}
	else if ( currentSize == "120%" ){
		selectSize = "130%";
	}
	else if ( currentSize == "130%" ){
		selectSize = "140%";
	}
	else if ( currentSize == "140%" ){
		m = escape("これ以上文字のサイズを大きくできません。");
		alert(unescape(m));
		selectSize = "140%";
	}
	else {
		selectSize = "140%";
	}
	document.body.style.fontSize = selectSize;
	setSize(selectSize);
}

function textSizeDefault(){
	currentSize = document.body.style.fontSize;
	selectSize = "100%";
	document.body.style.fontSize = selectSize;
	setSize(selectSize);
}

function textSizeDown(){
	currentSize = document.body.style.fontSize;
	if(!currentSize) currentSize = "100%";
	selectSize = "";
	if ( currentSize == "140%" ){
		selectSize = "130%";
	}
	else if ( currentSize == "130%" ){
		selectSize = "120%";
	}
	else if ( currentSize == "120%" ){
		selectSize = "110%";
	}
	else if ( currentSize == "110%" ){
		selectSize = "100%";
	}
	else if ( currentSize == "100%" ){
		selectSize = "90%";
	}
	else if ( currentSize == "90%" ){
		selectSize = "80%";
	}
	else if ( currentSize == "80%" ){
		selectSize = "70%";
	}
	else if ( currentSize == "70%" ){
		m = escape("これ以上文字のサイズを小さくできません。");
		alert(unescape(m));
		selectSize = "70%";
	}
	else {
		selectSize = "70%";
	}
	document.body.style.fontSize = selectSize;
	setSize(selectSize);
}

////色合いの変更　//////////////////////////////////////////////////////////////////////////////
var targetLINK  = "changecss";
var css_keyword = "color";
var dir_path = "/js/color/";
//
function setColorCookie(s){
	siteName = "tscColor=";
	exp = new Date();
	exp.setTime(exp.getTime() + 31536000000);
	document.cookie = siteName + 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);
}


//// onload //////////////////////////////////////////////////////////////////////////

window.onload = function() {
		getCookie();
}
