function ifrmResize(obj) {
    var Body;
    var H, Min;
//    Min = 169;
    Min = 196;
    Body = (obj.contentWindow.document.getElementsByTagName('BODY'))[0];
    H = parseInt(Body.scrollHeight);
    obj.style.height = (H<Min?Min:H) + 'px';

}

function ifrm_resize() {
  parent.document.all.contFrame.style.height=document.body.scrollHeight;
  Tid = setTimeout("ifrm_resize()",500);
  setTimeout("clearTimeout(Tid)",50000);
//  clearTimeout(Tid);
}

function ifrm_resize2() {
  parent.document.all.Hcost.style.height=document.body.scrollHeight;
  Tid = setTimeout("ifrm_resize2()",500);
  setTimeout("clearTimeout(Tid)",50000);
//  clearTimeout(Tid);
}

function showCal(obj_nm,obj_no){
  if (document.all[obj_nm+"_"+obj_no].style.display=="none") {
    document.all[obj_nm+"_"+obj_no].style.display = "block";
  } else {
    document.all[obj_nm+"_"+obj_no].style.display = "none";
  }
}

function sendDate_old(obj_no,dateVal,chk) {
  var error = "ok";
  var objForm;
  if(chk=="x") {
	objForm = comSerach.theForm;
  } else {
	objForm = theForm;
  }
  var obj = eval("objForm.v_date"+obj_no);
  obj.value = dateVal;
  document.all["cal_"+obj_no].style.display = "none";

  if(objForm.v_date0.value=="" && objForm.v_date1.value!=""){
    alert(msg_0103); error="ng";
  }
  if(objForm.v_date0.value!="" && objForm.v_date1.value!=""){
    var st = objForm.v_date0.value.split("-");
    var en = objForm.v_date1.value.split("-");
    var sd = new Date(st[0],st[1]-1,st[2].substr(0,2));
    var ed = new Date(en[0],en[1]-1,en[2].substr(0,2));
    chkdate = (ed.getTime()-sd.getTime())/(1000*24*60*60);
    if(chkdate>30){
      alert(msg_0107)
      objForm.v_date0.value = "";
      objForm.v_date1.value = "";
		  error="ng";
    } else if(chkdate < 1){
      alert(msg_0108)
      objForm.v_date0.value = "";
      objForm.v_date1.value = "";
		  error="ng";
    }
    if(error=="ok" && chk=="c") {
      document.theForm.action = "roomcost.php";
      document.theForm.target = "_self";
      document.theForm.submit();
    }
  }

}

function sendDate(obj_no,dateVal,chk,tgt) {
  var error = "ok";
  var objForm;
  objForm = document.theForm;

  var obj = eval("objForm.v_date"+obj_no);
  obj.value = dateVal;
  setDateCookie("c_date"+obj_no,dateVal);
  endFrame.document.location.reload();

  document.getElementById(tgt+"_"+obj_no).style.display = "none";

  if(objForm.v_date0.value=="" && objForm.v_date1.value!=""){
    alert(msg_0103); error="ng";
  }

  if(objForm.v_date0.value!=""){
    var st = objForm.v_date0.value.split("-");
    var sd = new Date(st[0],st[1]-1,st[2].substr(0,2));

    var et = new Date(st[0],st[1]-1,st[2].substr(0,2));
    var timestamp = et.getTime() + 86400000;
    var end = new Date();
    end.setTime(timestamp);

    var month = end.getMonth() + 1;
    month = month < 10 ? "0"+month : month;

    var date = end.getDate();
    date = date < 10 ? "0"+date : date;
    
    //var week = new Array("ÀÏ", "¿ù", "È­", "¼ö", "¸ñ", "±Ý", "Åä");
    //var day = week[end.getDay()];

    var end_date = end.getFullYear() + "-" + month + "-" + date;

    if (objForm.v_date1.value=="")
      objForm.v_date1.value = end_date;

    var en = objForm.v_date1.value.split("-");    
    var ed = new Date(en[0],en[1]-1,en[2].substr(0,2));
    chkdate = (ed.getTime()-sd.getTime())/(1000*24*60*60);
    if(chkdate>30){
      alert(msg_0107);
      objForm.v_date0.value = "";
      objForm.v_date1.value = "";
      error="ng";
    } else if(chkdate < 1){
      if(obj_no==1) {
        alert(msg_0108);
        objForm.v_date1.value = "";
        error="ng";
      } else {
        objForm.v_date1.value = end_date;
      }
    }
    if(error=="ok" && chk=="c") {
      getInfoView();
    }
  }
	/*
  var error = "ok";
  var objForm;
  if(chk=="x") {
  	objForm = comSerach.theForm;
  } else if (chk=="r") { //¸ÞÀÎ Search¿¡¼­ ÇØ¿ÜÈ£ÅÚ »ç¿ë
  	objForm = comSerach1.theForm;
  } else {
  	objForm = document.theForm;
  }
  var obj = eval("objForm.v_date"+obj_no);
  obj.value = dateVal;
  setDateCookie("c_date"+obj_no,dateVal);
  endFrame.document.location.reload();

//  document.all[tgt+"_"+obj_no].style.display = "none";
  document.getElementById(tgt+"_"+obj_no).style.display = "none";

  if(objForm.v_date0.value=="" && objForm.v_date1.value!=""){
    alert(msg_0103); error="ng";
  }
  if(objForm.v_date0.value!="" && objForm.v_date1.value!=""){
    var st = objForm.v_date0.value.split("-");
    var en = objForm.v_date1.value.split("-");
    var sd = new Date(st[0],st[1]-1,st[2].substr(0,2));
    var ed = new Date(en[0],en[1]-1,en[2].substr(0,2));
    chkdate = (ed.getTime()-sd.getTime())/(1000*24*60*60);
    if(chkdate>30){
      alert(msg_0107);
      objForm.v_date0.value = "";
      objForm.v_date1.value = "";
  	  error="ng";
    } else if(chkdate < 1){
      if(obj_no==1) {
        alert(msg_0108);
//        objForm.v_date0.value = "";
        objForm.v_date1.value = "";
        error="ng";
      } else {
        objForm.v_date1.value = "";
      }
    }
    if(error=="ok" && chk=="c") {
//      document.theForm.action = "roomcost.php";
//      document.theForm.target = "_self";
//      document.theForm.submit();
      getInfoView();
    }
  }
  **/
}


function close_layer(obj_nm) {
  var num= 0;
	while (true) {
    if (document.getElementById(obj_nm+"_"+num)!=null) {
      document.getElementById(obj_nm+"_"+num).style.display = "none";
    } else {
      break;
    }
    num++;
  }
}

function toggle_sub_layer(obj_nm,obj_no) {
  close_layer(obj_nm);
  document.all[obj_nm+"_"+obj_no].style.display = "block";
}


function inquiry_send() {
  var error = "ok";
  if (theForm.v_res_nm.value=="") {
    alert(msg_0146);
    error="ng";  theForm.v_res_nm.focus();
  }
  if (error=="ok" && theForm.v_sur_nm.value=="") {
    alert(msg_0147);
    error = "ng";  theForm.v_sur_nm.focus();
  }
  if (error=="ok" && (theForm.v_email1.value=="" || theForm.v_email2.value=="")) {
    alert(msg_0113);
    error = "ng";
  }
  if (error=="ok" && theForm.v_nan_cd.value=="") {
    alert(msg_0142);
    error = "ng";  theForm.v_nan_cd.focus();
  }
  if (error=="ok" && theForm.v_tel.value=="") {
    alert(msg_0135);
    error = "ng";  theForm.v_tel.focus();
  }
	if(error=="ok" && theForm.v_nation.selectedIndex==0) {
		alert(msg_0153);
		error="ng";  theForm.v_nation.focus();
	}
  if (error=="ok" && theForm.v_pname.value=="") {
    alert(msg_0148);
    error = "ng";  theForm.v_pname.focus();
  }
  if (error=="ok" && theForm.v_sdate.value=="") {
    alert(msg_0149);
    error = "ng";  theForm.v_sdate.focus();
  }
  if (error=="ok" && theForm.v_edate.value=="") {
    alert(msg_0150);
    error = "ng";  theForm.v_edate.focus();
  }
  if (error=="ok" && theForm.v_room.value=="") {
    alert(msg_0136);
    error = "ng";  theForm.v_room.focus();
  }
  if (error=="ok" && theForm.v_use_no.value=="") {
    alert(msg_0152);
    error = "ng";  theForm.v_use_no.focus();
  }
  if (error=="ok") {
    theForm.submit();
  }
}

function reserve_send(memtype) {	
	if (memtype == 1)	{
		if (!loginStatus())	{
			alert(msg_0155);
			return false;
		}
	}
  var error = "ok";
  if(error=="ok" && theForm.v_agree[0].checked!=true) {
    alert(msg_0111);
    error="ng";
  }
  if(error=="ok" && theForm.v_res_nm.value=="") {
    alert(msg_0146);
    error="ng";  theForm.v_res_nm.focus();
  }
  if(error=="ok" && theForm.v_sur_nm.value=="") {
    alert(msg_0147);
    error = "ng";  theForm.v_sur_nm.focus();
  }
	if(error=="ok" && theForm.v_nation.selectedIndex==0) {
		alert(msg_0153);
		error="ng";  theForm.v_nation.focus();
	}
  if(error=="ok" && theForm.v_email.value=="") {
    alert(msg_0113);
    error="ng";  theForm.v_email.focus();
  }
  if(error=="ok" && isEmail(theForm.v_email.value)=="") {
    alert(msg_0114);
    error="ng";  theForm.v_email.focus();
  }
  if(error=="ok" && theForm.v_tel.value=="") {
    alert(msg_0135);
    error = "ng";  theForm.v_tel.focus();
  }

  if (error=="ok") {
    //theForm.action = "room_form.php";
		//theForm.target = "execFrame";
		theForm.submit();
  }
}

function roomCheck() {
  var error = "ok";
  if(theForm.v_date0.value=="" ){
    alert(msg_0103); error="ng";
  }
  if (error=="ok" && theForm.v_date1.value == "") {
    alert(msg_0104); error="ng";
  }
  return error;
}

function popCheck() {
  var chk = 0;
  var rcode = "";
  var subquery = "&v_date0="+theForm.v_date0.value+"&v_date1="+theForm.v_date1.value;
  if (roomCheck()=="ok") {
    if(theForm.v_rnum.checked) {
       rcode = theForm.v_rnum.value; chk=1;
    } else {
      for(var i=0;i<theForm.v_rnum.length;i++) {
        if(theForm.v_rnum[i].checked) {
          rcode = theForm.v_rnum[i].value; chk=1;
        }
      }
    }
    if (chk < 1){
      alert(msg_0102);
      return false;
    } else {
      mkWin("cost_view.php?v_rcode="+rcode+"&v_agent="+theForm.v_agent.value+subquery,"0,0,630,300,no");
    }
  }
}

/* »èÁ¦ ÇÊ¿ä¾ø´Â ÇÔ¼ö
function res_send(rcode,wait,tgt) {
	if (!loginStatus())
	{
		alert(msg_0155);
		return false;
	}
  if (roomCheck()=="ok") {
  	document.theForm.action = tgt+"room_res.php";
    document.theForm.v_rcode.value = rcode;
    document.theForm.v_wait.value = wait;
		document.theForm.target = "_parent";
    document.theForm.submit();
  }
}
*/

function priceShow(img_nm,obj_nm,lang) {
  var obj = document.getElementById(obj_nm).style;
	var img_src;
  if (obj.display=="none") {
    obj.display = "block";
		img_src = "/image/kh_"+lang+"/hotel/"+obj_nm+"_detail_close.gif";
    img_nm.src = img_src;
  } else {
    obj.display = "none";
    img_src = "/image/kh_"+lang+"/hotel/"+obj_nm+"_detail_view.gif";
    img_nm.src = img_src;
  }
}

function chkMent(obj_nm,target) {
	var obj = eval("theForm."+obj_nm);
	var tgt = eval("theForm."+target);
	var inn_nm;
  if (obj.checked==true) {
    inn_nm = theForm.v_res_nm.value+" "+theForm.v_sur_nm.value;
    tgt.value = inn_nm;
  } else {
    tgt.value="";
  }
  return false;
}

function bank_send() {
  if (theForm.v_inn_nm.value=="") {
    alert(msg_0263);
    theForm.v_inn_nm.focus();
  } else {
    theForm.action = "../../kor/room/bank_submit.php";
    theForm.target = "execFrame";
    theForm.submit();
  }
}
function MentLayer(sel) {
  MentLayer1.style.display = "none";
  MentLayer2.style.display = "none";
   eval("MentLayer"+sel).style.display = "block";
}


// time check
function mkToday() {
  var today = new Date();
  var buf = "";
  h=today.getHours();
  m=today.getMinutes();
  buf=h+':'+m;
  return buf;
}

function checkOrderConfirmForm()
{
	var f = document.theForm;
	if(!f.v_oid.value)
	{
		alert(msg_0264);
		f.v_oid.focus();
		return false;
	}		
	if(!f.v_email.value)
	{
		alert(msg_0094);
		f.v_email.focus();
		return false;
	}
	var url = "../reservation/res_state_process_ajax.php";

  var queryString = "v_email=" + escape(f.v_email.value) +
									 "&v_oid=" + escape(f.v_oid.value);	
	
	loadXMLDocPost(url, queryString);
	return false;
}

function checkReceiptConfirmForm()
{
	var f = document.theForm;
	if(!f.v_oid.value)
	{
		alert(msg_0264);
		f.v_oid.focus();
		return false;
	}		
	if(!f.v_email.value)
	{
		alert(msg_0094);
		f.v_email.focus();
		return false;
	}
	var url = "../reservation/rec_state_process_ajax.php";

  var queryString = "v_email=" + escape(f.v_email.value) +
									 "&v_oid=" + escape(f.v_oid.value);	

	loadXMLDocPost(url, queryString);
	return false;

}

//Ãß°¡

function getInfoView() {
  reqc = createRequest();
  var handlerFunction = getInfoViewResult;
  reqc.onreadystatechange = handlerFunction;
  var lang = document.getElementById("v_lang").value;
  var pcd = document.getElementById("v_pcode").value;
  var cnt = document.getElementById("v_rcount").value;
	var memtype = document.getElementById("v_memtype").value;
  var dt0 = document.getElementById("v_date0").value.substr(0,10);
  var dt1 = document.getElementById("v_date1").value.substr(0,10);
  var qry = "lang="+lang+"&cnt="+cnt+"&memtype="+memtype+"&dt0="+dt0+"&dt1="+dt1;
  reqc.open("POST","./ajax_infoview.php?"+qry, true);
  reqc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  reqc.send("pcd="+pcd);
}


function getInfoViewResult() {
  if (reqc.readyState == 4) {
    if (reqc.status == 200) {
//  var tmp = reqc.responseText;alert(tmp);return false;
      var output = document.getElementById("roomInfoView");
      var outhtm = reqc.responseText;
      output.innerHTML = outhtm;
    } else {
      alert("There was a problem retrieving the XML data:\n" +
      reqc.statusText);
    }
  }
}

function getOptionView(rcd) {
  reqc = createRequest();
  var handlerFunction = getOptionViewResult;
  reqc.onreadystatechange = handlerFunction;
  var pcd = document.getElementById("v_pcode").value;
  var opt = document.getElementById("v_option").value;
  var qry = "pcd="+pcd+"&rcd="+rcd;
  reqc.open("POST","./ajax_optionview.php?"+qry, true);
  reqc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  reqc.send("opt="+opt);
}

function getOptionViewTest(rcd) {	//»èÁ¦¿¹Á¤
  reqc = createRequest();
  var handlerFunction = getOptionViewResult;
  reqc.onreadystatechange = handlerFunction;
  var pcd = document.getElementById("v_pcode").value;
  var opt = document.getElementById("v_option").value;
  var qry = "pcd="+pcd+"&rcd="+rcd;
  reqc.open("POST","./ajax_optionview_yjhtest.php?"+qry, true);
  reqc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  reqc.send("opt="+opt);
}

function getOptionViewResult() {
  if (reqc.readyState == 4) {
    if (reqc.status == 200) {
//      var tmp = reqc.responseText;alert(tmp);return false;
      var def = "- °í°´´Ô²²¼­´Â OptionÀ» ¼±ÅÃÇÏÁö ¾ÊÀ¸¼Ì½À´Ï´Ù. -";
      var num = 0;
      var obj = document.getElementsByName("option_sel");
      var sel = document.getElementsByName("roomtype_");
      var out = reqc.responseText;
      while (true) {
        if (obj[num] != null) {
          if (sel[num].style.display=="none") {
            obj[num].innerHTML = def;
          } else {
            obj[num].innerHTML = out;
          }
        } else {
          break;
        }
        num++;
      }
    } else {
      alert("There was a problem retrieving the XML data:\n" +
      reqc.statusText);
    }
  }
}

function optionZero(num) {
  document.getElementById("v_option").value = '';
  document.getElementById('v_wait').value = '';
  document.getElementById('room'+num).focus();
}

function iconView(loc,str,bed,lang) {
  //document.getElementById(loc).src = '../../image/kor/img/time_'+str+'.gif';
  document.getElementById('v_wait').value = str;
  document.getElementById('v_rpart').value = bed;
  //document.getElementById('v_cost_type').value = lang; //koreahotel¼öÁ¤
  document.getElementById('v_cost_type').value = 'eng';
}

function autoSel(type,date0,date1) {
  document.getElementById('v_date0').value = date0;
  document.getElementById('v_date1').value = date1;
  getInfoView();
}

function prevCal(rcode) {
  var gbn = document.getElementById("v_gubun").value;
  var opt = document.getElementById("v_option").value;
  optView('./prev_calculator.php?v_gubun='+gbn+'&v_rcode='+rcode+'&v_option='+opt,'cal','584','300');
}


//Ãß°¡ ~
function cls_layer(obj_nm) {
  var num= 0;
  var obj = document.getElementsByName(obj_nm);
  while (true) {
    if (obj[num] != null) {
      obj[num].style.display = "none";
    } else {
      break;
    }
    num++;
  }
}

function tog_slayer(obj_nm,obj_no) {
  cls_layer(obj_nm);
  var obj = document.getElementsByName(obj_nm);
  obj[obj_no].style.display = "block";
}


function optView(locationUrl,mode,width,height)
{
  var error = "ok";
  var count = document.getElementById("v_rcount").value;
  var date0 = document.getElementById("v_date0").value.substr(0,10);
  var date1 = document.getElementById("v_date1").value.substr(0,10);
  var v_opt = document.getElementById("v_option").value;
  var qry = '&v_rcount='+count+'&v_date0='+date0+'&v_date1='+date1;
  var tmp = mode=="modi"? qry+'&v_opt='+v_opt:qry;
  if (error=="ok" && date0=="") {
    alert("Åõ¼÷ÇÏ½Ç ³¯Â¥¸¦ ¼±ÅÃÇÏ½Ê½Ã¿À.");
    error="ng";
  }
  if (error=="ok" && date1=="") {
    alert("Åð½ÇÇÏ½Ç ³¯Â¥¸¦ ¼±ÅÃÇÏ½Ê½Ã¿À.");
    error="ng";
  }
  if (error=="ok") {
    optWindow(locationUrl+tmp,width,height);
  } else {
    return false;
  }
}

var optWin;
function optWindow(locationStr, winWidth, winHeight) 
{
	var winTop  = (parseInt(window.screen.height) - parseInt(winHeight)) / 2;
	var winLeft = (parseInt(window.screen.width)  - parseInt(winWidth))  / 2;
	optionStr = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,copyhistory=0,top="+winTop+",left="+winLeft+",width="+winWidth+",height="+winHeight;
  if (optWin) {
      optWin.close();
  }
	optWin = window.open(locationStr,'', optionStr);
	optWin.opener.name = this.name;
}


function resSend(hour,wait,tgt, memtype)
{
	if (memtype == 1)	{
		if (!loginStatus())	{
			alert(msg_0155);
			//windowOpen('../mem/pop_login.php','pop_login','1,1,400,400,no');
			return false;
		}
	}
  var error = "ok";
  var gubun = document.getElementById("v_gubun").value;
  var pwait = document.getElementById("v_wait").value;
  var date0 = document.getElementById("v_date0").value.substr(0,10);
  var date1 = document.getElementById("v_date1").value.substr(0,10);
  if (gubun=="cdo") {
    document.theForm.v_wait.value = wait;
  }
  if (error=="ok" && date0=="") {
    alert(msg_0103);
    error="ng";
  }
  if (error=="ok" && date1=="") {
    alert(msg_0104);
    error="ng";
  }
  if (error=="ok" && gubun!="cdo" && pwait=="") {
    alert(msg_0260);
    error="ng";
  }
  if (error=="ok") {
  	document.theForm.action = tgt;
    document.theForm.v_hour.value = hour;
    document.theForm.submit();
  }
}

function tour_send() {
  var error = "ok";
  if (error=="ok" && theForm.v_usertel.value=="") {
    alert(msg_0135);
    error = "ng";  theForm.v_usertel.focus();
  }
  if (error=="ok" && theForm.v_userhp.value=="") {
    alert(msg_0135);
    error = "ng";  theForm.v_userhp.focus();
  }
  if (error=="ok" && theForm.v_nation.value=="") {
    alert(msg_0153);
    error = "ng";  theForm.v_nation.focus();
  }
  if (error=="ok") {
    theForm.submit();
  }
}