// マウスカーソルの周りを画像が回る

var circle_xmouse, circle_ymouse;
var circle_inited = false;
var circle_objs = new Array();

function circle_init() {
	var box = document.getElementById(circle_id);
	if(!box) return;
	var i, j;
	for(i = 0, j = 0; i < box.childNodes.length; i++) {
		var img = box.childNodes[i];
		if(img.nodeName != "IMG") continue;
		var img2 = document.createElement("IMG");
		img2.src = img.src;
		img2.style.position = "absolute";
		img2.style.left = "-50px";
		img2.style.top = "-50px";
		img2.style.zIndex = box.style.zIndex;
		img2.width  = img.width;
		img2.height = img.height;
		document.body.appendChild(img2);
		
		var obj = new Object();
		obj.img = img2;
		circle_objs[j] = obj;
		j++;
	}
	for(i = 0; i < circle_objs.length; i++)
	{
		var obj = circle_objs[i];
		obj.angle = (2 * Math.PI / j) * i;
	}
	if(j > 0) setTimeout("circle_moveIcon();", circle_speed1);
}

function circle_move (e) {
	if(window.event) e = window.event;
	circle_xmouse = e.clientX + circle_scrollLeft();
	circle_ymouse = e.clientY + circle_scrollTop();
	if(!circle_inited) { circle_inited = true; circle_init(); }
}

function circle_moveIcon () {
	var i;
	for(i = 0; i < circle_objs.length; i++)
	{
		var obj = circle_objs[i];
		var img = obj.img;
		// x = r * cos T; y = r * sin T;
		img.style.left = circle_xmouse - (img.width / 2)
			+ circle_r * Math.cos(obj.angle) + "px";
		img.style.top  = circle_ymouse - (img.height / 2)
			+ circle_r * Math.sin(obj.angle) + "px";
		obj.angle += circle_speed2;
		if(obj.angle > 2 * Math.PI) obj.angle -= 2 * Math.PI;
	}
	
	setTimeout("circle_moveIcon();", circle_speed1);
}

if(document.getElementById)
	document.onmousemove = circle_move;

function circle_scrollLeft () {
	if(window.pageXOffset)
		return window.pageXOffset;
	if(document.compatMode == "CSS1Compat")
		return document.body.parentNode.scrollLeft;
	if(document.body.scrollLeft)
		return document.body.scrollLeft;
	return 0;
}
function circle_scrollTop () {
	if(window.pageYOffset)
		return window.pageYOffset;
	if(document.compatMode == "CSS1Compat")
		return document.body.parentNode.scrollTop;
	if(document.body.scrollTop)
		return document.body.scrollTop;
	return 0;
}
