// JavaScript Document

/*
	フォントサイズ変更用の関数
*/

var defaultFontSize = "100%" // デフォルトのフォントサイズを設定します。

function fontSizeChanger(size) {
	createCookie('$fontSize', size, 1);
	window.location.reload();
}

function fontSizeSetterOnload() {
	var d = document
	var value = readCookie('$fontSize');
	var image = document.getElementById('fsAdj');
	
	image.className = value;
	
		
	document.body.style.fontSize = 	
		(value == 'smaller') ? "smaller" : 
		(value == 'medium') ? defaultFontSize :
		(value == 'larger') ? "larger" : defaultFontSize;
}

function createFontSizeAdjuster() {
	document.writeln(
		'<ul class="fontsize_adj">',
		'<li><a href="#" onclick="fontSizeChanger(\'smaller\'); return false;"><img src="images/adj_small_off.jpg" width="15" height="15" alt="文字サイズ 小" id="smaller" /></a></li><!--',
		'--><li><a href="#" onclick="fontSizeChanger(\'medium\'); return false;"><img src="images/adj_medium_off.jpg" width="15" height="15" alt="文字サイズ 中" id="medium" /></a></li><!--',
		'--><li><a href="#" onclick="fontSizeChanger(\'larger\'); return false;"><img src="images/adj_large_off.jpg" width="15" height="15" alt="文字サイズ 大" id="larger" /></a></li>',
		'</ul>'
	)			
}


/*
	Cookie周りの関数
*/

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;
}


/*
	関数を呼び出す
*/

window.onload = function activateIfLoaded() {
	fontSizeSetterOnload();
}

/*
	背景画像をウィンドウサイズにあわせる
*/
function changeHeight(id){
	var obj=document.all && document.all(id)
	|| document.getElementById && document.getElementById(id);
		if(obj){
		clientSize=getWindowClientSize();
		obj.style.height=""+(clientSize.height)+"px";
		}
	}



function getWindowClientSize(){
	var result={"height":0};
		if(document.documentElement && document.documentElement.clientHeight){
		result.height=document.documentElement.clientHeight;
		}else{
		result.height=document.body.clientHeight;	}
	return result;
	}
