isIE=document.all; 
isNN=!document.all&&document.getElementById; 
isN4=document.layers; 
isHot=false; 

function ddInit(e){ 
  topDog=isIE ? "BODY" : "HTML"; 
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){ 
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode; 
  }  
  if (hotDog.id=="titleBar"){ 
    offsetx=isIE ? event.clientX : e.clientX; 
    offsety=isIE ? event.clientY : e.clientY; 
    nowX=parseInt(whichDog.style.left); 
    nowY=parseInt(whichDog.style.top); 
    ddEnabled=true; 
    document.onmousemove=dd; 
  } 
} 

function dd(e){ 
  if (!ddEnabled) return; 
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety; 
  return false;  
} 

function ddN4(whatDog){ 
  if (!isN4) return; 
  N4=eval(whatDog); 
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP); 

N4.onmousedown=function(e){ 
    N4.captureEvents(Event.MOUSEMOVE); 
    N4x=e.x; 
    N4y=e.y; 
  } 
  N4.onmousemove=function(e){ 
    if (isHot){ 
      N4.moveBy(e.x-N4x,e.y-N4y); 
      return false; 
    } 
  } 
  N4.onmouseup=function(){ 
    N4.releaseEvents(Event.MOUSEMOVE); 
  } 
} 

function hideMe(){ 
        document.all.theLayer.style.display = ""; 
        document.all.theLayer.style.display = "none"; 
} 

function showMe(){ 
        document.all.theLayer.style.display = "none"; 
        document.all.theLayer.style.display = ""; 
} 

document.onmousedown=ddInit; 
document.onmouseup=Function("ddEnabled=false"); 


function _ID(obj){return document.getElementById(obj)}


function popupLayer(s,w,h)
{
	if (!w) w = 550;
	if (!h) h = 360;

	var pixelBorder = 0;
	var titleHeight = 0;
	w += pixelBorder * 2;
	h += pixelBorder * 2 + titleHeight;

	var bodyW = document.body.clientWidth;
	var bodyH = document.body.clientHeight;

	var posX = (bodyW - w) / 2;
	var posY = (bodyH - h) / 2;

	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		left = 0;
		top = 0;
		//width = "100%";
		width = document.body.clientWidth;
		if(document.body.clientHeight > document.body.scrollHeight){
			height = document.body.clientHeight;
		}else{
			height = document.body.scrollHeight;
			//alert(document.body.clientHeight +' | '+ document.body.scrollHeight)
		}
		backgroundColor = "#000000";
		filter = "Alpha(Opacity=60)";
		opacity = "0.5";
		BackTable = "<table border='0' cellspacing='0' cellpadding='0' width='"+width+"' height='"+height+"' bgcolor='#FF0000' background='http://web2009.tour2000.com/images_081222/common/top_sub_logo.gif'><tr></td></td></tr></table>";
	}
	obj.id = "objPopupLayerBg";
	document.body.appendChild(obj);
	//document.getElementById("objPopupLayerBg").innerHTML = BackTable;

	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		left = posX + document.body.scrollLeft;
		top = posY + document.body.scrollTop;
		width = w;
		height = h;
		backgroundColor = "#FFFFFF";
		//border = "3px solid #5c5cad";
	}
	obj.id = "objPopupLayer";
	document.body.appendChild(obj);
	
	var bottom = document.createElement("div");
	with (bottom.style){
		position = "absolute";
		width = w - pixelBorder * 2;
		height = titleHeight;
//		width = w;
//		height = titleHeight;

		left = 0;
		top = 0;
		padding = "0px 0px 0px 0px";
		textAlign = "right";
		backgroundColor = "#FFFFFF";
		color = "#ffffff";
		font = "bold 11px tahoma";
		zindex = 5;
	}

	//bottom.innerHTML = "<a href='javascript:closeLayer()'><img src='/n_images/btn/ico_close.gif'></a>";
	//obj.appendChild(bottom);
	ShowBack();

	var ifrm = document.createElement("iframe");
	with (ifrm.style){
	//	width = w - 6;
	//	height = h - pixelBorder * 2 - titleHeight - 3;
		width = w;
		height = h;
		zindex = 5;
	}
	ifrm.id = "objPopupFrame";

	ifrm.frameBorder = 0;
	ifrm.scrolling = 'no';
	ifrm.src = s;
	obj.appendChild(ifrm);
	if(s == "/AirBooking/common/loadingpage_layer.asp" || s == "/common/loadingpage_layer.asp"){
//		s = s;
		obj.innerHTML	=	Fn_Get_Con(s);
	}
	
	if(obj != ""){
		window.onresize = ShowBack;
	}
}

function Fn_Get_Con(url)
	{
		var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		
		xmlHttp.Open("POST",url,false);

		xmlHttp.Send();

			if(xmlHttp.status == 200){
				return xmlHttp.responseText;
			}	
}

function closeLayer(){
	if(_ID('objPopupLayer')){
		_ID('objPopupLayer').parentNode.removeChild( _ID('objPopupLayer') );
		_ID('objPopupLayerBg').parentNode.removeChild( _ID('objPopupLayerBg') );
	}
		
	document.getElementById("div_background").style.display = "none";
	document.getElementById("frm_background").style.display = "none";

}

function ShowBack(){
	if(document.getElementById("div_background").style.display==''){
		var back = document.getElementById("div_background");
		var back2 = document.getElementById("frm_background");
		back.style.left = 0;
		back.style.top = 0;

		if(document.body.scrollWidth > document.body.clientWidth)
			back.style.width = document.body.scrollWidth;
		else
			back.style.width = '100%';

		if(document.body.scrollHeight > document.body.clientHeight)
			back.style.height = document.body.scrollHeight;
		else
			back.style.height = '100%';

		back2.style.left = 0;
		back2.style.top = 0;
		if(document.body.scrollWidth > document.body.clientWidth)
			back2.style.width = document.body.scrollWidth;
		else
			back2.style.width = '100%';
		if(document.body.scrollHeight > document.body.clientHeight)
			back2.style.height = document.body.scrollHeight;
		else
			back2.style.height = '100%';
		
		back.style.filter = "alpha(opacity=50)";
		back2.style.filter = "alpha(opacity=0)";
		back.innerHTML = "<table width='100%' height='100%' bgcolor='#000000'><tr><td></td></tr></table>";
	//	back.style.display = "";
		back2.style.display = "";
	}
}

/*
function ShowBack(){
	var back = document.getElementById("objPopupLayerBg");
	back.style.left = 0;
	back.style.top = 0;
	if(document.body.scrollWidth > document.body.clientWidth){
		back.style.width = document.body.scrollWidth;
	}else{
		back.style.width = '100%';
	}
	if(document.body.scrollHeight > document.body.clientHeight){
		back.style.height = document.body.scrollHeight;
	}else{
		back.style.height = '100%';
	}
	
	back.style.filter = "alpha(opacity=20)";
	back.innerHTML = "<table width='100%' height='100%' bgcolor='#000000'><tr><td></td></tr></table>";
	back.style.display = "";

}
*/

/*
function ShowBack(){
	var back = document.getElementById("div_background");
	var back2 = document.getElementById("frm_background");
	back.style.left = 0;
	back.style.top = 0;
	if(document.body.scrollWidth > document.body.clientWidth)
		back.style.width = document.body.scrollWidth;
	else
		back.style.width = '100%';
	if(document.body.scrollHeight > document.body.clientHeight)
		back.style.height = document.body.scrollHeight;
	else
		back.style.height = '100%';

	back2.style.left = 0;
	back2.style.top = 0;
	if(document.body.scrollWidth > document.body.clientWidth)
		back2.style.width = document.body.scrollWidth;
	else
		back2.style.width = '100%';
	if(document.body.scrollHeight > document.body.clientHeight)
		back2.style.height = document.body.scrollHeight;
	else
		back2.style.height = '100%';

	back.style.filter = "alpha(opacity=20)";
	back2.style.filter = "alpha(opacity=0)";
	back.innerHTML = "<table width='100%' height='100%' bgcolor='#000000'><tr><td></td></tr></table>";
	back.style.display = "";
	back2.style.display = "";
}
*/

	document.writeln("<div id='div_background' style='display:none;position:absolute;z-index:2;height:100%;'></div>");
	document.writeln("<iframe id='frm_background' border=0 frameborder=0 style='display:none;position:absolute;'></iframe>");
	////////////////////·¹ÀÌ¾î °ü·Ã ½ºÅ©¸³Æ® ³¡/////////////////////

	//·¹ÀÌ¾î °ü·Ã	½ÃÀÛ

		var isNav = (navigator.appName.indexOf("Netscape") !=-1);
		var isIE = (navigator.appName.indexOf("Microsoft") !=-1);
		var mouseX;
		var mouseY;

		if (document.layers){
		        document.captureEvents(Event.MOUSEMOVE);
		}
		document.onmousedown=getMouse;

		function getMouse()
		{
			mouseX = (document.layers) ? e.pageX : document.body.scrollLeft + event.clientX + event.offsetX - 50;
			mouseY = (document.layers) ? e.pageY : document.body.scrollTop + event.clientY + event.offsetY;
		}
		
	   document.onkeydown=whatkey;
		function whatkey()
		{
				switch (event.keyCode)
				{
					case 27: //Esc
						parent.closeLayer();
						break;
				}
	    }
		
document.writeln("<DIV ID='tooltip' STYLE='position:absolute;width:380px;height:350px;left:0px;top:0px;display: none; z-index:1'></DIV>");

function showTip(url, txt){

	var E = window.event;

	var strHtml = '';
			strHtml += Fn_Get_Con(url);

	tooltip.style.pixelLeft = E.clientX + document.body.scrollLeft - 230;
	tooltip.style.pixelTop =  E.clientY + document.body.scrollTop + 20;

	tooltip.innerHTML = strHtml;
	tooltip.style.display = '';

}

function hideTip() {
	tooltip.style.display='none';
}
