function rnd(){
	return Math.random();
}


function xRnd(){
	return (rnd()/10);
}


function yRnd(){
	return (2 + 2*( .5 - rnd() ));
}


//修正部分（2008.4.15）
//季節の設定
now = new Date();
mon = now.getMonth()+1; //１を足すこと
you = now.getDay(); //曜日

//動作テスト用関数の受け入れ（通常必要ありません）
//URLの？以降を取得
get_text = document.location.search;
get_text = get_text.substring(1,get_text.length);
if (get_text > 0) {mon = get_text;}
//動作テスト用関数の受け入れ（終了）

if (mon == 1) {
	//1月
	//降る物
	var flakes = Array("yuki.gif","yuki_turn.gif","yuki_turn2.gif","yukiB.gif","yukiB_turn.gif","yukiB_turn2.gif");
} else if (mon == 2) {
	//2月
	var flakes = Array("yuki.gif","yuki_turn.gif","yuki_turn2.gif","lightB.png","lightB2.png","lightB3.png","heart1.gif","heart2.gif");
} else if (mon == 3) {
	//３月
	var flakes = Array("butterfly04.gif","butterfly05.gif","hana1.gif","hana2.gif","hana3.gif","hana4.gif");
} else if (mon == 4) {
	//４月
	var flakes = Array("sakura.gif","sakura_turn.gif","sakura_turn2.gif");
} else if (mon == 5) {
	//５月
	var flakes = Array("leaf.gif","leaf2.gif","leaf3.gif");
} else if (mon == 6) {
	//６月
	var flakes = Array("rain1.png","rain2.png","rain3.png");
} else if (mon == 7) {
	//７月
	var flakes = Array("light.png","lightB.png","lightR.png");
} else if (mon == 8) {
	//８月
	var flakes = Array("star.gif","star_turn.gif","star_turn2.gif");
} else if (mon == 9) {
	//９月
	var flakes = Array("dongri.gif","ichou.gif","kareha.gif","momiji.gif");
} else if (mon == 10) {
	//10月
	var flakes = Array("majo.gif","obake.gif","komori.gif","jack_o_rantan.gif");
} else if (mon == 11) {
	//11月
	var flakes = Array("kaede.gif","kaede_turn.gif","kaede_turn2.gif","kaedeY.gif","kaedeY_turn.gif","kaedeY_turn2.gif");
} else {
	//12月
	var flakes = Array("present.gif","light.png","lightB.png","lightR.png","light2.png","lightB2.png","lightR2.png");
}

if (you == 0 || you == 6) {
	//土日のみ
	var letitsnow = true;
} else {
	var letitsnow = false;
}
//修正終わり

var numflakes = 18;
var T = 50;
var dx, xPos, yPos, am, vx, vy, obj, i;
var winwidth = 800;
var winheight = 600;


function sizeIt()
{
window.winwidth = window.innerWidth?window.innerWidth:document.body.clientWidth;
window.winheight = window.innerHeight?window.innerHeight:document.body.clientHeight;

}

//iPad/iPhone用設定
if (navigator.platform != ("iPad" || "iPhone")) {
	dx = new Array();
	xPos = new Array();
	yPos = new Array();
	sway = new Array();
	var swaymax = 20;
	vx = new Array();
	vy = new Array();
	sizeIt();
	document.write("<STYLE type=\"text/css\">\n.flk {position:absolute;top:-100;}<\/STYLE>");

	for (i = 0; i < numflakes; i++)
	{
		var thisflake = "/js/" + flakes[Math.floor(rnd()*flakes.length)];
		dx[i] = 0;
		xPos[i] = rnd()*(window.winwidth-30) +10;
		yPos[i] = rnd()*window.winheight;
		sway[i] = rnd()*swaymax;
		vx[i] = xRnd();
		vy[i] = yRnd();
		document.write("<div id=\"f"+ i +"\" class=\"flk\"><img src=\"");
		document.write(thisflake + "\" border=\"0\"><\/div>");
	}
	
	window.onload=doSnow;
}

function snowMove(id,left,top)
{
	obj = document.getElementById?document.getElementById(id).style:
   document.all?document.all[id].style:
   document.layers?document.layers[id]:null;
	if (obj)
   {
		obj.left=left;
		obj.top=top;
	}
}



function snowSwitch(s)
{
	if ( s == "on" )
   {
		if ( window.letitsnow != true )
      {
			window.letitsnow = true;
			doSnow();
		}
	} else if ( s == "off" )
   {
		window.letitsnow = false;
		hideSnow();
	}
}



function hideSnow()
{
	for (i = 0; i < numflakes; ++ i) {
		snowMove("f"+i,-100,-100);
	}
}



function doSnow() {
	if (letitsnow){
		sizeIt();
		delta = (window.pageYOffset!=null)?window.pageYOffset:document.body.scrollTop;
		for (i = 0; i < numflakes; ++ i) {
			yPos[i] += vy[i];
			if (yPos[i] > window.winheight+delta-50) {
				xPos[i] = rnd()*(window.winwidth-sway[i]-30);
				yPos[i] = delta;
				vx[i] = xRnd();
				vy[i] = yRnd();
			}
			dx[i] += vx[i];
			snowMove("f"+i,xPos[i]+sway[i]*Math.cos(dx[i]),yPos[i]);
		}
		setTimeout("doSnow()", T);
	}
}

