//////////////////////////////////////////////////////////////////////////////
//	작성자 : 우현진															//
//	일 시  : 2006년 11월 22일												//
//////////////////////////////////////////////////////////////////////////////
document.write(
    "<div id=alt_div style=\"" +
    "padding:2;" +
    "border:1 solid #FF7200;" + // 말풍선 테두리 컬러
    "background-color:#F7F7F7;color:#000;" + // 말풍선 테이블 백그라운드컬러 / 폰트컬러
    "position:absolute;" +
    "visibility:hidden;" +
    "overflow:hidden;" +
    "z-index:auto;" +
    "width:auto;" +
    "height:auto;" +
    "filter:alpha(opacity=100);" + // 투명도
    "\"></div>"
);

function alt( msg, _width, _height ){
    var _style = alt_div.style;
	var html;
	if( msg != null ){
		html = '<table>';
		html = html + '<tr>';
		html = html + '<td>';
		html = html + "<img src='" + msg + "'>";
		html = html + '</tr>';
		html = html + '</td>';
		html = html + '</table>';
        
		alt_div.innerHTML = html;

        _style.visibility = "visible";
        if( _width != null ){
            if( alt_div.offsetWidth > _width ){
                _style.width = _width;
            }
        }
        if( _height != null ){
            if( alt_div.offsetHeight > _height ){
                _style.height = _height;
            }
        }
		document.onmousemove = layrermove;
    }else{
        _style.visibility = "hidden";
		document.onmousemove = '';
    }
}

function layrermove(e)
{
	if (window.event)
	{
		if ((document.all.alt_div.style.pixelLeft != window.event.clientX + document.body.scrollLeft) || (document.all.alt_div.style.pixelTop != window.event.clientY + document.body.scrollTop)){
			if(window.screen.width + document.body.scrollLeft <= window.event.clientX + document.body.scrollLeft + 500)
			{
				document.all.alt_div.style.pixelLeft = window.event.clientX + document.body.scrollLeft - 413;  			
			}
			else
			{
				document.all.alt_div.style.pixelLeft = window.event.clientX + document.body.scrollLeft;  
			}

			if(window.screen.height + document.body.scrollTop <= window.event.clientY + document.body.scrollTop + 453)
			{
				// 바닥에 닿을때 위로 올려준다
				//document.all.alt_div.style.pixelTop = window.event.clientY + document.body.scrollTop - 127; //
				
				//이미지가 큰이유로 레이어가 버벅.. 왼쪽으로 고정
				document.all.alt_div.style.pixelTop = window.event.clientY + document.body.scrollTop;
			}
			else
			{
				document.all.alt_div.style.pixelTop = window.event.clientY + document.body.scrollTop;
			}
		}
	}
	else
	{
		
		var itemsObj	= document.all.alt_div;

		img_w			= '400';
		img_h			= '300';

		var mouseW		= e.clientX;
		var mouseH		= e.clientY;
		
		var scrollW		= document.body.scrollLeft;
		var scrollH		= document.body.scrollTop;
		var bodyW		= document.body.offsetWidth;
		var bodyH		= document.body.offsetHeight;

		var posx		= ((bodyW-mouseW-scrollW) <= img_w) ? (mouseW-img_w-20+scrollW) : (mouseW+20+scrollW);
		var posy		= ((bodyH-mouseH) <= img_h) ? ((scrollH+mouseH)-img_h) : mouseH+scrollH;

		itemsObj.style.left		= posx + "px";
		itemsObj.style.top		= posy + "px";
	}
}
