// フォントサイズ3段階切替固定版
uaName = navigator.userAgent;
appName = navigator.appVersion;
var fontSizeUnit = "px";
var perOrder = 2;
var defaultSize = 10;
var ckName = "hidefont";
var ckDays = 30;
var ckPath = "/"
var fsCK = GetCookie(ckName);
ln = 0;
ls = 0;


if ( fsCK == null ) {
  currentSize = defaultSize;
}
else{
  currentSize = Number(fsCK);
}


if ( fsCK == 12 ){
  ln = 1;
  ls = -1;
}
else if ( fsCK == 11 ){
  ln = 1;
  ls = -1;
}
else if ( fsCK == 9 ){
  ln = -1;
  ls = 1;
}
else if ( fsCK == 8 ){
  ln = -1;
  ls = 1;
}


function fscRef(){
  if (( document.layers )||(( appName.indexOf("Mac",0) != -1 ) && ( uaName.indexOf("MSIE 4.0",0) != -1 ))){
    return false;
  }
  else if( document.body ){
	var i;
	var len = document.getElementsByClassName("font_10px").length;
	for (i = 0; i < len; i++) {
	document.getElementsByClassName("font_10px")[i].style.fontSize = currentSize + fontSizeUnit;
	document.getElementsByClassName("font_10px")[i].style.lineHeight = currentSize + 2 + fontSizeUnit;
	}
	var len = document.getElementsByClassName("font_11px").length;
	for (i = 0; i < len; i++) {
	document.getElementsByClassName("font_11px")[i].style.fontSize = currentSize + 1 + fontSizeUnit;
	document.getElementsByClassName("font_11px")[i].style.lineHeight = currentSize + 4 + fontSizeUnit;
	}
	var len = document.getElementsByClassName("font_12px").length;
	for (i = 0; i < len; i++) {
	document.getElementsByClassName("font_12px")[i].style.fontSize = currentSize + 2 + fontSizeUnit;
	document.getElementsByClassName("font_12px")[i].style.lineHeight = currentSize + 8 + fontSizeUnit;
	}
	var len = document.getElementsByClassName("font_12px_a").length;
	for (i = 0; i < len; i++) {
	document.getElementsByClassName("font_12px_a")[i].style.fontSize = currentSize + 2 + fontSizeUnit;
	document.getElementsByClassName("font_12px_a")[i].style.lineHeight = currentSize + 6 + fontSizeUnit;
	}
	var len = document.getElementsByClassName("font_14px").length;
	for (i = 0; i < len; i++) {
	document.getElementsByClassName("font_14px")[i].style.fontSize = currentSize + 4 + fontSizeUnit;
	document.getElementsByClassName("font_14px")[i].style.lineHeight = currentSize + 6 + fontSizeUnit;
	}
	var len = document.getElementsByClassName("font_16px").length;
	for (i = 0; i < len; i++) {
	document.getElementsByClassName("font_16px")[i].style.fontSize = currentSize + 6 + fontSizeUnit;
	document.getElementsByClassName("font_16px")[i].style.lineHeight = currentSize + 12 + fontSizeUnit;
	}
  }
}


function fsc( CMD ){
  if( CMD == "larger" ){
    if ( ln >= 1 ){
    return false;
    }
    else{
    ln++;
    ls--;
    var newSize = 12;
    SetCookie( ckName , newSize );
    }
  }
  if( CMD == "smaller" ){
    if ( currentSize != perOrder ){
    if ( ls >= 1 ){
    return false;
    }
    else{
    ln--;
    ls++;
    var newSize = 8;
    SetCookie( ckName , newSize );
    }
  }
    else{
      var newSize=Number(currentSize);
    }
  }
  if( CMD == "default" ){
    ls = 0;
    ln = 0;
    var newSize = defaultSize;
    DeleteCookie( ckName );
  }
  if( document.layers ){
    window.alert( "Sorry! Netscape Communicator4.x is not supported." );
    return false;
  }
  else if(( appName.indexOf("Mac",0) != -1 ) && ( uaName.indexOf("MSIE 4.0",0) != -1)){
    window.alert( "Sorry! MacIE4.0 is not supported." );
    return false;
  }
  else{
  currentSize = newSize;
  fscRef();
  }
}

function SetCookie(name,value){
  var dobj = new Date();
  dobj.setTime( dobj.getTime() + 24 * 60 * 60 * ckDays * 1000);
  var expiryDate = dobj.toGMTString();
  document.cookie = name + '=' + escape(value)+ ';expires=' + expiryDate + ';path=' + ckPath;
}

function GetCookie (name){
  var arg  = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen){
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
   return null;
}

function getCookieVal (offset){
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
  endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset,endstr));
}
function DeleteCookie(name){
  if (GetCookie(name)) {
    document.cookie = name + '=' +
    '; expires=Thu, 01-Jan-70 00:00:01 GMT;path='+ckPath;
  }
}

//EOF

