//----↓スタイルシート変更用↓--------------------
//-------------------------------------------------- 
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;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

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;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet('fontsize_s');
setActiveStyleSheet(title);

//ホームページに登録
var ie  = navigator.userAgent.indexOf("MSIE ");
var verIE = 0, winIE = -1;
if(ie >= 0) {
    verIE = parseFloat(navigator.userAgent.substr(ie + 5));
    winIE = navigator.userAgent.indexOf("Windows");
}
function setHome (obj) {
    if(verIE >= 5.0 && winIE >= 0)
        obj.setHomepage(location.href);
    else
        alert("このブラウザーではホームページに設定できません。");
}
//お気に入りに登録
function addFav () {
    if(verIE >= 5.0 && winIE >= 0)
        window.external.AddFavorite(location.href,document.title);
    else
        alert("このブラウザーでは追加できません。");
}
//TreeMenu
f = 1;
function setEvent () {
    if(!document.getElementById) return;
    var arrayB = document.getElementsByTagName("DIV");
    for(i = 0; i < arrayB.length; i++) {
        if(arrayB[i].parentNode.tagName == "LI") {
            arrayB[i].onclick = expandMenu;
        }
    }
}

function expandMenu (e) {
     if(window.event) e = window.event;
     var b = null;
     if(e.srcElement) b = e.srcElement;
     else if(e.currentTarget) b = e.currentTarget;
     var ul = b.nextSibling;
     while(ul) {
         if(ul.nodeType == 1 && ul.tagName == "UL")
            break;
         ul = ul.nextSibling;
     }
     if(ul) {
         if(ul.style.display == "block")
             ul.style.display = "none";
         else ul.style.display = "block";
     }
}

if(document.getElementById) {
    document.write("<style type='text/css'>" +
                   "ul ul { display: none; }" +
                   "</style>");
}

//PopupMenu

var ie  = navigator.userAgent.indexOf("MSIE ");
var verIE = 0, winIE = -1;
if(ie >= 0) {
    verIE = parseFloat(navigator.userAgent.substr(ie + 5));
    winIE = navigator.userAgent.indexOf("Windows");
}

function getElemLeft (elem) {//位置を計算する関数 X軸までの距離を計算する
    var x = elem.offsetLeft;
    var pa = elem.offsetParent;//offsetParentは
    while(pa) {
        if(pa.offsetLeft) x += pa.offsetLeft;
        pa = pa.offsetParent;
    }
    return x;
}
function getElemTop (elem) {//位置を計算する関数 上端までの距離を計算する
    var y = elem.offsetTop;
    var pa = elem.offsetParent;
    while(pa) {
        if(pa.offsetTop) y += pa.offsetTop;
        pa = pa.offsetParent;
    }
    return y;
}

var currentId = "";
function showMenu (e, id) {
    if(!document.getElementById) return;
    if(currentId == id) return;
    closeMenu();
    var obj = document.getElementById(id);
    var x, y;
    var elm;
    if(e.srcElement) elem = e.srcElement;
    else elem = e.currentTarget;
    if(elem.offsetParent && !(verIE > 0 && winIE < 0)) {
        x = getElemLeft(elem)-20;
        y = getElemTop(elem) + elem.offsetHeight;
    }
    else {
        var x = e.clientX + scrollLeft();
        var y = e.clientY + scrollTop();
        x -= 60; y += 16;
    }
    obj.style.left = x + "px";
    obj.style.top = y + "px";
    obj.style.visibility = "visible";
    currentId = id;
}
function closeMenu () {
    if(!document.getElementById) return;
    if(!currentId) return;
    var obj = document.getElementById(currentId);
    obj.style.visibility = "hidden";
    currentId = "";
}
function bodyClick (e) {
    closeMenu();
}
if(document.getElementById)
    document.onclick = bodyClick;

function scrollLeft () {
    if(window.pageXOffset)
        return window.pageXOffset;
    if(document.compatMode == "CSS1Compat")
        return document.body.parentNode.scrollLeft;
    if(document.body.scrollLeft)
        return document.body.scrollLeft;
    return 1;
}
function scrollTop () {
    if(window.pageYOffset)
        return window.pageYOffset;
    if(document.compatMode == "CSS1Compat")
        return document.body.parentNode.scrollTop;
    if(document.body.scrollTop)
        return document.body.scrollTop;
    return 1;
}
// 表示モード切替
function displayMode(mode) {
	document.getElementById('obj').style.display = mode;
}

//ShowhideMenu

function showHide(obj) {
    if(!document.getElementById) return;
    var style = document.getElementById(obj).style;
    if(style.display == "block") style.display = "none";
    else { style.display = "block"; }
}
if(document.getElementById) {
    document.write("<style type='text/css'>");
    document.write("div#div1, div#div2, div#div3, div#div4, div#div5,div#div6, div#div7, div#div8, div#div9, div#div10, div#div11,div#div12, div#div13, div#div14, div#div15{ display: none;}");
    document.write("</style>");
}

function showHide2(obj) {
    if(!document.getElementById) return;
    var style = document.getElementById(obj).style;
    if(style.display == "none") style.display = "block";
    else { style.display = "none"; }
}
if(document.getElementById) {
    document.write("<style type='text/css'>");
    document.write("div#div11, div#div12, div#div13, div#div14, div#div15, div#div16, div#div17{ display: block;}");
    document.write("</style>");
}

//SHOW MSG
isIE4 = (navigator.appVersion.charAt(0)>=4 && (navigator.appVersion).indexOf("MSIE") != -1)
isNN4 = (navigator.appVersion.charAt(0)>=4 && (navigator.appName).indexOf("Netscape")!=-1);

function link_info(m) {
  if(m==null)  m = ""; 
  if(isIE4) {
    el = document.all("msg"); 
    el.innerHTML = m;
}
else if(isNN4) {
    lay = document.layers["link"].document.layers["msg"];
    lay.document.open();
    lay.document.write("<font style='font-size:10pt' color='#C0C0C0'>"+ m +"</font>");
    lay.document.close(); 
   }
}

function popupCenter(url, name, width, height) {
    var left = (screen.width - width) / 2;
    var top  = (screen.height - height) / 2;
    var options = "left=" + left + ",top=" + top + 
       ",width=" + width + ",height=" + height;
    window.open(url, name, options);
}

//右クリック禁止
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")

//自動ジャンプ 
//<a href="..html" onmouseover="colormove();">enter</a> 
//<span id="s1">■</span>
//<span id="s2">■</span>
//<span id="s3">■</span>
//<span id="s4">■</span>
//<span id="s5">■</span>
//<span id="s6">■</span>

var jump_url = "javascript:history.go(-1)";
var dom = document.getElementById ? 1 : 0;
var speed =50;
var brink_color ="#8aabcc";
var col = new Array();
var name = new Array("s1","s2","s3","s4","s5","s6");
var arr_no = name.length-1;
var no=-1;
var flag = 0;

function colormove(){
if(flag==0) {
for(var i=0;i<=arr_no;i++){
if(document.all) { col[i] = document.all(name[i]).style.color;}
else if(dom) { col[i] = document.getElementById(name[i]).style.color;}
}
flag=1;
}
if(no < arr_no) { no++;}
else if(no == arr_no)  {
clearTimeout(Tim);
location.href = jump_url;
return true;
}
if(document.all) { document.all(name[no]).style.color = brink_color;}
else if(dom) { document.getElementById(name[no]).style.color = brink_color;}
Tim = setTimeout("colormove()",speed);
}
//チェックボックスを押さないと変えられないフォーム
function switchReadOnly(chkbox, elmname) {
    var input = chkbox.form.elements[elmname];
    input.readOnly = chkbox.checked ? false : true;
}

//小窓が開く
function popupCenter(url, name, width, height) {
    var left = (screen.width - width) / 2;
    var top  = (screen.height - height) / 2;
    var options = "left=" + left + ",top=" + top + 
       ",width=" + width + ",height=" + height;
    window.open(url, name, options);
}
//
function LoadImg() {
  if (document.images) {
    var imgFiles = LoadImg.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function ImgRes() {
  if (document.ImgData != null)
    for (var i=0; i<(document.ImgData.length-1); i+=2)
      document.ImgData[i].src = document.ImgData[i+1];
}

function SwpImg() {
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.ImgData;
  for (i=0; i < (SwpImg.arguments.length-2); i+=3) {
    objStr = SwpImg.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = SwpImg.arguments[i+2];
  } }
  document.ImgData = swapArray;
}

function StMsg(msgStr) {
  status=msgStr;
  document.ReValue = true;
}


function link_info(m) {
  if(m==null)  m = "";
  if(isIE4) {
    el = document.all("msg");
    el.innerHTML = m;
   }
  else if(isNN4) {
    lay = document.layers["link"].document.layers["msg"];
    lay.document.open();
    lay.document.write("<font style='font-size:10pt' color='#808080'>"+m+"</font>");
    lay.document.close(); 
   }
}

