
function layer_resize(layer_name, xx,yy)
{
	var layer	= document.getElementById(layer_name);
	layer.style.display		= '';

	if((layer.style.pixelWidth+5)<xx || (layer.style.pixelHeight+5)<yy)
	{
		if(layer.style.pixelWidth<xx)	 	layer.style.width		= layer.style.pixelWidth + 5;
		if(layer.style.pixelHeight<yy)		layer.style.height	= layer.style.pixelHeight + 5;
	}
	else
	{
		layer.style.width		= xx;
		layer.style.height	= yy;
		clearInterval(resize);
	}
}

function layer_resize_close(layer_name)
{
	resize = setInterval("layer_resize_close2('"+layer_name+"')",10);
}

function layer_resize_close2(layer_name)
{
	var layer	= document.all(layer_name);

	if(layer.style.pixelWidth>5 && layer.style.pixelHeight>5)
	{
		layer.style.width		= layer.style.pixelWidth - 5;
		layer.style.height	= layer.style.pixelHeight - 5;
	}
	else
	{
		layer.style.width		= 1;
		layer.style.height	= 1;
		clearInterval(resize);
		layer.style.display	= "none";
	}

}


document.onclick = function () {
	ContextMenu_close();
	ContextMenu_close2();
}

function ContextMenu_openOriginal(menu_arr)
{
//	if(document.getElementById("contextmenu_div"))	document.getElementById('contextmenu_div').removeNode(true);
	if(document.getElementById("contextmenu_div"))	return false;

	var _DIV	= document.createElement('div');

	_DIV.id = "contextmenu_div";
	_DIV.style.position = "absolute";
	_DIV.style.overflow = "hidden";
	_DIV.style.padding = 1;
	_DIV.style.background = "#3399FF";
	_DIV.style.color = "#ffffff";
	_DIV.style.borderStyle = "solid";
	_DIV.style.borderWidth = 1;
	_DIV.style.borderColor = "#3333CC";
	_DIV.style.width = 0;
	_DIV.style.height = 0;
	_DIV.style.top = document.body.scrollTop + event.clientY;
	_DIV.style.left = event.clientX;
	_DIV.style.filter = "progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.00,wipestyle=0,motion=forward)progid:DXImageTransform.Microsoft.dropShadow(Color=999999,offX=3,offY=3,positive=true);";

	document.body.appendChild(_DIV);

	var html, _split;

	html = "";

	var i = 0;
	while(menu_arr[i])  {
		_split = menu_arr[i].split("|");
		html += "<div ";
		html += "onmouseover=\"this.style.borderColor='ffffff';\" ";
		html += "onmouseout=\"this.style.borderColor='#3399FF';\" ";
		html += "onclick=\"ContextMenu_close();"+_split[1]+"\" onselectstart=\"return false\" oncontextmenu='return false;' ";
		html += "style='height:23;cursor:hand;padding-left:2;padding-top:3;border-style:solid;border-width:1;border-color:#3399FF;overflow:hidden;'>";
		html += " "+_split[0];
		html += "</div>";
		i++;
	}//End While

	contextmenu_div.innerHTML = html;

	var height = (menu_arr.length * 23) + 4;


	_DIV.filters[0].apply();

	_DIV.style.width = 150;
	_DIV.style.height = height;
	_DIV.style.overflow = '';

	_DIV.filters[0].play();
}
function ContextMenu_open(menu_arr)
{
	if(document.getElementById("contextmenu_div"))	return false;

	if(event.clientX+150 > document.body.clientWidth) {
		var left = event.clientX-150;
		var action = 'reverse';
	} else {
		var left = event.clientX;
		var action = 'forward';
	}

	var _DIV	= document.createElement('div');
	_DIV.id = "contextmenu_div";
	_DIV.style.position = "absolute";
	_DIV.style.overflow = "hidden";
	_DIV.style.borderWidth = 0;
	_DIV.style.width = 0;
	_DIV.style.height = 0;
	_DIV.style.zIndex = 1000;
	_DIV.style.top = document.body.scrollTop + event.clientY;
	_DIV.style.left = left;
	_DIV.style.filter = "progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.00,wipestyle=0,motion="+action+")progid:DXImageTransform.Microsoft.dropShadow(Color=999999,offX=3,offY=3,positive=true);";
	document.body.appendChild(_DIV);
	_DIV.innerHTML = "<iframe width='100%' name='contextmenu_iframe' id='contextmenu_iframe' src='/blank.php' frameborder='0' scrolling='no'></iframe>";

	var html, _split;
	html = "<html><body style='margin:0;background:#3399FF;font-family:굴림;'><table width='100%' border='0' align='center' cellpadding='1' cellspacing='0' style='border-style:solid;border-width:1;border-color:#3333CC;color:#FFFFFF;font-size:9pt;'><tr><td>";

	var i=0, height=0;
	while(menu_arr[i])
	{
		if(menu_arr[i] == '-') {
			html += "<div onselectstart='return false' oncontextmenu='return false;' style='background:#AAAAAA;height:1;overflow:hidden;'></div>";
			height +=1;
		} else {
			_split = menu_arr[i].split("|");
			html += "<div ";
			html += "onmouseover=\"this.style.borderColor='ffffff';\" ";
			html += "onmouseout=\"this.style.borderColor='#3399FF';\" ";
			html += "onclick=\"parent."+_split[1]+"parent.ContextMenu_close();\" onselectstart='return false' oncontextmenu='return false;' ";
			html += "style='height:23;cursor:hand;padding-left:2;padding-top:3;border-style:solid;border-width:1;border-color:#3399FF;overflow:hidden;'>";
			html += " "+_split[0];
			html += "</div>";
			height +=23;
		}

		i++;
	}//End While
	html += "</td></tr></table></body></html>";
	contextmenu_iframe.document.write(html);

	height += 4;
	_DIV.style.height = height;
	document.getElementById('contextmenu_iframe').style.height = height;


	_DIV.filters[0].apply();
	_DIV.style.width = 150;
	_DIV.style.overflow = '';
	_DIV.filters[0].play();

	//setTimeout("document.onclick = function () { ContextMenu_close(); ContextMenu_close2(); }", 2000);
}

function ContextMenu_open_LayerType(menu_arr)
{
	if(document.getElementById("contextmenu_div"))	return false;

	if(event.clientX+150 > document.body.clientWidth) {
		var left = event.clientX-150;
		var action = 'reverse';
	} else {
		var left = event.clientX;
		var action = 'forward';
	}

	if(document.body.clientHeight < event.clientY+(menu_arr.length*23)) {
		var top = event.clientY - (menu_arr.length*23);
	} else {
		var top = document.body.scrollTop + event.clientY;
	}

	var _DIV	= document.createElement('div');
	_DIV.id						= "contextmenu_div";
	_DIV.style.position		= "absolute";
	_DIV.style.overflow		= "hidden";
	_DIV.style.borderStyle	= 'solid';
	_DIV.style.borderWidth	= 1;
	_DIV.style.borderColor	= '#000000';
	_DIV.style.padding		= 0;
	_DIV.style.width			= 0;
	_DIV.style.height			= 0;
	_DIV.style.zIndex		= 1000;
	_DIV.style.top				= top;
	_DIV.style.left				= left;
	_DIV.style.filter			= "progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.00,wipestyle=0,motion="+action+")progid:DXImageTransform.Microsoft.dropShadow(Color=999999,offX=3,offY=3,positive=true);";
	

	var html='', _split;

	var i=0, height=0;
	while(menu_arr[i])
	{
		if(menu_arr[i] == '-') {
			html += "<div onselectstart='return false' oncontextmenu='return false;' style='background:#AAAAAA;height:1;overflow:hidden;'></div>";
			height +=1;
		} else {
			_split = menu_arr[i].split("|");
			html += "<div ";
			html += "onmouseover=\"this.style.borderColor='#00FF00';"+(_split[2]?_split[2]:'')+"\" ";
			html += "onmouseout=\"this.style.borderColor='#007EBB';"+(_split[3]?_split[3]:'')+"\" ";
			html += "onclick=\""+_split[1]+"ContextMenu_close();\" onselectstart='return false' oncontextmenu='return false;' ";
			html += "style='height:23;cursor:hand;padding-left:2;padding-top:3;border-style:solid;border-width:1;border-color:#007EBB;overflow:hidden;background:#007EBB;color:white;'>";
			html += " "+_split[0];
			html += "</div>";
			height +=23;
		}
		i++;
	}//End While

	_DIV.style.height = height + 2;
	_DIV.innerHTML = html;
	document.body.appendChild(_DIV);

	_DIV.filters[0].apply();
	_DIV.style.width = 150;
	_DIV.style.overflow = '';
	_DIV.filters[0].play();
}
function ContextMenu_close()
{
	try {
		if(document.getElementById('contextmenu_div')) document.getElementById('contextmenu_div').removeNode(true);
	} catch (e) {

	}
}
function ContextMenu_close2()
{
	try {
		if(document.getElementById('contextmenu_div_cart')) document.getElementById('contextmenu_div_cart').removeNode(true);
	} catch (e) {

	}
}


function layer_alpha(layer_name, alpha)//레이어 알파..
{
	var layer	= document.all(layer_name);
	layer.style.display		= "";

	if(alpha > alpha_val)
	{
		layer.style.filter = "alpha(opacity="+alpha_val+")";
		alpha_val += 20;
	}
	else
	{
		layer.style.filter = "alpha(opacity="+alpha+")";
		clearInterval(l_alpha);
	}

}


function img_view(SRC)
{

	if(!document.all("img_view_div"))  {

		var _DIV	= document.createElement('div');
	
		_DIV.id		= "img_view_div";
		_DIV.style.position	= "absolute";
		_DIV.style.overflow	= "hidden";
		_DIV.style.padding = 0;
	
		_DIV.style.background = "#ffffff";
	//	_DIV.style.color = "#ffffff";
	//	_DIV.style.borderStyle = "solid";
	//	_DIV.style.borderWidth = 1;
	//	_DIV.style.borderColor = "#3333CC";
	
		_DIV.style.filter = "progid:DXImageTransform.Microsoft.dropShadow(Color=999999,offX=3,offY=3,positive=true)";
	
		document.body.appendChild(_DIV);

	}  else  {

		var _DIV = document.all("img_view_div");

	}

	_DIV.style.top = event.clientY;
	_DIV.style.left = event.clientX;
	_DIV.innerHTML = "<img src=\"" + SRC + "\" Onclick=\"document.all('img_view_div').removeNode(true);\">";

}

function Create_layer(name)
{
	if(document.getElementById(name))		document.getElementById(name).removeNode(true);

	var _Layer		= document.createElement('div');
	_Layer.id		= name;
	_Layer.style.position	= 'absolute';
	_Layer.style.top			= event.clientY;
	_Layer.style.left			= event.clientX;

	return _Layer;
}

function layer_save()
{
	var _Layer = Create_layer('Save_layer');
	_Layer.style.width = 0;
	_Layer.style.height = 0;
	_Layer.style.display = 'none';
	_Layer.innerHTML = "<iframe name='SF' src='/blank.php'></iframe>";
	document.body.appendChild(_Layer);
}

function layer_iframe(width, height, src, position)
{
	if(document.getElementById('SP_layer'))		document.getElementById('SP_layer').removeNode(true);

	var _Layer = document.createElement('div');
	_Layer.id = 'SP_layer';
	_Layer.style.position = 'absolute';
	_Layer.style.width = width;
	_Layer.style.height = height;
	_Layer.style.background = 'f4f4f4';
	_Layer.style.overflow = 'hidden';
	_Layer.style.filter = "progid:DXImageTransform.Microsoft.dropShadow(Color=999999,offX=3,offY=3,positive=true)";
	_Layer.style.zIndex = 100;

	if(position == 'center') {
		_Layer.style.top = (document.body.clientHeight/2) - (height/2) + document.body.scrollTop;
		_Layer.style.left = (document.body.clientWidth/2) - (width/2);
	} else if(position) {
		var position2 = position.split('|');
		_Layer.style.top = position2[0];
		_Layer.style.left = position2[1];
	} else {
		_Layer.style.top = event.clientY;
		_Layer.style.left = event.clientX;
	}

	document.body.appendChild(_Layer);

	var _Iframe = document.createElement('iframe');
	_Iframe.id = 'SP_iframe';
	_Iframe.style.width = '100%';
	_Iframe.style.height = '100%';
	_Iframe.frameBorder = 0;
	_Iframe.marginHeight = 0;
	_Iframe.marginWidth = 0;
	_Iframe.scrolling = 'no';
	_Iframe.src = src;

	_Layer.appendChild(_Iframe);
}

function layer_close()
{
	document.getElementById('SP_layer').removeNode(true);
}

function layer_iframe_resize(height)
{
	document.getElementById('SP_layer').style.pixelHeight = height;
}

function layer_iframe_resizeBy(height)
{
	document.getElementById('SP_layer').style.pixelHeight += height;
}


function Layer_move(p_x,p_y)//--> 레이어 스무스하게 스크롤바 따라 다니기..
{
	var yMenuFrom, yMenuTo, yButtonFrom, yButtonTo, yOffset, timeoutNextCheck;

	yMenuFrom   = parseInt (move_layer.style.top, 10);
	yMenuTo     = document.body.scrollTop + p_y;

	timeoutNextCheck = 500;


	if(Math.abs (yButtonFrom - (yMenuTo + 152)) < 6 && yButtonTo < yButtonFrom)
	{
		setTimeout ("Layer_move()", timeoutNextCheck);
		return;
	}

	if(yMenuFrom != yMenuTo)
	{
		yOffset = Math.ceil( Math.abs( yMenuTo - yMenuFrom ) / 20 );
		if(yMenuTo < yMenuFrom) yOffset = -yOffset;

		move_layer.style.pixelTop = parseInt (move_layer.style.top, 10) + yOffset;
		timeoutNextCheck = 10;
	}

	setTimeout ("Layer_move("+p_x+","+p_y+")", timeoutNextCheck);
}

function Layer_move_load(p_x, p_y)
{
	Layer_move(p_x,p_y);
	return true;
}

function PopUp_GoodsUpdate(goods_pk, url)
{
	location = '/Goods/Goods/Goods_update/?goods_pk='+goods_pk+'&URL='+url;
}