
var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isNS = navigator.appName == "Netscape";

function getRef(id) {
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}

function getSty(id) {
	x = getRef(id);
	return (isNS4 ? getRef(id) : getRef(id).style);
}

var scrollerHeight = 0;
var puaseBetweenImages = 3000;
var imageIdx = 0;

function moveRightEdge() {
	var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;

	if (isNS4) {
		yMenuFrom   = divTOP.top;
		yMenuTo     = windows.pageYOffset ;   // À§ÂÊ À§Ä¡
	} else if (isDOM) {
		yMenuFrom   = parseInt (divTOP.style.top, 10);
		yMenuTo     = (isNS ? window.pageYOffset : document.body.scrollTop + document.body.clientHeight -500); // À§ÂÊ À§Ä¡
		
	}
	timeoutNextCheck = 500;

	if (yMenuFrom != yMenuTo) {
		yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
		if (yMenuTo < yMenuFrom)
			yOffset = -yOffset;
		if (isNS4)
			divTOP.top += yOffset;
		else if (isDOM)
			{
			
			//divTOP.style.top = parseInt (divTOP.style.top, 10) + yOffset;
 
       
			 if(parseInt (divTOP.style.top, 10) > document.body.scrollTop + document.body.clientHeight - 500)
			 {
			  divTOP.style.top = document.body.scrollTop + document.body.clientHeight - 500 ;
			  //alert("divTOP.style.top:"+divTOP.style.top + " , document.body.scrollTop:" + document.body.scrollTop + " ,document.body.clientHeight:" + document.body.clientHeight);
			  }
			 else
			  divTOP.style.top = parseInt (divTOP.style.top, 10) + yOffset;
       }

		if(parseInt (divTOP.style.top, 10) < 280)
       divTOP.style.top =280;


		timeoutNextCheck = 10;
	}
	setTimeout ("moveRightEdge()", timeoutNextCheck);
}



if (isNS4) {
	var divTOP = document["divTOP"];
	divTOP.top = top.pageYOffset;
	divTOP.visibility = "visible";
	moveRightEdge();
} else if (isDOM) {
	var divTOP = getRef('divTOP');
	divTOP.style.top = (isNS ? window.pageYOffset : document.body.scrollTop );
	divTOP.style.visibility = "visible";
	moveRightEdge();
}
