﻿// CSS設定用 JavaScript ファイル
// ヘッダーで参照する

function getCookie(name)  {
var cookieStr = document.cookie
var existNum = cookieStr.indexOf(name)
  if(existNum != -1)  {
    start = existNum + name.length + 1
    end = cookieStr.indexOf(";" , start)
    if(end == -1) {
      end = cookieStr.length
    }
    var cookieValue = cookieStr.substring(start,end)
    return cookieValue
  } else {
    return ""
  }
}

//フォームに入力された情報をクッキーに記憶する。
//フォームの寿命は入力されたときから1年
function memoryCookie() {
  expires = new Date()
  expires.setTime(expires.getTime() + 24*60*60*1000*365)
  document.cookie = "your_name=" + document.forms[0].your_name.value + ";expires=" + expires.toGMTString()
  instruct()
}

function instruct() {
  var str = "設定が完了しまいた。\n\n"
  str += "次回、アクセスされたときから、\n"
  str += "この設定が反映されます。"
  alert(str)
}


var check = getCookie("your_name")
if(check != "") {
  document.write("<LINK REL=stylesheet TYPE=text/css HREF=/" + getCookie('your_name') + ">")
} else  {
  document.write("<LINK REL=stylesheet TYPE=text/css HREF=/med.css>")
}

window.onload = function(){
    if(getCookie("your_name") != "") {
      document.forms[0].your_name.value = getCookie("your_name")
    }
};
