var no =5;
var speed = 4;

balloon = new Array();
balloon[0] = "./ha0.gif";//わき上がらせる画像のファイル名
balloon[1] = "./ha1.gif";
balloon[2] = "./ha3.gif";//画像を増やすときはballoon[3]の数字を増やし下のmaxballoonの数も増やす

var maxballoon = 2;  // 画像の数(0は数に入れない）
var ns4up = (document.layers) ? 1 : 0;  // browser sniffer
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp;    // coordinate and position variables
var am, stx, sty;  // amplitude and step variables
var i, doc_width = 500, doc_height = 600;

if (ns4up) {
	doc_width = self.innerWidth;
	doc_height = self.innerHeight - 50;
} else if (ie4up) {
	doc_width = document.body.clientWidth;
	doc_height = document.body.clientHeight -50;
}

dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
j = maxballoon;
for (i = 0; i < no; ++ i) {
	dx[i] = 0;                        // set coordinate variables
	xp[i] = Math.random()*(doc_width-50);  // set position variables
	yp[i] = Math.random()*doc_height;
	am[i] = Math.random()*20;         // set amplitude variables
	stx[i] = 0.02 + Math.random()/10; // set step variables
	sty[i] = 0.7 + Math.random();     // set step variables
	if (ns4up) {                      // set layers
		if (i == 0) {
			document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"500\" visibility=\"show\"><img src=\"" + balloon[j] + "\" border=\"0\"></layer>");
		} else {
			document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"500\" visibility=\"show\"><img src=\"" + balloon[j] + "\" border=\"0\"></layer>");
	   }
	} else if (ie4up) {
		if (i == 0) {
			document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 500px; LEFT: 15px;\"><img src=\"" + balloon[j] + "\" border=\"0\"></div>");
		} else {
			document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 500px; LEFT: 15px;\"><img src=\"" + balloon[j] + "\" border=\"0\"></div>");
    	}
	}
	if (j == 0) { j = maxballoon; } else { j -= 1; }
}

function takoNS() {  // Netscape main animation function
	for (i = 0; i < no; ++ i) {  // iterate for every dot
		yp[i] -= sty[i];
		if (yp[i] < 0) {
			xp[i] = Math.random()*(doc_width-am[i]-30);
			yp[i] = doc_height;
			stx[i] = 0.02 + Math.random()/10;
			sty[i] = 0.7 + Math.random();
			doc_width = self.innerWidth;
			doc_height = self.innerHeight -50;
		}
		dx[i] += stx[i];
		document.layers["dot"+i].top = yp[i];
		document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
	}
	setTimeout("takoNS()", speed);
}

function takoIE() {  // IE main animation function
	for (i = 0; i < no; ++ i) {  // iterate for every dot
		yp[i] -= sty[i];
		if (yp[i] < 0) {
			xp[i] = Math.random()*(doc_width-am[i]-30);
			yp[i] = doc_height;
			stx[i] = 0.02 + Math.random()/10;
			sty[i] = 0.7 + Math.random();
			doc_width = document.body.clientWidth;
			doc_height = document.body.clientHeight -50;
		}
	dx[i] += stx[i];
	document.all["dot"+i].style.pixelTop = yp[i];
	document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
	}
	setTimeout("takoIE()", speed);
}

if (ns4up) {
	takoNS();
} else if (ie4up) {
	takoIE();
}

var kazu=6;//増やすと画面上の画像数も増える
var hayasa=1;//増やすと速くなる　ネスケとIEではかなり速さが違うので調整してね
var yoko=50;//増やすと横揺れが多くなり０だと真っ直ぐ降る
var doc_width=800;//画像の動く範囲（幅）
var doc_height=600;//画像の動く範囲（高さ）
var Num = 3;//画像の数を増やしたらこの数字も増やす　こちらは０も数の内に入れる
var Boll = new Array();
Boll[0]  = "./ho0.gif";//降らす画像のファイル名　増やすときは数字も増やす
Boll[1]  = "./yuki.gif";
Boll[2]  = "./ho1.gif";
var ta,wasi,tk,tw,to,at,ko

var ie4=(document.all)//IEもネスケも４バージョン以前の確認はできていません
var nesc4=(document.layers)
if (nesc4){doc_width = self.innerWidth;
} else if (ie4) {doc_width = document.body.clientWidth;}
ta=new Array();wasi=new Array();tk=new Array();tw=new Array();to=new Array();at=new Array();
for (ko=0;ko<kazu;ko++){  
ta[ko] = 0;
wasi[ko] = Math.random()*(doc_width-50);
tk[ko] = Math.random()*doc_height;
tw[ko] = Math.random()*yoko;
to[ko] = Math.random()/10;
at[ko] = hayasa+Math.random();

function rm(i) {
if(navigator.appVersion.charAt(0) <=2 && navigator.appName.charAt(0) == "N") {
	nd = new Date();
	nd = nd.getTime(); nd += ""; nd = nd.substring(nd.length-3,nd.length); nd = eval(nd)/1000;
	nd = Math.floor(nd*i);
	return nd;} else {nd = Math.floor(Math.random()*i);return nd;}
}
var Img = rm(Num);
if (nesc4){
	if (ko==0){
	document.write("<Layer Name=\"TKO"+ko+"\"><Img Src=\""+Boll[Img]+"\"></Layer>");
	}else{
	document.write("<Layer Name=\"TKO"+ko+"\"><Img Src=\""+Boll[Img]+"\"></Layer>");
	}
	} else if (ie4) {
	if (ko==0){
		document.write("<Div ID=\"TKO"+ko+"\" style=\"Z-index:"+ko+";POSITION:absolute;\"><Img Src=\""+Boll[Img]+"\"></Div>");
	}else{
		document.write("<Div ID=\"TKO"+ko+"\" style=\"Z-index:"+ko+";POSITION:absolute;\"><Img Src=\""+Boll[Img]+"\"></Div>");
		}
	}
}

function ie(){
for (ko=0;ko<kazu;ko++){
	tk[ko] += at[ko];
	if (tk[ko]>doc_height-50){
	wasi[ko]=Math.random()*(doc_width-tw[ko]-30);
	tk[ko]=0;
	to[ko]=Math.random()/10;
	at[ko]=hayasa+Math.random();
	doc_width=document.body.clientWidth;
	}
	ta[ko]+=to[ko];
	document.all["TKO"+ko].style.pixelTop=tk[ko];
	document.all["TKO"+ko].style.pixelLeft=wasi[ko]+tw[ko]*Math.sin(ta[ko]);
   }
	setTimeout("ie()",0);
}

function nesc(){
for (ko=0;ko<kazu;ko++){
	tk[ko]+=at[ko];
	if (tk[ko]>doc_height-50){
	wasi[ko]=Math.random()*(doc_width-tw[ko]-30);
	tk[ko]=0;
	to[ko]=Math.random()/10;
	at[ko]=hayasa+Math.random();
	doc_width=self.innerWidth;
	}
	ta[ko]+=to[ko];
	document.layers["TKO"+ko].top=tk[ko];
	document.layers["TKO"+ko].left=wasi[ko]+tw[ko]*Math.sin(ta[ko]);
   }
	setTimeout("nesc()",0);
}

if (nesc4) {nesc();} else if (ie4) {ie();}
