var days = 10;    //クッキーの有効期限日数を設定
function cookie_css(){   //ページが読み込まれたときにCSS切り替え
    //クッキーを読み込んで保存してあるCSSのタイトルを読み込む
    cookie_css_title = read_cookie("NowCSS");
    //クッキーに保存してあるCSSに切り替える
    ChgCSS(cookie_css_title);
}
function cookie_css_r(){   //ページが読み込まれたときにCSS切り替え
    //クッキーを読み込んで保存してあるCSSのタイトルを読み込む
    cookie_css_title = read_cookie("NowCSS");
    //クッキーに保存してあるCSSに切り替える
    ChgCSS(cookie_css_title);
}
function ChgCSS(cssName) { //スタイルシートを切り替える
	if(document.styleSheets){
	   for(var i=0; i<document.styleSheets.length; i++){
	       if(document.styleSheets[i].title == cssName){
	           document.styleSheets[i].disabled=false;
	           set_cookie("NowCSS",document.styleSheets[i].title,days);
	       }
	       else{
	           document.styleSheets[i].disabled=true;
	       }
	   }
	}
}

//クッキーを設定する関数set_cookie
function set_cookie(cook_name,value_str,exp_d) {
    if (exp_d == 0) {
        expire_text = "";
        expire_day = "";
    }
    else {
        expire_day = new Date();
        expire_day.setTime(expire_day.getTime() + (exp_d * 24 * 60 * 60 * 1000));
        expire_day = expire_day.toGMTString();
        expire_text = "expires=";
    }
    document.cookie = cook_name + "=" + escape(value_str) + "; " + expire_text + expire_day;
}
//クッキーを読み込む関数read_cookie
function read_cookie(strings){
   cookie_data=document.cookie+";";
   first_pos=cookie_data.indexOf(strings,0);
   if(first_pos!=-1){
        first_pos += (strings.length+1);
        end_pos=cookie_data.indexOf(";",first_pos);
        value=cookie_data.substring(first_pos,end_pos);
        return(unescape(value));
   }
   return("small");
}
