// tipsonoff.js [レイアでALTっぽい説明を出す]
// sachio@edge.jp [2001/06/13]
// hanabusa@edge.jp [2001/06/17] <for MSIE4>
margin_x=20; margin_y=20; // Margin for scrollbars

//=== Get Layer Object from Name
function getLayerObjectFromName(nm){
	if(document.all) return document.all(nm);
	if(document.layers){
		var s='';
		for(var i=1; i<arguments.length; i++) s+='document.layers.'+arguments[i]+'.';
		return eval(s+'document.layers.'+nm);
	}
	return null;
}

//=== To get the width of Layer
//function getLayerWidth (div){
//	if(document.all) return div.style.pixelWidth;
function getLayerWidth (div, nm){
	if(document.all) return document.all("t_" + nm).style.pixelWidth;
	if(document.layers) return div.clip.width;
	return 0;
}

//=== To get the height of Layer
function getLayerHeight(div){
	if(document.all) return div.style.pixelHeight;
	if(document.layers) return div.clip.height;
	return 0;
}

//=== To get the width of Window
function getWindowWidth (){
	if(document.all) return document.body.clientWidth;
	if(document.layers) return window.innerWidth;
	return 0;
}

//=== To get the height of Window
function getWindowHeight(){
	if(document.all) return document.body.clientHeight;
	if(document.layers) return window.innerHeight;
	return 0;
}

//=== To get the Xoffset of Window
function getWinXOffset(){
	if(document.all) return document.body.scrollLeft;
	if(document.layers) return window.pageXOffset;
	return 0;
}

//=== To get the Yoffset of Window
function getWinYOffset(){
	if(document.all) return document.body.scrollTop;
	if(document.layers) return window.pageYOffset;
	return 0;
}

// Move to Layers( Absolute coord )
function moveLayerTo(div,left,top){
	if(document.all){
		div.style.pixelLeft = left;
		div.style.pixelTop  = top;
		return;
	}
	if(document.layers){
		div.moveTo(left,top);
		return;
	}
}


//=== To display Tips
function displayTips(nm,e){

	ox = 30;
	oy = 30;

	var div=getLayerObjectFromName(nm);

	if(div==null) return;

	// === Format Size of Layers
	if(document.all){
		div.style.pixelWidth  = div.offsetWidth;
		div.style.pixelHeight = div.offsetHeight;
	}

	// === Get info
	var ww=getWindowWidth(), wh=getWindowHeight();
//	var lw =getLayerWidth(div), lh =getLayerHeight(div);
	var lw =getLayerWidth(div,nm), lh =getLayerHeight(div);
	var sx=getWinXOffset(), sy=getWinYOffset();

	if(document.all){var x=sx+window.event.clientX + ox, y=sy+window.event.clientY - oy;}
	else if(document.layers){var x=e.pageX + ox, y=e.pageY - oy;}

	if((x+lw)>(ww+sx-margin_x)) x=ww+sx-lw-margin_x;
	if(x<sx) x=sx;
	if((y+lh)>(wh+sy-margin_y)) y=wh+sy-lh-margin_y;
	if(y<sy) y=sy;

	moveLayerTo(div,x,y);

	if(document.all) div.style.visibility= 'visible';
	if(document.layers) div.visibility =true;

}


//=== To hide Tips
function hideTips(nm){

	var div=getLayerObjectFromName(nm);

	if(document.all) div.style.visibility= 'hidden';
	if(document.layers) div.visibility =false;
}
