window.size = function()
{
	var w = 0;
	var h = 0;

	//IE
	if(!window.innerWidth)
	{
		//strict mode
		if(!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}

window.center = function()
{
	var hWnd = (arguments[0] != null) ? arguments[0] : {width:0,height:0};

	var _x = 0;
	var _y = 0;
	var offsetX = 0;
	var offsetY = 0;

	//IE
	if(!window.pageYOffset)
	{
		//strict mode
		if(!(document.documentElement.scrollTop == 0))
		{
			offsetY = document.documentElement.scrollTop;
			offsetX = document.documentElement.scrollLeft;
		}
		//quirks mode
		else
		{
			offsetY = document.body.scrollTop;
			offsetX = document.body.scrollLeft;
		}
	}
	//w3c
	else
	{
		offsetX = window.pageXOffset;
		offsetY = window.pageYOffset;
	}

	_x = ((this.size().width-hWnd.width)/2)+offsetX;
	_y = ((this.size().height-hWnd.height)/2)+offsetY;

	return{x:_x,y:_y};
}
function CreateFlash(pWidth,pHeight,pPath,pOption,pFlashVar)
{
	document.write("<DIV STYLE='z-index:0;'>");
	document.write("<OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' WIDTH='" + pWidth + "' HEIGHT='" + pHeight + "' VIEWASTEXT>");
	document.write("<PARAM NAME='movie' VALUE='" + pPath + "'>");
    document.write("<PARAM NAME='quality' VALUE='high'>");
    document.write("<PARAM NAME='wmode' VALUE='transparent'>");
    if(pFlashVar!="undefined")
    {	
		//if(pFlashVar.length>0)
		//{
			document.write("<PARAM name='FlashVars' value='" + pFlashVar + "'>");
		//}
	}
	
	document.write("<EMBED SRC='" + pPath + "' QUALITY='high' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer' TYPE='application/x-shockwave-flash' WIDTH='" + pWidth + "' HEIGHT='" + pHeight + "' " + pOption +"></EMBED>");
	document.write("</OBJECT>");
	document.write("</DIV>");
}
function CreateFlash2(pWidth,pHeight,pPath,pOption,pFlashVar, oparam)
{
	document.write("<DIV STYLE='z-index:0;' id='x'>");
	document.write("<OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' WIDTH='" + pWidth + "' HEIGHT='" + pHeight + "' VIEWASTEXT>");
	document.write("<PARAM NAME='movie' VALUE='" + pPath + "'>");
    document.write("<PARAM NAME='quality' VALUE='high'>");
    document.write("<PARAM NAME='wmode' VALUE='transparent'>");
    document.write("<PARAM NAME='allowScriptAccess'  VALUE='always'> ");
    
    if(pFlashVar!="undefined")
    {	
		//if(pFlashVar.length>0)
		//{
			document.write("<PARAM name='FlashVars' value='" + pFlashVar + "'>");
		//}
	}
	document.write("<EMBED SRC='" + pPath + "' QUALITY='high' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer' TYPE='application/x-shockwave-flash' WIDTH=" + pWidth + " HEIGHT=" + pHeight + " " + pOption +"></EMBED>");
	document.write("</OBJECT>");
	document.write("</DIV>");
}
function Trim(value) {
 return value.replace(/^\s+|\s+$/g,"");
}
 
function LTrim(value) {
 return value.replace(/^\s+/,"");
}
 
function RTrim(value) {
 return value.replace(/\s+$/,"");
}
function GetPersonCountByRoomType(rtype)
{
	switch(rtype)
	{
	case "SGL":
		return 1;
	case "DBL":
		return 2;
	case "TRP":
		return 3;
	case "QUD":
		return 4;
	case "DBL1":
		return 3;
	}
}

function LoadPopUpContents(pType,pURL,pMessage)
{
    var divPopUp = document.getElementById("POPUPLAYER");
    var divPopUpLayerContents = document.getElementById("POPUPLAYERCONTENTS");
    //var divPopUpContents = document.getElementById("POPUPCONTENTS");
    var ifPopUpLayer = document.getElementById("IFPOPUPLAYER");
    
    var pWidth = 0;
    var pHeight = 0;
    //ifPopUpLayer.src = "";
    switch(pType)
    {
        case "CODISEARCH" :
        {
            pWidth = 760;
            ifPopUpLayer.src = pURL;
            break;
        }
        case "HOTELDETAIL" :
        {
            pWidth = 763;            
            ifPopUpLayer.src = pURL;
            break;
        }
        case "RESERVATION" :
        {
            pWidth = 763;            
            ifPopUpLayer.src = pURL;
            break;
        }
        default :
        {
            pWidth = 760;
            ifPopUpLayer.src = pURL;
            break;
        }
    }
    
    pHeight = document.body.clientHeight * 0.9;
    
    divPopUp.style.width = pWidth + 18 + "px";
    document.getElementById("POPUPCLOSE").style.width = pWidth + 18 + "px";
    //document.getElementById("POPUPLAYERCONTENTS").style.width = pWidth + "px";
    divPopUp.style.height = pHeight;
    divPopUpLayerContents.style.height = pHeight-14;
    ifPopUpLayer.style.height = pHeight;
    ifPopUpLayer.style.width =  pWidth + 8 + "px";//"100%";
    divPopUp.style.top = document.body.scrollTop + (document.body.clientHeight - pHeight)/2;
	divPopUp.style.left = document.body.clientWidth/2-pWidth/2;
    divPopUp.style.display = "block";    
    if(pMessage!="")
    {
        //OpenLoading(pMessage);
    } else {
        OpenCurtain();
    }
}

function OpenPopUpLayer(pType,pURL,pMessage)
{
    var pHeight;
    var divPopUp = document.getElementById("POPUPLAYER");
    var divPopUpLayerContents = document.getElementById("POPUPLAYERCONTENTS");
    var ifPopUpLayer = document.getElementById("IFPOPUPLAYER");
    var pWidth = 765;   
    var divClose = document.getElementById("POPUPCLOSE");
    divClose.style.display="none";
    var divPopUpCurtain = document.getElementById("POPUPCURTAIN");
    divPopUpCurtain.style.display="block";
    ifPopUpLayer.src = "/blank.html";
    pHeight = document.body.clientHeight * 0.9;       
    divPopUp.style.backgroundColor="F5F5F5";
    divPopUp.style.top = document.body.scrollTop + (document.body.clientHeight - 10)/2;
	divPopUp.style.left = document.body.clientWidth/2-10/2;
    divPopUp.style.width = 0;
    divPopUp.style.height = 0;
    divPopUpLayerContents.style.width = 0;
    divPopUpLayerContents.style.height = 0;
    ifPopUpLayer.style.width=0;
    ifPopUpLayer.style.height=0;
    divPopUp.style.display="block";
    
    //window.setTimeout("Animation('" + pType + "','" + pURL + "','" + pMessage + "')",10);
    LoadPopUpContents(pType,pURL,pMessage);
}

function Animation(pType,pURL,pMessage)
{
    var divPopUp = document.getElementById("POPUPLAYER");
    
    var divPopUpLayerContents = document.getElementById("POPUPLAYERCONTENTS");
    var ifPopUpLayer = document.getElementById("IFPOPUPLAYER");
    var pHeight;
    var pWidth;
    pWidth = 760;
    pHeight = document.body.clientHeight * 0.9;
    
    var pOffsetWidth = pWidth/30;
    var pOffsetHeight = pHeight/30;
    
    if(parseInt(divPopUp.style.width)>=pWidth )
    {   
        if(parseInt(divPopUp.style.height)<pHeight)
        { 
            divPopUp.style.height = parseInt(divPopUp.style.height) + pOffsetHeight;
        } else {    
            LoadPopUpContents(pType,pURL,pMessage);
            return;
         }
    } else {
        if(parseInt(divPopUp.style.width)<pWidth)
        {
            divPopUp.style.width = parseInt(divPopUp.style.width) + pOffsetWidth;        
        } 
    }
    
    try {
        divPopUp.style.top = document.body.scrollTop + (document.body.clientHeight - parseInt(divPopUp.style.height))/2;
	    divPopUp.style.left = document.body.clientWidth/2-parseInt(divPopUp.style.width)/2;
	} catch(e) {
	}
	
	window.setTimeout("Animation('" + pType + "','" + pURL + "','" + pMessage + "')",10);
}

function NoWheel()
{
	//if(!isIE)
	//{
	//	e.preventDefault();
	//}
	return false;
}

function ClosePopUpLayer()
{
	var divPopUp = document.getElementById("POPUPLAYER");
	var ifPopUpLayer = document.getElementById("IFPOPUPLAYER");
	
    divPopUp.style.display = "none";
    
    document.body.onmousewheel = null ;
    document.body.onresize = null ;
    
    CloseCurtain();
    
    
}

function CloseCurtain()
{    
	var divPopUp = document.getElementById("POPUPLAYER");
	var divCurtain = document.getElementById("Curtain");
	if(divPopUp.style.display!="none" && divCurtain.style.display!="none")
	{
//		alert("a1");
		
		divCurtain.style.zIndex="2000";
    }
    else
    {
//    alert("a2");
		
		document.getElementById("Curtain").style.display="none";
		document.body.onmousewheel = null ;
		document.body.onresize = null ;
    }
    var divLoading = document.getElementById("LOADINGLAYER");
    divLoading.style.display="none";
}

function OpenCurtain()
{
	var divPopUp = document.getElementById("POPUPLAYER");
	
	var divCurtain = document.getElementById("Curtain");
	if(divPopUp.style.display!="none" && divCurtain.style.display!="none")
	{
		divCurtain.style.zIndex="2250";
    }
    else
    {
		divCurtain.style.zIndex="2000";
		divCurtain.style.height=document.body.scrollHeight + "px";
		divCurtain.style.display="block";
    }
    document.body.onmousewheel = NoWheel ;
}

function OpenLoading(pVal)
{	
	if(pVal==undefined)
		return;
    OpenCurtain();
    
    var divLoading = document.getElementById("LOADINGLAYER");
    //divLoading.style.top = document.body.clientHeight/2-85;
    divLoading.style.top = document.body.offsetHeight/2-85+document.body.scrollTop;
	divLoading.style.left = document.body.clientWidth/2-133;
	
	document.getElementById("LOADINGLAYERTEXT").innerHTML = pVal;
	
    divLoading.style.display="block";
}

function OpenIndicator(pFlag)
{	
	//if(pVal==undefined)
	//	return;
	if(pFlag)
	{
        OpenCurtain();
    }
    
    var divLoading = document.getElementById("INDICATOR");
    //divLoading.style.top = document.body.clientHeight/2-85;
    divLoading.style.top = document.body.offsetHeight/2-85+document.body.scrollTop;
	divLoading.style.left = document.body.clientWidth/2-133;
	
	//document.getElementById("LOADINGLAYERTEXT").innerHTML = pVal;
	
    divLoading.style.display="block";
}

function OpenBigLoading(pVal)
{	
	
    OpenCurtain();
    var tpoint=window.center({width:730,height:288});
    
    var divLoading = document.getElementById("BIGLOADINGLAYER");
    //divLoading.style.top = document.body.clientHeight/2-85;
    //divLoading.style.top = document.body.offsetHeight/2-144+document.body.scrollTop;
	//divLoading.style.left = document.body.clientWidth/2-364;
	divLoading.style.top = tpoint.y+"px";
	divLoading.style.left = tpoint.x+"px";
	
	
	//document.getElementById("LOADINGLAYERTEXT").innerHTML = pVal;
	
    divLoading.style.display="block";
}
function CloseBigLoading()
{
	var divLoading = document.getElementById("BIGLOADINGLAYER");
    divLoading.style.display="none";
    
    CloseCurtain();    
}
function CloseLoading()
{
	var divLoading = document.getElementById("LOADINGLAYER");
    divLoading.style.display="none";
//    alert("a");
		
    CloseCurtain();    
}

function CloseIndicator()
{
	var divLoading = document.getElementById("INDICATOR");
    divLoading.style.display="none";
//    alert("a");
		
    CloseCurtain();    
}

function OnClickCurtain()
{
	var tObj = document.getElementsByTagName("DIV");
	
	try {
		for(var i=0;i<tObj.length;i++)
		{
			try {
				if(tObj(i).style.zIndex>0)
				{
					tObj(i).style.display="none";
				}
			} catch(E) {
			}
		}
		CloseCurtain();   
	} catch(E) {
	}
}

function OnResizePopUpLayer(pWidth,pPopContentsHeight)
{   
//alert(pHeight);
    var divPopUp = document.getElementById("POPUPLAYER");
    var divPopUpLayerContents = document.getElementById("POPUPLAYERCONTENTS");
    var ifPopUpLayer = document.getElementById("IFPOPUPLAYER");
    var pHeight = 0;
    //var pWidth = 760;
    pHeight = document.body.clientHeight * 0.9;
    
    divPopUp.style.height = pHeight;
    divPopUpLayerContents.style.height = pHeight-14;
    ifPopUpLayer.style.height = pHeight;
    divPopUp.style.top = document.body.scrollTop + (document.body.clientHeight - pHeight)/2;
	divPopUp.style.left = document.body.clientWidth/2-pWidth/2;
    divPopUp.style.display = "block";    
    
    var divCurtain = document.getElementById("Curtain");
    divCurtain.style.height=document.body.scrollHeight + "px";
    
    IFPOPUPLAYER.OnResizePopUpContents(pPopContentsHeight);
}

function OnSCrollPopUpLayer(pWidth,pPopContentsHeight)
{   
//alert(pHeight);
    var divPopUp = document.getElementById("POPUPLAYER");
    var divPopUpLayerContents = document.getElementById("POPUPLAYERCONTENTS");
    var ifPopUpLayer = document.getElementById("IFPOPUPLAYER");
    var pHeight = 0;
    //var pWidth = 760;
    pHeight = document.body.clientHeight * 0.9;
        
    divPopUp.style.top = document.body.scrollTop + (document.body.clientHeight - pHeight)/2;
	divPopUp.style.left = document.body.clientWidth/2-pWidth/2;
	
}

function PrintHotelInfo(pHIndex)
{
    window.open("/common/core/PrintContainer.asp?title=호텔상세정보&maincontent=" + escape("/Search/HotelPrintNew.asp?HBIndex=" + pHIndex),"HOTELPRINT","width=770,height=700,top=0,left=0, scrollbars=no,resizable=yes");
}

function TwitHotel(pHotelName,pHBIndex)
{
    //var tURL = "https://twitter.com/?status=" + escape("#hoteljava " + pHotelName + " 제가 연말에 꼬옥 가고싶은 호텔입니다 http://www.hoteljava.co.kr/Hotel/" + pHBIndex + " ");
    var tURL = "/TwitHotel.asp?HBIndex=" + pHBIndex + "&HotelName=" + escape(pHotelName);
    
    window.open(tURL);
}


