// JavaScript Document
// クッキー保存 setCookie(クッキー名, クッキーの値, クッキーの有効日数); //
function setCookie(c_name,value,expiredays){
    // pathの指定
	var cnt=0;
    /*var path = location.pathname;
    // pathをフォルダ毎に指定する場合のIE対策
    var paths = new Array();
    paths = path.split("/");
    if(paths[paths.length-1] != ""){
		
		paths[paths.length-1] = "";
		
		path = paths.join("/");
		
		
    }*/
    // 有効期限の日付
    var extime = new Date().getTime();
    var cltime = new Date(extime + (60*60*24*1000*expiredays));
    var exdate = cltime.toUTCString();
    // クッキーに保存する文字列を生成
    var s="";
    s += c_name +"="+ escape(value);// 値はエンコードしておく
    s += "; path=/"/*+ path*/;
    if(expiredays){
        s += "; expires=" +exdate+"; ";
    }else{
        s += "; ";
    }
    // クッキーに保存
    document.cookie=s;
}

// クッキーの値を取得 getCookie(クッキー名); //
function getCookie(c_name){
    var st="";
    var ed="";
    if(document.cookie.length>0){
        // クッキーの値を取り出す
        st=document.cookie.indexOf(c_name + "=");
        if(st!=-1){
            st=st+c_name.length+1;
            ed=document.cookie.indexOf(";",st);
            if(ed==-1) ed=document.cookie.length;
            // 値をデコードして返す
            return unescape(document.cookie.substring(st,ed));
        }
    }
    return "";
}
// クッキーの値をアラートで表示
function checkCookie(){
    if(getCookie('backnumber')){
        var setName = getCookie('backnumber');
        alert(setName);
    }
}
/*function GetCookie( name )
{
    var result = null;

    var cookieName = name + '=';
    var allcookies = document.cookie;

    var position = allcookies.indexOf( cookieName );
    if( position != -1 )
    {
        var startIndex = position + cookieName.length;

        var endIndex = allcookies.indexOf( ';', startIndex );
        if( endIndex == -1 )
        {
            endIndex = allcookies.length;
        }

        result = decodeURIComponent(
            allcookies.substring( startIndex, endIndex ) );
    }

    return result;
}
*/
//直下
function getBackgNumber(){
	var num=getCookie("backnumber");
	setBackground(num);
}
//second
function getBackgNumber2(){
	var num=getCookie("backnumber");
	setBackground2(num);
}
//third/folder
function getBackgNumber3(){
	var num=getCookie("backnumber");
	setBackground3(num);
}
//third/folder/folder
function getBackgNumber3_2(){
	var num=getCookie("backnumber");
	setBackground3_2(num);
}

//直下
function setBackground(num){
	if(num<2)	{
		/*body.style.backgroundImage = "url(../css/img/background1.png)";
		body.style.backgroundImage = "../css/img/background1.png";*/
		document.getElementById("back").style.backgroundImage = "url(css/img/background1.png)";
		document.getElementById("button1").style.backgroundImage = "url(css/img/1_backcircle_red.png)";
		document.getElementById("button2").style.backgroundImage = "url(css/img/2_backcircle_gray.png)";
		document.getElementById("button3").style.backgroundImage = "url(css/img/3_backcircle_gray.png)";
		document.getElementById("button1").src = "css/img/1_backcircle_red.png";
		document.getElementById("button2").src = "css/img/2_backcircle_gray.png";
		document.getElementById("button3").src = "css/img/3_backcircle_gray.png";
		setCookie('backnumber',1,7);
	}else if(num<3){
		/*body.style.backgroundImage = "url(../css/img/background2.png)";
		body.style.backgroundImage = "../css/img/background2.png";*/
		document.getElementById("back").style.backgroundImage = "url(css/img/background2.png)";
		document.getElementById("button1").style.backgroundImage = "url(css/img/1_backcircle_gray.png)";
		document.getElementById("button2").style.backgroundImage = "url(css/img/2_backcircle_red.png)";
		document.getElementById("button3").style.backgroundImage = "url(css/img/3_backcircle_gray.png)";
		document.getElementById("button1").src = "css/img/1_backcircle_gray.png";
		document.getElementById("button2").src = "css/img/2_backcircle_red.png";
		document.getElementById("button3").src = "css/img/3_backcircle_gray.png";
		setCookie('backnumber',2,7);
	}else{
		/*body.style.backgroundImage = "url(../css/img/background3.png)";
		body.style.backgroundImage = "../css/img/background3.png";*/
		document.getElementById("back").style.backgroundImage = "url(css/img/background3.png)";
		document.getElementById("button1").style.backgroundImage = "url(css/img/1_backcircle_gray.png)";
		document.getElementById("button2").style.backgroundImage = "url(css/img/2_backcircle_gray.png)";
		document.getElementById("button3").style.backgroundImage = "url(css/img/3_backcircle_red.png)";
		document.getElementById("button1").src = "css/img/1_backcircle_gray.png";
		document.getElementById("button2").src = "css/img/2_backcircle_gray.png";
		document.getElementById("button3").src = "css/img/3_backcircle_red.png";
		setCookie('backnumber',3,7);
	}
}
//third/folder/folder
function setBackground3_2(num){
	if(num<2)	{
		/*body.style.backgroundImage = "url(../css/img/background1.png)";
		body.style.backgroundImage = "../css/img/background1.png";*/
		document.getElementById("back").style.backgroundImage = "url(../../../css/img/background1.png)";
		document.getElementById("button1").style.backgroundImage = "url(../../../css/img/1_backcircle_red.png)";
		document.getElementById("button2").style.backgroundImage = "url(../../../css/img/2_backcircle_gray.png)";
		document.getElementById("button3").style.backgroundImage = "url(../../../css/img/3_backcircle_gray.png)";
		document.getElementById("button1").src = "../../../css/img/1_backcircle_red.png";
		document.getElementById("button2").src = "../../../css/img/2_backcircle_gray.png";
		document.getElementById("button3").src = "../../../css/img/3_backcircle_gray.png";
		setCookie('backnumber',1,7);
	}else if(num<3){
		/*body.style.backgroundImage = "url(../css/img/background2.png)";
		body.style.backgroundImage = "../css/img/background2.png";*/
		document.getElementById("back").style.backgroundImage = "url(../../../css/img/background2.png)";
		document.getElementById("button1").style.backgroundImage = "url(../../../css/img/1_backcircle_gray.png)";
		document.getElementById("button2").style.backgroundImage = "url(../../../css/img/2_backcircle_red.png)";
		document.getElementById("button3").style.backgroundImage = "url(../../../css/img/3_backcircle_gray.png)";
		document.getElementById("button1").src = "../../../css/img/1_backcircle_gray.png";
		document.getElementById("button2").src = "../../../css/img/2_backcircle_red.png";
		document.getElementById("button3").src = "../../../css/img/3_backcircle_gray.png";
		setCookie('backnumber',2,7);
	}else{
		/*body.style.backgroundImage = "url(../css/img/background3.png)";
		body.style.backgroundImage = "../css/img/background3.png";*/
		document.getElementById("back").style.backgroundImage = "url(../../../css/img/background3.png)";
		document.getElementById("button1").style.backgroundImage = "url(../../../css/img/1_backcircle_gray.png)";
		document.getElementById("button2").style.backgroundImage = "url(../../../css/img/2_backcircle_gray.png)";
		document.getElementById("button3").style.backgroundImage = "url(../../../css/img/3_backcircle_red.png)";
		document.getElementById("button1").src = "../../../css/img/1_backcircle_gray.png";
		document.getElementById("button2").src = "../../../css/img/2_backcircle_gray.png";
		document.getElementById("button3").src = "../../../css/img/3_backcircle_red.png";
		setCookie('backnumber',3,7);
	}
}
//second
function setBackground2(num){
	if(num<2)	{
		/*body.style.backgroundImage = "url(../css/img/background1.png)";
		body.style.backgroundImage = "../css/img/background1.png";*/
		document.getElementById("back").style.backgroundImage = "url(../css/img/background1.png)";
		document.getElementById("button1").style.backgroundImage = "url(../css/img/1_backcircle_red.png)";
		document.getElementById("button2").style.backgroundImage = "url(../css/img/2_backcircle_gray.png)";
		document.getElementById("button3").style.backgroundImage = "url(../css/img/3_backcircle_gray.png)";
		document.getElementById("button1").src = "../css/img/1_backcircle_red.png";
		document.getElementById("button2").src = "../css/img/2_backcircle_gray.png";
		document.getElementById("button3").src = "../css/img/3_backcircle_gray.png";
		setCookie('backnumber',1,7);
	}else if(num<3){
		/*body.style.backgroundImage = "url(../css/img/background2.png)";
		body.style.backgroundImage = "../css/img/background2.png";*/
		document.getElementById("back").style.backgroundImage = "url(../css/img/background2.png)";
		document.getElementById("button1").style.backgroundImage = "url(../css/img/1_backcircle_gray.png)";
		document.getElementById("button2").style.backgroundImage = "url(../css/img/2_backcircle_red.png)";
		document.getElementById("button3").style.backgroundImage = "url(../css/img/3_backcircle_gray.png)";
		document.getElementById("button1").src = "../css/img/1_backcircle_gray.png";
		document.getElementById("button2").src = "../css/img/2_backcircle_red.png";
		document.getElementById("button3").src = "../css/img/3_backcircle_gray.png";
		setCookie('backnumber',2,7);
	}else{
		/*body.style.backgroundImage = "url(../css/img/background3.png)";
		body.style.backgroundImage = "../css/img/background3.png";*/
		document.getElementById("back").style.backgroundImage = "url(../css/img/background3.png)";
		document.getElementById("button1").style.backgroundImage = "url(../css/img/1_backcircle_gray.png)";
		document.getElementById("button2").style.backgroundImage = "url(../css/img/2_backcircle_gray.png)";
		document.getElementById("button3").style.backgroundImage = "url(../css/img/3_backcircle_red.png)";
		document.getElementById("button1").src = "../css/img/1_backcircle_gray.png";
		document.getElementById("button2").src = "../css/img/2_backcircle_gray.png";
		document.getElementById("button3").src = "../css/img/3_backcircle_red.png";
		setCookie('backnumber',3,7);
	}
}
//third/folder
function setBackground3(num){
	if(num<2)	{
		/*body.style.backgroundImage = "url(../css/img/background1.png)";
		body.style.backgroundImage = "../css/img/background1.png";*/
		document.getElementById("back").style.backgroundImage = "url(../../css/img/background1.png)";
		document.getElementById("button1").style.backgroundImage = "url(../../css/img/1_backcircle_red.png)";
		document.getElementById("button2").style.backgroundImage = "url(../../css/img/2_backcircle_gray.png)";
		document.getElementById("button3").style.backgroundImage = "url(../../css/img/3_backcircle_gray.png)";
		document.getElementById("button1").src = "../../css/img/1_backcircle_red.png";
		document.getElementById("button2").src = "../../css/img/2_backcircle_gray.png";
		document.getElementById("button3").src = "../../css/img/3_backcircle_gray.png";
		setCookie('backnumber',1,7);
	}else if(num<3){
		/*body.style.backgroundImage = "url(../css/img/background2.png)";
		body.style.backgroundImage = "../css/img/background2.png";*/
		document.getElementById("back").style.backgroundImage = "url(../../css/img/background2.png)";
		document.getElementById("button1").style.backgroundImage = "url(../../css/img/1_backcircle_gray.png)";
		document.getElementById("button2").style.backgroundImage = "url(../../css/img/2_backcircle_red.png)";
		document.getElementById("button3").style.backgroundImage = "url(../../css/img/3_backcircle_gray.png)";
		document.getElementById("button1").src = "../../css/img/1_backcircle_gray.png";
		document.getElementById("button2").src = "../../css/img/2_backcircle_red.png";
		document.getElementById("button3").src = "../../css/img/3_backcircle_gray.png";
		setCookie('backnumber',2,7);
	}else{
		/*body.style.backgroundImage = "url(../css/img/background3.png)";
		body.style.backgroundImage = "../css/img/background3.png";*/
		document.getElementById("back").style.backgroundImage = "url(../../css/img/background3.png)";
		document.getElementById("button1").style.backgroundImage = "url(../../css/img/1_backcircle_gray.png)";
		document.getElementById("button2").style.backgroundImage = "url(../../css/img/2_backcircle_gray.png)";
		document.getElementById("button3").style.backgroundImage = "url(../../css/img/3_backcircle_red.png)";
		document.getElementById("button1").src = "../../css/img/1_backcircle_gray.png";
		document.getElementById("button2").src = "../../css/img/2_backcircle_gray.png";
		document.getElementById("button3").src = "../../css/img/3_backcircle_red.png";
		setCookie('backnumber',3,7);
	}
}