/////////////////////////////////////////////////////////////////
// Program id  : ScrollBanner.js
// Description : ½ºÅ©·Ñ ¸Þ´º Ã³¸®¸¦ À§ÇÑ ÇÔ¼ö ¸ðÀ½
// ÀÛ¼ºÀÚ      : ÃßÃ¢È£
// ¼Ò ¼Ó       : ÇÃ·¹ÀÌ¾î
// ÀÏ ÀÚ       : 2007.05.17
//             : * div ÀÇ id °ª¿¡ Á¾¼ÓÀûÀÓ
//			   : 
//////////////////////////////////////////////////////////////

// °¢ division ÀÇ ¼Ó¼º°ªÀ» ÀúÀåÇÏ±â À§ÇÑ ¹è¿­
var layerArrayData = new Array();
var currentObject = null;
var beforeObject = null;

// Layer Height ÀÇ »çÀÌÁî Áõ°¡Ä¡
var inc_height = 30;
// Layer Ãâ·Â / ¼û±è Å¸ÀÓ 
var inc_time = 1;
var proc = true;
// ¸¶¿ì½º ÁÂÇ¥
var x;
var y;

function initMenu()
{

	frameLayer = document.getElementById('lmenu');
	divs = frameLayer.getElementsByTagName('div');
	var i = 0;

	for ( var index = 0; index < divs.length; index++ ) { 
		div_id = divs[index].getAttribute('id');
		if ( div_id != "cat_list" )
		{
			// °¢ division ÀÇ ¼Ó¼º°ª
			sub_layer = document.getElementById(div_id);
		
			height = sub_layer.style.height.replace('px','');
			html = sub_layer.innerHTML;

			layerObject = new layer(div_id,height,html);
			layerArrayData[i] = layerObject;


//			document.getElementById(div_id).innerHTML = '';
//			document.getElementById(div_id).style.height = 0;

			i++;

		}
	}

}

function shrinkHeight()
{
	if ( beforeObject != null ) {
		var layer = document.getElementById(beforeObject);
		layer.innerHTML = '';
		var theight = parseInt(layer.style.height.replace('px',''),10);
		if ( theight > 0 ) {
			proc = false;
			if ( theight - inc_height < 0 ) { theight = 0; }
			else { theight -= inc_height; }
			layer.style.height = theight + "px";
			setTimeout("shrinkHeight()",inc_time);
		} else {
			proc = true;
		}
	}
}

function extendHeight()
{
	for ( var i = 0 ; i < layerArrayData.length ; i++ )
	{
		layerObject = layerArrayData[i];
		tmp_id = layerObject;
		if ( tmp_id.id == currentObject ) {
			var layerObj = document.getElementById(tmp_id);
			var theight = parseInt(document.getElementById(currentObject).style.height.replace('px',''),10);
			if ( theight < tmp_id.height  ) {
				proc = false;
				theight += inc_height; 
				document.getElementById(currentObject).style.height = theight + "px";
				setTimeout("extendHeight()",inc_time);
			} else {
				document.getElementById(currentObject).innerHTML = tmp_id.html;
				document.getElementById(currentObject).style.height = tmp_id.height;
				proc = true;
			}
		}
	}
}

function layer(id,height,html)
{
	this.id = id;
	this.height = height;
	this.html = html;
}

function show(obj)
{
	
	if ( proc )
	{
		beforeObject = currentObject;

		if ( currentObject != obj ) {
			currentObject = obj;
//			shrinkHeight();			
			extendHeight();			
		}
	}
}

function mouseMove(e) 
{
	x=event.x;
	y=event.y;
}
function show2(obj) {

	moveElement( obj, 100, 100 );
	document.getElementById(obj).style.visibility = "visible";
}
function hidden2(obj)
{
	document.getElementById(obj).style.visibility = 'hidden';
}
function moveElement(id, x, y){ // W3C DOM Browser
	var elm = document.getElementById(id);
	if (elm) {
		elm.style.left = x + 'px';
		elm.style.top = y + 'px';
	}
}
