function testKey(obj){
	//if (event.keyCode == 13){
	if (obj.value.length < 3)
	{

		DivSetVisible("hotelDiv", "hotelIF", false);
		 return;
	}
	else
	{
		var Parms  = '?hotelNm=' + escape(obj.value);
			Parms += '&nationCd=' + escape(document.all["nationcd"].value);
			Parms += '&cityCd=' + escape(document.all["citycd"].value);

		var res = dynamic.loadHtml('/hotel/HotelSelectList.asp'+ Parms);
		hotelDiv.innerHTML = res;
		DivSetVisible("hotelDiv", "hotelIF", true)
	}
}
function fnHotelSelect(val)
{
	DivSetVisible("hotelDiv", "hotelIF", false);
	document.all["Shnm"].value = val.replace(/†/gi,"'");
}

function txtClear()
{
	if(document.all["nationcd"].value=="")
	{
		alert("먼저 국가와 도시를 선택해 주세요");
		document.all["nationcd"].focus();
		return;
	}
	if(document.all["citycd"].value=="")
	{
		alert("먼저 국가와 도시를 선택해 주세요");
		document.all["citycd"].focus();
		return;
	}
	if (document.all["Shnm"].value.substr(3,2) == "3자") 
		document.all["Shnm"].value = "";
}

// --- 달력 호출하는 부분 ---//
function jsCalendar(frm,nm){
	window.open("/popup/popup_calendar.asp?frm="+frm+"&nm="+nm, "H_CALENDAR", "width=520, height=300");
}

// --- 달력 호출하는 부분 ---//
function jsCalendar2(frm,nm)
{
	window.open("/popup/popup_calendar2.asp?frm="+frm, "H_CALENDAR", "width=522, height=300");
}

// --- 투익 달력 호출하는 부분 ---//
function jsCalendar3(frm,nm){
	window.open("/inc/tourexp/calendar_tourexp.asp?frm="+frm+"&nm="+nm, "H_CALENDAR", "width=570, height=370");
}

//----- 메일보내기 호출하는 부분 ---//
function mailOpen(hCode) {
window.open('/popup/popup_sendmail.asp?hCode='+hCode,'HOTELMAIL','width=500, height=350, scrollbars=no, status=yes');
}

function setDate()
{
	if(document.frmhtlsearch.ciDt.value=="")
	{
		alert("먼저 체크인 날짜를 선택해 주세요");
		return;
	}
	var ndate = document.frmhtlsearch.ciDt.value;
	ndate = ndate.split('-');
	var yyyy = ndate[0];
	var mm = parseInt(ndate[1],10);
	var dd = parseInt(ndate[2],10);

	if(parseInt(mm,10)<10)
	{
		var nmm = "0" + mm;
	}else
	{
		var nmm = mm;
	}
	if(parseInt(dd,10)<10)
	{
		var ndd = "0" + dd;
	}else
	{
		var ndd = dd;
	}
	var ngt = document.frmhtlsearch.ngt.value;
	var cDate = addDay(yyyy, parseInt(mm,10), parseInt(dd,10), ngt)
	var months = parseInt(cDate.getMonth())+1;
	var days = cDate.getDate();

	if(parseInt(months,10)<10)
	{
		months = "0" + months;
	}
	if(parseInt(days,10)<10)
	{
		days = "0" + days;
	}
	document.frmhtlsearch.coDt.value =cDate.getFullYear() + "-" + months + "-" + days;
}

function addDay(yyyy, mm, dd, pDay) // 년, 월, 일, 계산할 일자 (년도는 반드시 4자리로 입력)
{
	var oDate; // 리턴할 날짜 객체 선언
	dd = parseInt(dd)*1 + parseInt(pDay)*1; // 날짜 계산
	mm--; // 월은 0~11 이므로 하나 빼준다

	oDate = new Date(yyyy, mm, dd) // 계산된 날짜 객체 생성 (객체에서 자동 계산)
	return oDate;
}


//----- detail 페이지 이미지 관련 함수 ----//
function fnPic()
{
	var url = mainimg.src;
	url = url.replace(/&/g,"^^");

	LeftPosition=(screen.width)?(screen.width)/2 - 200:300;
	TopPosition=(screen.height)?(screen.height)/2 - 150:450;

	window.open('/hotel/image_pop.asp?url='+url,'IMAGE_VIEW','width=100, height=100,top='+TopPosition+',left='+LeftPosition+',scrollbars=no, status=no');
}

function fnPic_Show(hCode)
{
	LeftPosition=(screen.width)?(screen.width)/2 - 200:300;
	TopPosition=(screen.height)?(screen.height)/2 - 150:450;

	window.open('/popup/popup_photoV.asp?hCode='+hCode,'IMAGE_VIEW','width=690, height=588,top='+TopPosition+',left='+LeftPosition+',scrollbars=no, status=no');
}

function fnViewimg(mode)
{
	var nowcnt = frmimgcnt.nowcnt.value;
	var imgcnt = frmimgcnt.imgcnt.value;

	for(var i=1;i<=imgcnt;i++)
	{
		var img = "img"+i;
		document.all[img].style.display='none';
	}

	if(mode=="pre")
	{
		if(nowcnt==1)
		{
			var imgs = "img"+nowcnt;
			document.all[imgs].style.display='';
			alert("가장 처음 이미지입니다.");
			return;
		}else{
			frmimgcnt.nowcnt.value=parseInt(frmimgcnt.nowcnt.value)-1;
			nowcnt = frmimgcnt.nowcnt.value;
			var imgs = "img"+nowcnt;
			document.all[imgs].style.display='';
		}
	}else{
		if(nowcnt==imgcnt)
		{
			var imgs = "img"+nowcnt;
			document.all[imgs].style.display='';
			alert("가장 마지막 이미지입니다.");
			return;
		}else{
			frmimgcnt.nowcnt.value=parseInt(frmimgcnt.nowcnt.value)+1;
			nowcnt = frmimgcnt.nowcnt.value;
			var imgs = "img"+nowcnt;
			document.all[imgs].style.display='';
		}

	}
}
