////coolie設定//////////////////////////////////////////////////////////////////////////////
function getCookie(){
	//text
	zoom = "";
	siteName = "miuraText=";
	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 = "miuraColor=";
	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 = "miuraText=";
	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 = "90%";
	selectSize = "";
	if ( currentSize == "90%" ){
		selectSize = "100%";
	}
	else if ( currentSize == "100%" ){
		selectSize = "110%";
	}
	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 = "90%";
	document.body.style.fontSize = selectSize;
	setSize(selectSize);
}

////色合いの変更　//////////////////////////////////////////////////////////////////////////////
var targetLINK  = "changecss";
var css_keyword = "color";
var dir_path = "/shared/style/color/";
//
function setColorCookie(s){
	siteName = "miuraColor=";
	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);
}

//// フォーカスで文字を消去 //////////////////////////////////////////////////////////////////////////
function searchText(){
	document.getElementById("func_search_q").onclick = function(){
	　　if ( document.search.query.value == 'キーワードを入力' ) {
	　　document.search.query.value = '';
		}
	}
	document.getElementById("func_search_q").onfocus = function(){
	　　if ( document.search.query.value == 'キーワードを入力' ) {
	　　document.search.query.value = '';
		}
	}
	document.getElementById("func_search_q").onblur = function(){
	　　if ( document.search.query.value == '' ) {
　　	document.search.query.value = 'キーワードを入力';
		}
	}
}

//// 開閉メニュー //////////////////////////////////////////////////////////////////////////
function stackList(){
	var i;
	var tagname ="span";
	var tags = document.getElementsByTagName(tagname);
	var node;
	if(!tags)return;
	for(i=0;i<tags.length;i++){
		if(tags[i].className=="a1" || tags[i].className=="a3"){
			node = tags[i].childNodes[0].childNodes[0];
			node.style.display = "none";
			
			if(tags[i].className=="a3"){
				tags[i].parentNode.style.display = "none";
			}
		}

		if(tags[i].className=="a2"){
			node = tags[i].childNodes[0].childNodes[0];
			node.alt = "メニューを開きます。";
			node.src = "/shared/images/shared/icon_open.gif";
		}
	}
}
//
function expand(classname){
	var i;
	var tagname ="p";
	var tags = document.getElementsByTagName(tagname);
	var display;
	var node;
	if(!tags)return;
	for(i=0;i<tags.length;i++){
		if(tags[i].className==classname+"2"){
			node = tags[i].childNodes[0].childNodes[0].childNodes[0];
			if(node.alt=="メニューを閉じます。"){
				display = "none";
				node.alt = "メニューを開きます。";
				node.src = "/shared/images/shared/icon_open.gif";
			}else{
				display = "block";
				node.alt = "メニューを閉じます。";
				node.src = "/shared/images/shared/icon_close.gif";
			}
		}
		
		if(tags[i].className==classname+"3"){
				tags[i].style.display = display;
		}
	}	
}

//// onload //////////////////////////////////////////////////////////////////////////

window.onload = function() {
		getCookie();
		searchText();
		stackList();
}
