// 日付取得
today = new Date();
month = today.getMonth()+1; // 月

// リンク
function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
}

// 画像変更表示
function changeImg()
{
// ロゴ画像表示
//    rogoName = "img/rogo/rogo" + Math.floor(Math.random()*70) + ".gif"
    rogoName = "img/rogo/rogo55.gif";
    document.rogoImg.src= rogoName;

// トップ画像表示
    switch(month)
    { // 月によって分ける
        case 3: // 春
        case 4:
            document.topImg.src= "img/top_spring.jpg";
            break;
        case 5: // 夏
        case 6:
        case 7:
        case 8:
            document.topImg.src= "img/top_summer.jpg";
            break;
        case 9: // 秋
        case 10:
        case 11:
            document.topImg.src= "img/top_autumn.jpg";
            break;
        case 12: // 冬
        case 1:
        case 2:
            document.topImg.src= "img/top_winter.jpg";
            break;
        default:
            document.topImg.src= "img/top.jpg";
            break;
    }

}

// 雪を降らす
sx = new Array();
sy = new Array();
sp = new Array();
sw = new Array();
swlimit = new Array();
swmove = new Array();
light=new Array();
seifu=new Array();
scrnx = -10;
scrny = -10;
num = 25;
reroad = false;
for(i=0; i<num; i++)
{
    sx[i] = -10;
    sy[i] = -10;
    sp[i] = Math.floor(Math.random()* 5) + 1;
    sw[i] = Math.floor(Math.random()* 7) - 3;
    swlimit[i] = (Math.floor(Math.random() * 10) + 50) * 10;
    swmove[i] = 0;
    light[i]=120*Math.random()-20;
    ff=i%2;
    if(ff===0){
        seifu[i]=-10;
    }
    else if(ff==1){
        seifu[i]=10;
    }

    switch(month)
    { // 月によって分ける
        case 3: // 春
        case 4:
            document.write("<img src='img/move_spring.gif' style='position:absolute;"+
                           "width:8px;height:8px;z-index:3;top:"+
                           sy[i]+"px;left:"+sx[i]+"px;' name='moveImgName"+i+
                           "' style='position:absolute;display:block;filter:alpha(style=2)'>");
            break;
        case 5: // 夏
        case 6:
        case 7:
        case 8:
            document.write("<img src='img/move_summer.gif' style='position:absolute;"+
                           "width:8px;height:8px;z-index:3;top:"+
                           sy[i]+"px;left:"+sx[i]+"px;' name='moveImgName"+i+
                           "' style='position:absolute;display:block;filter:alpha(style=2)'>");
            break;
        case 9: // 秋
        case 10:
        case 11:
            document.write("<img src='img/move_autumn.gif' style='position:absolute;"+
                           "width:12px;height:12px;z-index:3;top:"+
                           sy[i]+"px;left:"+sx[i]+"px;' name='moveImgName"+i+
                           "' style='position:absolute;display:block;filter:alpha(style=0)'>");
            break;
        case 12: // 冬
        case 1:
        case 2:
            document.write("<img src='img/move_winter.gif' style='position:absolute;"+
                           "width:8px;height:8px;z-index:3;top:"+
                           sy[i]+"px;left:"+sx[i]+"px;' name='moveImgName"+i+
                           "' style='position:absolute;display:block;filter:alpha(style=2)'>");
            break;
        default:
            document.write("<img src='img/move.gif' style='position:absolute;"+
                           "width:8px;height:8px;z-index:3;top:"+
                           sy[i]+"px;left:"+sx[i]+"px;' name='moveImgName"+i+
                           "' style='position:absolute;display:block;filter:alpha(style=2)'>");
            break;
    }
}

function moveImg()
{
    scrny = document.body.clientHeight;
    scrnx = document.body.clientWidth;
    for(i=0; i<num; i++)
    {
        if(reroad === false)
        {
            sx[i] = Math.floor(Math.random()* scrnx);
            document.images["moveImgName"+i].style.left = sx[i];
        }
        sy[i] += sp[i];
        if(sy[i] > scrny){
            sy[i] = -10;
        }

        sx[i] += sw[i];
        swmove[i] += sw[i];
        if(Math.abs(swmove[i]) > swlimit[i]){
            sw[i] = sw[i] - (sw[i]*2)
            swmove[i] = 0;
        }
        if(sx[i] > (scrnx - 20)){
            sx[i] = Math.floor(Math.random()* scrnx);
        }

        light[i]=light[i]+seifu[i]/2;
        document.images["moveImgName"+i].style.top = sy[i];
        document.images["moveImgName"+i].style.left = sx[i];
        document.images["moveImgName"+i].filters["alpha"].opacity=light[i];
        if((light[i]>100)||(light[i]<-20)){
            seifu[i]=-1*seifu[i];
        }
    }
    reroad = true;
}


