// read cookie data and set css file
var cookieData = readCookie("style");
if(!cookieData) cookieData = "Default";

var cssfile = "";

if(cookieData == "Large") {
 cssfile = "css/font_large.css";
} else {
 cssfile = "css/font_default.css";
}
document.write ('<link rel="stylesheet" href="'+cssfile+'" type="text/css" />');


window.self.focus();

/* font change script */
// change idName.backgrounds
function defaultFontSize(sl, idName) {
  position = "0px -23px";
  basePosition = "0px 0px";

  // change background
  var li3 = document.getElementById("fontNaviLarge");
  li3.style.backgroundPosition = basePosition;

  // change focused size background
  var li = document.getElementById("fontNavi"+sl);
  li.style.backgroundPosition = position;
  setDocumentSize(sl, idName);
  createCookie("style", sl, 365);
}

function zoomFontSize(sl, idName) {
  position = "0px -25px";
  basePosition = "0px 0px";

  // change background
  var li2 = document.getElementById("fontNaviDefault");
  li2.style.backgroundPosition = basePosition;

  // change focused size background
  var li = document.getElementById("fontNavi"+sl);
  li.style.backgroundPosition = position;
  setDocumentSize(sl, idName);
  createCookie("style", sl, 365);
}

// change idName.fontSize by sl
function setDocumentSize(sl, idName) {
  if(sl == 'Default') {
    size = "100%";
  } else if(sl == 'Large') {
    size = "120%";
  } else {
    size = "100%";
  }

  // change font size
  obj = document.getElementById(idName);
  obj.style.fontSize = size;
}

// create cookie
function createCookie(name,value,days) {
  var expires = "";
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  document.cookie = name + "=" + value + expires + "; path=/";
}

// read cookie
function readCookie(name) {
  var nameEqual = 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(nameEqual) == 0 ){
      var result = c.substring(nameEqual.length,c.length);
      return result;
    }
  }
  return null;
}
 
// init --onload function
function init() {
  var cookieData = readCookie("style");
  if(!cookieData) cookieData = "Default";

  var position = "";
  var lia = document.getElementById("fontNavi"+cookieData);

  // change focused size background
  if(cookieData == "Default"){
    position = "0px -23px";
    lia.style.backgroundPosition = position;
  }else if(cookieData == "Large"){
    position = "0px -25px";
    lia.style.backgroundPosition = position;
  }
}

