/* クッキー */
function class_cookielib(){
	this.getCookie = getCookie;
	this.setCookie = setCookie;
	this.removeCookie = removeCookie;
	
	var expireDate = new Date();
	expireDate.setFullYear(expireDate.getFullYear()+1);
	expireStr = "expires=" + expireDate.toUTCString();

	function getCookie(name){
		var gc=name+"=";
		var Cookie=document.cookie;
		if (Cookie.length>0) {
			var start=Cookie.indexOf(gc);
			if (start!=-1) {
				start+=gc.length;
				terminus=Cookie.indexOf(";",start);
				if (terminus==-1) terminus=Cookie.length;
				return unescape(Cookie.substring(start,terminus));
			}
		}
		return '';
	}
	function setCookie() {
		var key = arguments[0];
		var val = arguments[1];
		var path = (typeof(arguments[2]) != 'undefined' ? arguments[2] : '/');
		var exp = (typeof(arguments[3]) != 'undefined' ? arguments[3] : expireStr);
		var sc = key + "=" + escape(val) + "; path=" + path + "; " + exp;
		document.cookie = sc;
	}
	function removeCookie(key,path) {
		if(!path){
			path = '/';
		}
		var rc = key + "=; path=" + path + "; expires=Thu, 1 Jan 1970 00:00:00 UTC";
		document.cookie = rc;
	}
}
var cookieObj = new class_cookielib();

/* テキストサイズの変更 */
var TextSize_val = 2;
var Text_Size = new Array();
Text_Size[0] = '80%';
Text_Size[1] = '90%';
Text_Size[2] = '100%';
Text_Size[3] = '110%';
Text_Size[4] = '120%';
Text_Size[5] = '130%';
function setTextSize(){
	var cookie
	var title
	if(cookieObj.getCookie('TextSize') != ''){
		TextSize_val = 1 * cookieObj.getCookie('TextSize');
	}
	document.write('<style type="text/css">');
	document.write('* body, * th, * td { font-size:' + Text_Size[TextSize_val] + '; }');
	document.write('</style>');
	cookie = readCookie("pub-style");
	title = cookie ? cookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);
}
function changeTextSize(num){
	var fl_update = false;
	var tmp_val = TextSize_val + num;
	if(tmp_val >= 0 && tmp_val < Text_Size.length){
		TextSize_val = tmp_val;
		fl_update = true;
	}
	if(fl_update){
		cookieObj.setCookie('TextSize',TextSize_val,'/','');
		window.location.reload();
	}
}
function changeTextSizeMidle(num){
	TextSize_val = 2;
	cookieObj.setCookie('TextSize',TextSize_val,'/','');
	window.location.reload();
}
/*　テクストサイズ変更のリンクを表示する。　*/
function outputTextSizeCtrl(){
	if(document.layers){
		return;
	}
	document.write('文字サイズ');
	if(TextSize_val < Text_Size.length - 1){
		document.write('<a href="#" onclick="changeTextSize(1);return false;" ')
		document.write('onkeypress="changeTextSize(1);return false;" ')
		document.write('class="fontkakomi">大</a>');
	}
	else{
		document.write('<span class="fontkakomi">大</span>');
	}
	document.write('　');
	document.write('<a href="#" onclick="changeTextSizeMidle(1);return false;" onkeypress="changeTextSizeMidle(1);return false;" class="fontkakomi">中</a>');
	document.write('　');

	if(TextSize_val != 0){
		document.write('<a href="#" onclick="changeTextSize(-1);return false;" onkeypress="changeTextSize(-1);return false;" class="fontkakomi">小</a>');
	}
	else{
		document.write('<span class="fontkakomi">小</span>');
	}
}
function setActiveStyleSheet(title) {
  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;
    }
  }
  createCookie("pub-style", title, 365);
}

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("pub-style");
var title = cookie ? cookie : getPreferredStyleSheet();
if (title == null) title = "C"
setActiveStyleSheet(title);