// ·¹ÀÌ¾î ÆäÀÌÁö ·Îµù ½ÃÀÛ
//window.onresize=SetActivePopSize;

Event.observe(window, 'resize', function() {   
	SetActivePopSize();
}); 

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;

function SetActivePopScoll(){
	//set wheel
	
	if(isIE)
	{
		document.body.onmousewheel = nowheel;
		var divBody = document.getElementById('activeLayerDiv');
		divBody.onmousewheel = wheel_splayer;
	}
	else
	{
		document.addEventListener('DOMMouseScroll', nowheel, false);
		var divBody = document.getElementById('activeLayerDiv');
		divBody.addEventListener('DOMMouseScroll', wheel_splayer, false);
	}
	
}

function wheel_splayer(e)
{
	var divBody = document.getElementById('activeLayerDiv');
	var wheelAmount = 100;
	var wheelDirection;
	if(isIE) {
		wheelDirection = -1*event.wheelDelta/Math.abs(event.wheelDelta);
	}
	else {
		wheelDirection = e.detail/Math.abs(e.detail);
	}
	divBody.scrollTop += wheelDirection*wheelAmount;
}
function nowheel(e)
{
	if(!isIE)
	{
		e.preventDefault();
	}
	return false;
}

function SetActivePopSize()
{
	var cheight;
	var sheight;
	if($("bodyBgDiv") != null){
		//bg Layer ³ôÀÌ ¼³Á¤ 
		cheight = document.body.clientHeight;
		sheight = document.body.scrollHeight;
		if(cheight >= sheight)
			$("bodyBgDiv").style.height = cheight +'px';
		else
			$("bodyBgDiv").style.height = sheight+'px';
	}

	if($("activeLayerDiv") != null){
		SetActiveLayerSize();	//»ó¼¼·¹ÀÌ¾î »çÀÌÁî Á¶Àý
		try{
			activeLayerFrame.ResizeMySize();	//»ó¼¼·¹ÀÌ¾î iframe ³»¿¡ ÇÔ¼ö È£Ãâ ÇÑ´Ù. (iframe ³» ·¹ÀÌ¾î »çÀÌÁî Á¶Àý)
		}catch(ex){
		}
	}
}
function SetActiveLayerSize(){
	$("activeLayerDiv").style.width = detailDocWidth + "px";
	//$("activeLayerDiv").style.height = detailDocHeight + "px";
	var h = 800;
	//if((document.body.clientHeight -50) > 800)
	//	h = 800;
	//else
		h = document.body.clientHeight - 50;
	
	$("activeLayerDiv").style.height = h + "px";
	
	var popx = (document.body.clientWidth - detailDocWidth) / 2;
	$("activeLayerDiv").style.left = popx;
	$("activeLayerDiv").style.top = 25 + document.body.scrollTop;	
	$("activeLayerFrame").style.height = h;
}
function HideCombo( tagName, showHide)
{ 
	try{
		var tags = document.getElementsByTagName( tagName );

		for(var i = 0; i < tags.length ; i++) 
		{ 
			//alert(tags[i].name);
			if(showHide == "show")
				$(tags[i].name).style.display="";
			else
				$(tags[i].name).style.display="none";
		} 
	} catch(e) {}
}

function SetActivePopLayer(url, w, h)
{
	h = 800;
	//if((document.body.clientHeight -50) > 800)
	//	h = 800;
	//else
		h = document.body.clientHeight - 50;

	SetActiveBodyBg();	
	SetActiveLoadingLayer();
	SetActivePageView(url, w, h);
	HideCombo("select", "hide");
}


var detailDocWidth = "";
var detailDocHeight = "";
function SetActivePageView(url, w, h)
{
	detailDocWidth = w;
	detailDocHeight = h;

	if($("activeLayerDiv") == null){
		var div = document.createElement('div');
		div.style.position = "absolute";
		div.style.display = "none";
		div.style.zIndex = 103;
		div.setAttribute("id", "activeLayerDiv");
		document.body.appendChild(div);
	}
	
	$("activeLayerDiv").style.width = detailDocWidth + "px";
	$("activeLayerDiv").style.height = detailDocHeight + "px";
	
	var popx = (document.body.clientWidth - detailDocWidth) / 2;
	var popy = (document.body.clientHeight / 2) - (h/2);

	$("activeLayerDiv").innerHTML = "<iframe name='activeLayerFrame' src='"+url+"' id='activeLayerFrame' allowtransparency='true' width='"+detailDocWidth+"'height='"+detailDocHeight+"' frameborder='0' scrolling='no'></iframe>";
	$("activeLayerDiv").style.left = popx;
	$("activeLayerDiv").style.top = 25 + document.body.scrollTop;
	$("activeLayerDiv").show();
	//$("activeLayerDiv").onmouseover = function(){SetActivePopScoll();}
	
}
function SetActiveBodyBg()
{
	if($("bodyBgDiv") == null) {
		createElement("bodyBgDiv");
	}
	
	//bg Layer ³ôÀÌ ¼³Á¤
	var cheight = document.body.clientHeight;
	var sheight = document.body.scrollHeight;
	if(cheight >= sheight)
		$("bodyBgDiv").style.height = cheight +'px';
	else
		$("bodyBgDiv").style.height = sheight+'px';
		
	var obj = $("bodyBgDiv");
	obj.show();
	obj.onclick=function(){	ActiveLayerHide(); }
}
function SetActiveLoadingLayer()
{
	if($("activeLoadingDiv") == null){
		var div = document.createElement('div');
		div.style.position = "absolute";
		div.style.width = "218px";
		div.style.height = "83px";
		div.style.display = "none";
		div.style.zIndex = 102;
		div.setAttribute("id", "activeLoadingDiv");
		document.body.appendChild(div);
		
		div.innerHTML = "<table width='218' border='0' cellspacing='0' cellpadding='0'><tr>" +
								"			<td align='center'><img src='/Images/Map/MtMap/loading.gif' alt='°Ë»öÁß' width='218' height='83'></td></tr></table>";
	}
	var popx = (document.body.clientWidth - 230) / 2;
	var popy = (document.body.clientHeight / 2) - 41;
	
	if(popx > 360)
		$("activeLoadingDiv").style.left = popx;
	else
		$("activeLoadingDiv").style.left = 290;

	$("activeLoadingDiv").style.top = popy + document.body.scrollTop;
	$("activeLoadingDiv").show();		
}

function createElement(divName)
{
	var div = document.createElement('div');
	div.style.position = "absolute";
	div.style.width = "100%";	
	div.style.cursor = "hand";
	div.style.cursor = "pointer";
	div.style.top = "0px";
	div.style.display = "none";
	div.style.zIndex = 100;
	div.style.background = "#000000";
	div.style.filter = "alpha(opacity=40)";
	div.setAttribute("id", divName);
	document.body.appendChild(div);
	$("bodyBgDiv").setOpacity(0.5); 

	return divName;
}
function ActiveLayerHide()
{
	if(isIE)
		document.body.onmousewheel = null;
	else
		document.removeEventListener('DOMMouseScroll', nowheel, false);
		
	$("bodyBgDiv").hide();
	$("activeLoadingDiv").hide();
	$("activeLayerDiv").hide();	
	$("activeLayerFrame").src = "";
	$("activeLayerDiv").style.width = 0;
	$("activeLayerDiv").style.height = 0;
	$("activeLoadingDiv").style.width = 0;
	$("activeLoadingDiv").style.height = 0;
	HideCombo("select", "show");
}
// ·¹ÀÌ¾î ÆäÀÌÁö ·Îµù ³¡

/* °ø¿¬ ´ã±â °ü·Ã ÇÔ¼ö ½ÃÀÛ
function SaveActFolder(pid, kind, userid,thisPage){
	if(confirm("¼±ÅÃÇÑ °ø¿¬Á¤º¸¸¦ ´ã°Ú½À´Ï±î?")) {
		InsertActFolder_ajax(pid, kind, userid,thisPage);
	}else{ return; }
}
function InsertActFolder_ajax(pid, kind, userid,thisPage){
	eval(thisPage).InsertActFolder(pid, kind, userid, InsertActFolder_CallBack);
}
function InsertActFolder_CallBack(res){
	//res.value°¡ 1ÀÌ¸é ÀúÀå ¼º°ø, 0ÀÌ¸é ÀÌ¹ÌÀúÀåµÇÀÖ´Â »óÅÂ
	try
	{
		if(res.value == 1){
			//ShowActFolderSucessLayer();
			var docWidth = "400";
			var docHeight = "230";
			var popx = (document.body.clientWidth - docWidth) / 2;
			var popy = (document.body.clientHeight / 2) - (docHeight/2);
			window.open("/Scripts/Theme/Act/PopActFolder.aspx", "popup", "width=400, height=230, top="+popy+", left=" + popx);
		}else if(res.value == 0){
			alert("ÀÌ¹Ì ÀúÀåµÇ¾î ÀÖ´Â °ø¿¬ Á¤º¸ ÀÔ´Ï´Ù.");
		}else{
			alert("ÀÏ½ÃÀûÀÎ ½Ã½ºÅÛ Àå¾Ö·Î ÀÎÇØ Á¤»óÀûÀ¸·Î Ã³¸® µÇÁö ¾Ê¾Ò½À´Ï´Ù.\n\n´Ù½Ã ½Ãµµ ÇØ º¸¼¼¿ä.");
		}
	}catch(ex){}
}
function ShowActFolderSucessLayer(){

	//SetActivePopLayer("/Scripts/Theme/Act/PopActFolder.aspx", 402, 230)
	
	var docWidth = "410";
	var docHeight = "300";
	if($("activeLayerDiv") == null){
		var div = document.createElement('div');
		div.style.position = "absolute";
		div.style.width = docWidth + "px";
		div.style.height = docHeight + "px";
		div.style.display = "none";
		div.setAttribute("id", "activeFolderLayerDiv");
		document.body.appendChild(div);
	}
	var popx = (document.body.clientWidth - docWidth) / 2;
	var popy = (document.body.clientHeight / 2) - (docHeight/2);

	$("activeFolderLayerDiv").innerHTML = "<iframe name='activeLayerFolderFrame' src='/Scripts/Theme/Act/PopActFolder.aspx' id='activeLayerFolderFrame' allowtransparency='true' width='"+docWidth+"'height='"+docHeight+"' frameborder='0' z-index:2></iframe>";
	$("activeFolderLayerDiv").style.left = popx;
	$("activeFolderLayerDiv").style.top = popy + document.body.scrollTop;
	$("activeFolderLayerDiv").show();
	
}
// °ø¿¬ ´ã±â °ü·Ã ÇÔ¼ö ³¡ */
