/**
 * global variable
 */
var Menu;
var Active = 'N';
var Time   = null;

/**
 * ¿ÞÂÊ À§Ä¡
 */
function offsetLeft(element)
{
	xpos = element.offsetLeft;
	for(e = element.offsetParent; e; e = e.offsetParent)
	{
		xpos += e.offsetLeft;
	}

	return xpos;
}

/**
 * »ó´Ü À§Ä¡
 */
function offsetTop(element)
{
	ypos = element.offsetTop;
	for(e = element.offsetParent; e; e = e.offsetParent)
	{
		ypos += e.offsetTop;
	}

	return ypos;
}

/**
 * ÇÏÀ§ ºÐ·ù ÄÁÆ®·Ñ
 */
function categoryon(oMenu, oSpan)
{
	if(Time != null){
		clearTimeout(Time);
		hide();
	}

	var xpos = offsetLeft(oSpan);
	var ypos = offsetTop(oSpan) + 20;

	oMenu.style.left = xpos;
	oMenu.style.top = ypos;
	oMenu.style.visibility = 'visible';

	Menu = oMenu;
	Active = 'Y';
}

/**
 * ¸Þ´º ¹öÆ°ÀÇ ¸¶¿ì½º ¾Æ¿ô
 */
function categoryout()
{
	Active = 'N';
	Time = setTimeout('hide()', 100)
}

/**
 * ÇÏÀ§ ºÐ·ù º¸ÀÓ
 */
function menuon()
{
	clearTimeout(Time);
	Active = 'Y';
}

/**
 * ÇÏÀ§ ºÐ·ù ¼û±è(ÇÏÀ§ºÐ·ùÀÇ ¸¶¿ì½º ¾Æ¿ô)
 */
function menuout()
{
	Active = 'N';
	Time = setTimeout('hide()', 100);
}

/**
 * ºÐ·ù ¼û±è
 */
function hide()
{
	if(Active == 'N')
	{
		Menu.style.visibility = 'hidden';
	}
}

	isIE  = document.all;
	isNN  = !document.all && document.getElementById;
	isN4  = document.layers;	

	var max_zindex = 30;
	var expiredays = 1;    
	function drag( mode,e,obj )
	{ 
		if ( mode == 'start' )
	 {
			obj.offsetx = isIE ? event.clientX : e.clientX;
			obj.offsety = isIE ? event.clientY : e.clientY;

			obj.nowX    = parseInt(obj.style.left);
			obj.nowY    = parseInt(obj.style.top);
			obj.dragable = '1';

			var new_zindex = max_zindex + 1;
			obj.style.zIndex = new_zindex;
			max_zindex = new_zindex;
		}
	 else if ( mode == 'move' )
	 { 
			 if ( obj.dragable == '1' )
	   {
				 var x = isIE ? (obj.nowX + event.clientX - obj.offsetx) : (obj.nowX + e.clientX - obj.offsetx);
				 var y = isIE ? (obj.nowY + event.clientY - obj.offsety) : (obj.nowY + e.clientY - obj.offsety);
				 var max_winw = document.body.clientWidth - parseInt(obj.style.width);
				 var max_winh = document.body.clientHeight - parseInt(obj.style.height);

				 //·¹ÀÌ¾î°¡ ÀÏÁ¤ ¼öÄ¡ ¹ØÀ¸·Î ³»·Á°¡Áö ¾Ê´ø Çö»óÀÌ ÀÖ´Âµ¥ + 100 ½ÄÀ¸·Î ¼ýÀÚ¸¦ ÀÔ·ÂÇØ ÁÖ¸é ´õ ³»·Á°£´Ù.

				 if ( x >= 0 && x <=max_winw ) obj.style.left = x;
				 if ( y >= 0 && y <=max_winh ) obj.style.top  = y;
			 }
		}
	 else if ( mode == 'stop' )
	 {
			obj.dragable='0'
		}
	}

	function closeLayer(){
		document.getElementById('divPop').style.visibility = "hidden";
	}
	function setCookie( name, value, expiredays )
	{ 
		var todayDate = new Date(); 
		todayDate.setDate(todayDate.getDate() + expiredays); 
		document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
	} 

	isIE  = document.all;
	isNN  = !document.all && document.getElementById;
	isN4  = document.layers;
