var x = 0;
var y = 0;
var snow = 0;
var sw = 0;
var cnt = 0;
var offsetx = -10;
var offsety = 6;
var width = 250;
var height = 10;
var over;

document.onmousemove = mouseMoveHandler;

function setVariables() {
	if (navigator.appName == "Netscape") {
//		horz=".left";
//		vert=".top";
		doc_innerW="window.innerWidth";
		doc_innerH="window.innerHeight";
		doc_offsetX="window.pageXOffset";
		doc_offsetY="window.pageYOffset";
	}
	else {
//		horz=".pixelLeft";
//		vert=".pixelTop";
		if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			doc_innerW="document.documentElement.clientWidth";
			doc_innerH="document.documentElement.clientHeight";
		} else {
			doc_innerW="document.body.clientWidth";
			doc_innerH="document.body.clientHeight";
		}

		if( document.documentElement ) {
			doc_offsetX="document.documentElement.scrollLeft";
			doc_offsetY="document.documentElement.scrollTop";
		} else {
			doc_offsetX="document.body.scrollLeft";
			doc_offsetY="document.body.scrollTop";
		}
	}
}

function hide(articleNum) {
    over = eval("document.all." + articleNum + ".style");

	if (cnt >= 1) {
		sw = 0;
	}
    if (0 == sw) {
    	snow = 0;
    	hideObject();
    } else {
    	cnt++;
    }
}

function show(articleNum) {
    over = eval("document.all." + articleNum + ".style");
	disp();
}

function disp() {
	if (0 == snow) {
		moveTo(x + offsetx, y + offsety);
		showObject();
		snow = 1;
	}
}

function mouseMoveHandler(e) {

	if (document.all) {

		x = event.x + eval(doc_offsetX) + 10;
		y = event.y + eval(doc_offsetY) + 12;

		if ( x > 620 )	{ //해상도가 달라도 상관없도록 수정
			x = x - 255;
		}

		if (y + height - eval(doc_offsetY) > eval(doc_innerH)) {
			y = y - height;
		}
	} else {
		x = e.pageX;
		y = e.pageY;
	}

	if (snow) {
		moveTo(x + offsetx, y + offsety);
	}
}

function showObject() {
	over.display = "inline";
}

function hideObject() {
	over.display = "none";
}

function moveTo(xL, yL) {
	over.left = xL;
	over.top = yL;
}


function layerOver(e, Value) {

	var x,y,realy;
//	var bodyHeight = document.body.offsetHeight+eval(doc_offsetY);
	var bodyHeight = eval(doc_innerH)+eval(doc_offsetY);
	var bodyWidth = document.body.offsetWidth+eval(doc_offsetX);
	var ttHeight = document.getElementById(Value);
	ttHeight.style.display = 'inline';

	if(e) {
		x=e.pageX+eval(doc_offsetX)+10;
		y=e.pageY+eval(doc_offsetY)+10;

		if(totaly > bodyHeight) {
			realy = y - (totaly - bodyHeight);
		} else {
			realy = y;
		}

	}else{
		x=event.x+eval(doc_offsetX)+10;
		y=event.y+eval(doc_offsetY)+10;
		totaly = y + ttHeight.offsetHeight;
		totalx = x + ttHeight.offsetWidth;

		if(totaly > bodyHeight) {
			realy = y - (totaly - bodyHeight) - 30;
		} else {
			realy = y;
		}

		if(x >700) {
			x = x - 240;
		} else if(totalx > bodyWidth) {
			x = x - (totalx - bodyWidth);
		} else {
			x = x;
		}
	}

	ttHeight.style.left = x - 55;
	ttHeight.style.top = realy;
//alert( x + "," + realy );
/*
	var x,y,realy;
	var bodyHeight = document.body.offsetHeight+document.body.scrollTop;
	var bodyWidth = document.body.offsetWidth+document.body.scrollLeft;
	var ttHeight = document.getElementById(Value);
	
	ttHeight.style.display = 'inline';

	if(e) {
		x=e.pageX+document.body.scrollLeft+10;
		y=e.pageY+document.body.scrollTop+10;

		if(totaly > bodyHeight) {
			realy = y - (totaly - bodyHeight);
		} else {
			realy = y;
		}

	}else{
		x=event.x+document.body.scrollLeft+10;
		y=event.y+document.body.scrollTop+10;
		totaly = y + ttHeight.offsetHeight;
		totalx = x + ttHeight.offsetWidth;

		if(totaly > bodyHeight) {
			realy = y - (totaly - bodyHeight) - 30;
		} else {
			realy = y;
		}

		if(x >700) {
			x = x - 240;
		} else if(totalx > bodyWidth) {
			x = x - (totalx - bodyWidth);
		} else {
			x = x;
		}
	}

	ttHeight.style.left = x;
	ttHeight.style.top = realy;
*/
}

function layerOut(Value) {
	document.getElementById(Value).style.display = 'none';
}

setVariables();

