var xp0=0;
var yp0=0;
var n=20;
var h;             //表示させる画像の数
var doc_width = 800;
var doc_height = 1800;
var oImg = new Image();

xp=new Array();
yp=new Array();
i=new Array();
l=new Array();
hosi=new Array();
var k;
var p=0;
timerID=0;

function STAR_WARS2() 
{ 
	for (m=1;m<(n+1);m++) document.all["dot"+m].style.display="none";
	
	clearTimeout(timerID);

	doc_width =document.body.scrollLeft+window.event.clientX;
	doc_height=document.body.scrollTop+window.event.clientY;

	xp0 = doc_width; 
	yp0 = doc_height; 

	for (m=1;m<(n+1);m++)
	{
		if(m<=(n/2))
		{
			h=m;
			xp[m]=xp0+0.1*h*Math.cos((m)*2*3.14/n+3.14/2);
			yp[m]=yp0-0.1*h*Math.sin((m)*2*3.14/n+3.14/2);
		}

		if(m>(n/2))
		{
			h=n-m;
			xp[m]=xp0+0.1*h*Math.cos(m*2*3.14/n+3.14/2);
			yp[m]=yp0-0.1*h*Math.sin(m*2*3.14/n+3.14/2);
		}

		i[m]=xp[m]-xp0;
		l[m]=yp[m]-yp0;

	}

	k=10;   //はじけるスピード(最初)
	p=0;
	STAR_WARS();

}

function STAR_WARS() {
	p=p+1;
	for (m=1;m<(n+1);m++)
	{

		document.all["dot"+m].style.display="block";
		document.all["dot"+m].style.pixelTop = yp[m];
		document.all["dot"+m].style.pixelLeft = xp[m];

		xp[m]=xp[m]+k*i[m];
		yp[m]=yp[m]+k*l[m]-1;//３は落下方向のスピード。０は落下しない。
		k=k*0.997;           //はじけるスピードの減速係数。１以下で減速、１以上で加速

	}

	timerID=setTimeout("STAR_WARS()",5);//10を小さくするとこまやかな動きになるが負荷が大きくなる

	if (p>=60)
	{
		p=30;          //この行と上の行の６０ははじけて消えるまでの時間
		for (m=1;m<(n+1);m++) document.all["dot"+m].style.display="none";

		clearTimeout(timerID);

	}

}

function Initialize(sImgSrc)
{
	Image_Initialize(sImgSrc);
}
function Image_Initialize(sImgSrc)
{
	oImg.src = sImgSrc;
	var idx = 0;
	var iTOP = 0;
	for(idx = 1; idx <= 20; idx++)
	{ 
		iTOP = iTOP + 15;
		document.write("<DIV ");
		document.write("id=\"dot" + idx + "\" ");
		document.write("style=\"DISPLAY: none; LEFT:15px; POSITION: absolute; TOP:" + iTOP + "px\">");
		document.write("<IMG id=img" + idx + " name=img" + idx + " border=0>");
		document.write("</DIV>\n");
		document.images["img" + idx].src = oImg.src;
	}
}

function SymError() { return true; }
window.onerror = SymError;
document.onclick = STAR_WARS2;
