function CheckEmpty(elt, msg) {
	if (elt.value=='') {
		alert(msg);
		elt.focus();
		return false;
	}
	space_cnt = 0;
	for( var i = 0; i < elt.value.length; i++ ) {
		onechar = elt.value.charAt( i );
		if (onechar==" ") space_cnt++;
	}
	if (space_cnt==elt.value.length) {
		alert(msg);
		elt.focus();
		return false;
	}

	return true;
} 

//-------------------------------------------------------------------
// ÀÌ¹ÌÁö ÆÄÀÏÀÎ°¡¸¦ Ã¼Å©ÇÏ´Â ÇÔ¼ö
//-------------------------------------------------------------------
function imgPopup(url, pageNm){

	TheURL = "/thejohn/common/imgPopupWin.asp?img_id="+url+"&pageNm="+pageNm;
	posx = (screen.width - 610)/2;
	posy = (screen.height - 500)/2;
	imgPopupwin = window.open(TheURL, "imgPopup", "toolbars=no,menubars=no,scrollbars=yes,left="+posx+",top="+posy);     
	imgPopupwin.focus();
}


//-------------------------------------------------------------------
// ÀÌ¹ÌÁö ÆÄÀÏÀÎ°¡¸¦ Ã¼Å©ÇÏ´Â ÇÔ¼ö
//-------------------------------------------------------------------
function check_image(comp)
{

    var    str =  new String(comp.value).toLowerCase();

    if(str.lastIndexOf("jpeg") > -1 || str.lastIndexOf("jpg") > -1 || str.lastIndexOf("gif") > -1 || str.lastIndexOf("GIF") > -1 || str == '') {
        return;
    } else {
        alert('»çÁø°ü·Ã ¾÷·Îµå´Â jpeg, jpg, gif¸¸ °¡´ÉÇÕ´Ï´Ù.');
		comp.focus();
        return false;
    }
	return true;
}

function isImageFile( fileName ) {
	if (fileName == "")
	{
		 return true;
	}else{
		  var fileSuffix = fileName.substring(fileName.lastIndexOf(".") + 1);
		  fileSuffix = fileSuffix.toLowerCase();
		  if ( "jpg" == fileSuffix || "jpeg" == fileSuffix || "gif" == fileSuffix || "bmp" == fileSuffix  || "png" == fileSuffix ) 
		   return true;
		  else 
		   return false;
	}

}

//¾ÆÀÌÇÁ·¡ÀÓ »çÀÌÁî ¼öÁ¤
function init(){
  var doc = document.getElementById("intForm");
  doc.style.top=0;
  doc.style.left=0;
  if(doc.offsetHeight == 0){
  } else {
    pageheight = doc.offsetHeight;
    pagewidth = doc.offsetWidth;
    parent.frames["apv"].resizeTo(pagewidth,pageheight);
  }
 }

function onmenu(n,m,g_id,e_id,ref){

	for(i=0; i<m; i++) {
		id = "a"+i;
		var obj = document.getElementById(id);
		var szDisplay = obj.style.display;
		if(i == n){
			if(szDisplay == "none")
			{
				obj.style.display = "block";     
				//Å¬¸¯½Ã Ä«¿îÅÍ Áõ°¡?!
				document.frames.item("hiddenFrame").document.forms("frm_action").item("g_id").value = g_id;
				document.frames.item("hiddenFrame").document.forms("frm_action").item("e_id").value = e_id;
				document.frames.item("hiddenFrame").document.forms("frm_action").item("ref").value = ref;
				document.frames.item("hiddenFrame").document.frm_action.submit();
				obj.style.display = "block";        
			}
			else if(szDisplay == "block")
			{
				document.frames.item("hiddenFrame").document.forms("frm_action").item("g_id").value = "";
				document.frames.item("hiddenFrame").document.forms("frm_action").item("e_id").value = "";
				document.frames.item("hiddenFrame").document.forms("frm_action").item("ref").value = "";
				document.frames.item("hiddenFrame").document.frm_action.submit();
				obj.style.display = "none";     
			}     
		}else{
			obj.style.display = "none";     
		}
		//»çÀÌÁî Á¶Àý
		init();

	}
	/*
	 id = "a"+n;
	 var obj = document.getElementById(id);
   var szDisplay = obj.style.display;
    if(szDisplay == "none")
    {
        obj.style.display = "block";        
    }
    else if(szDisplay == "block")
    {
        obj.style.display = "none";     
    }
	*/
 
}
function pv_editOk(idx, chkCD,pagecd)  {

	form = document.forms['intForm'];

  section_cd = eval("form.Section_cd_"+idx);  
  img_file = eval("form.img_file_"+idx);
  photo_txt = eval("form.photo_txt_"+idx);
  list_no = eval("form.list_no_"+idx);

  if (!isImageFile(img_file.value) ) {
   alert("»çÁø°ü·Ã ¾÷·Îµå´Â jpeg, jpg, gif¸¸ ¼±ÅÃÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");
   img_file.focus();
   return false;
  }
  if(!CheckEmpty(photo_txt, "»çÁø ¼³¸íÀ» °£´ÜÈ÷ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À."))	 return false;
	

  if(confirm("¼öÁ¤ ÇÏ½Ã°Ú½À´Ï±î?")) {

    form.pageNum.value = idx;

    form.photo_txt.value = photo_txt.value;
    form.list_no.value = list_no.value;
    form.Section_cd.value = section_cd.value;

    form.hp_id.value = chkCD;

    form.page_cd.value = pagecd;
    form.intType.value = "E";

		form.action = "./pv_insert_exec.asp";
		form.target = "ifexec";
		form.submit();
  }
}

function winHotelFind(){
	TheURL = "../common/hotelfindPopupWin.asp";
	posx = (screen.width - 610)/2;
	posy = (screen.height - 500)/2;
	hfPopupWin = window.open(TheURL, "hfPopup", "toolbars=no,menubars=no,scrollbars=yes,width=500,height=270,left="+posx+",top="+posy);     
	hfPopupWin.focus();
}

function FormatNumber(num){
        fl=""
        if(isNaN(num)) { alert("¹®ÀÚ´Â »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");return 0}
        if(num==0) return num
        
        if(num<0){ 
                num=num*(-1)
                fl="-"
        }else{
                num=num*1 //Ã³À½ ÀÔ·Â°ªÀÌ 0ºÎÅÍ ½ÃÀÛÇÒ¶§ ÀÌ°ÍÀ» Á¦°ÅÇÑ´Ù.
        }
        num = new String(num)
        temp=""
        co=3
        num_len=num.length
        while (num_len>0){
                num_len=num_len-co
                if(num_len<0){co=num_len+co;num_len=0}
                temp=","+num.substr(num_len,co)+temp
        }
        return fl+temp.substr(1)
}

function FormatNumber3(num){
        num=new String(num)
        num=num.replace(/,/gi,"")
        return FormatNumber(num)
}
function num_check() {
        // ie¿¡¼­¸¸ ÀÛµ¿
        var keyCode = event.keyCode
        if (keyCode < 48 || keyCode > 57){
                alert("¹®ÀÚ´Â »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.")
                event.returnValue=false
        }
}
function allcheck(f){ 
//	f = document.refer;
	if(f.chk.checked) {
		for( var i=0; i<f.elements.length; i++) { 
			var check = f.elements[i]; 
			check.checked = true; 
		} 
		return; 
	}else{
		for( var i=0; i<f.elements.length; i++) { 
			var check = f.elements[i]; 
			check.checked = false; 
		} 
		return; 
	}
} 
function onlyNumSemi(obj)
{
	var strTemp = obj.value;
	for(i=0; i<strTemp.length; i++) {
		if (((strTemp.charAt(i) > '9') || (strTemp.charAt(i) < '0')) && (strTemp.charAt(i) != '-')){
			obj.value = obj.value.substring(0, i);
			return;
		}
	}
	return;
}
//==========================================================================================
function choice(Dir,val){
	
	curImg = Dir+"/"+val;
	swImg_1 = Dir+"/"+val;
	swImg_2 = Dir+"/"+val;
	swImg_3 = Dir+"/"+val;
	
	document.images.imgS.style.filter="blendTrans(duration=2)"; 
	document.images.imgS.style.filter="blendTrans(duration=crossFadeDuration)"; 
	document.images.imgS.filters.blendTrans.Apply(); 			
	document.all.imgS.src = curImg;
	document.images.imgS.filters.blendTrans.Play();			
}
//==========================================================================================
//PopUp Photo »ç¿ë
function choice_popup(Dir,val,Tit,hotal){
	
	curImg = Dir+"/"+val;
	swImg_1 = Dir+"/"+val;
	swImg_2 = Dir+"/"+val;
	swImg_3 = Dir+"/"+val;

	if(Tit != ""){
		Tit = hotal + " - " + Tit;
	}else{
		Tit = hotal;
	}
	document.dForm.photo_txt.value = Tit;
	document.images.imgS.style.filter="blendTrans(duration=2)"; 
	document.images.imgS.style.filter="blendTrans(duration=crossFadeDuration)"; 
	document.images.imgS.filters.blendTrans.Apply(); 			
	document.all.imgS.src = curImg;
	document.images.imgS.filters.blendTrans.Play();			
}
//==========================================================================================
function pvAllWin(pagecd){
  TheURL = "../common/pvPopupWin.asp?page_cd="+pagecd;
	posx = (screen.width - 600)/2;
	posy = (screen.height - 500)/2;
	Popupwin = window.open(TheURL, "pvPopupWin", "width=600, height=500, toolbars=no,menubars=no,scrollbars=yes,left="+posx+",top="+posy);     
	Popupwin.focus();
}
		
function email_chk(email) {
  var invalidChars = "\"|&;<>!*\'\\"   ;
  for (var i = 0; i < invalidChars.length; i++) {
    if (email.value.indexOf(invalidChars.charAt ) != -1) {
		alert("Àß¸øµÈ ÀÌ¸ÞÀÏ ÁÖ¼ÒÀÔ´Ï´Ù.");
		email.focus();
		return false;
    }
  }
  if (email.value.indexOf("@")==-1){
		alert("Àß¸øµÈ ÀÌ¸ÞÀÏ ÁÖ¼ÒÀÔ´Ï´Ù. '@'°¡ ¾ø½À´Ï´Ù..");
		email.focus();
		return false;
  }
  if (email.value.indexOf(" ") != -1){
    alert("Àß¸øµÈ ÀÌ¸ÞÀÏ ÁÖ¼ÒÀÔ´Ï´Ù.");
		email.focus();
		return false;
  }
  if (window.RegExp) {
    var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
    var reg1 = new RegExp (reg1str);
    var reg2 = new RegExp (reg2str);
 
    if (reg1.test(email.value) || !reg2.test(email.value)) {
		alert("Àß¸øµÈ ÀÌ¸ÞÀÏ ÁÖ¼ÒÀÔ´Ï´Ù.");
		email.focus();
		return false;
    }
  }
  return true;
}  

function jumin_chk(ju_id1, ju_id2)
{
	var codesum = 0;
	var coderet = 0;

	codesum = ( eval( ju_id1.substring( 0, 1 ) ) * 2 )
            + ( eval( ju_id1.substring( 1, 2 ) ) * 3 )
            + ( eval( ju_id1.substring( 2, 3 ) ) * 4 )
            + ( eval( ju_id1.substring( 3, 4 ) ) * 5 )
            + ( eval( ju_id1.substring( 4, 5 ) ) * 6 )
            + ( eval( ju_id1.substring( 5, 6 ) ) * 7 )
            + ( eval( ju_id2.substring( 0, 1 ) ) * 8 )
            + ( eval( ju_id2.substring( 1, 2 ) ) * 9 )
            + ( eval( ju_id2.substring( 2, 3 ) ) * 2 )
            + ( eval( ju_id2.substring( 3, 4 ) ) * 3 )
            + ( eval( ju_id2.substring( 4, 5 ) ) * 4 )
            + ( eval( ju_id2.substring( 5, 6 ) ) * 5 );
    coderet = 11 - ( eval( codesum % 11 ) );

    if ( coderet >= 10 )
        coderet = coderet - 10;
    if ( coderet >= 10 )
        coderet = coderet - 10;
    if ( eval( ju_id2.substring( 6, 7 ) ) != coderet ){
		return(-1);
    }
	return 1;
}
//=======================================================================================================
//·Î±×ÀÎ
function loginOk(){
	form = document.forms['intForm'];

	if(!CheckEmpty(form.txtID, "¾ÆÀÌµð¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À."))	 return ;
 	if(!CheckEmpty(form.txtPassword, "¾ÏÈ£¸¦ ÀÔ·ÂÇØ ÁÖ½Ê½Ã¿À."))	 return ;
	
	 // ·Î±×ÀÎ Á¤º¸ ÀúÀå Ã¼Å© È®ÀÎÇÏ¿© ÁøÇà
	 if(form.saveid.checked) saveLogin(form.txtID.value);
	 else  saveLogin("");

	form.action = "/thejohn/userHtml/common/loginChk.asp";
	form.submit() ;	
}

//·Î±×¾Æ¿ô
function logoutOk(){
	document.location.href = "/thejohn/userHtml/common/logoutChk.asp";
}
//=======================================================================================================
// ·Î±×ÀÎ Á¤º¸ ÀúÀå
function confirmSave(checkbox)
{
  var isRemember;
  
  // ·Î±×ÀÎ Á¤º¸ ÀúÀåÇÑ´Ù°í ¼±ÅÃÇÒ °æ¿ì
  if(checkbox.checked)
  {
    isRemember = confirm("ÀÌ PC¿¡ ·Î±×ÀÎ Á¤º¸¸¦ ÀúÀåÇÏ½Ã°Ú½À´Ï±î? \n\nPC¹æµîÀÇ °ø°øÀå¼Ò¿¡¼­´Â °³ÀÎÁ¤º¸°¡ À¯ÃâµÉ ¼ö ÀÖÀ¸´Ï ÁÖÀÇÇØÁÖ½Ê½Ã¿À.");
    
    if(!isRemember)
      checkbox.checked = false;
  }
}
 
// ÄíÅ°°ª °¡Á®¿À±â
function getCookie(key)
{
  var cook = document.cookie + ";";
  var idx =  cook.indexOf(key, 0);
  var val = "";
 
  if(idx != -1)
  {
    cook = cook.substring(idx, cook.length);
    begin = cook.indexOf("=", 0) + 1;
    end = cook.indexOf(";", begin);
    val = unescape( cook.substring(begin, end) );
  }
 
  return val;
}
 
// ÄíÅ°°ª ¼³Á¤
function setCookie(name, value, expiredays)
{
  var today = new Date();
  today.setDate( today.getDate() + expiredays );
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";"
}
 
// ÄíÅ°¿¡¼­ ·Î±×ÀÎ Á¤º¸ °¡Á®¿À±â
function getLogin()
{
 var frm = document.forms['intForm'];
 
 // userid ÄíÅ°¿¡¼­ id °ªÀ» °¡Á®¿Â´Ù.
 var id = getCookie("userid");
 
 // °¡Á®¿Â ÄíÅ°°ªÀÌ ÀÖÀ¸¸é
 if(id != "")
 {
  frm.txtID.value = id;
  frm.saveid.checked = true;
 }
}
 
// ÄíÅ°¿¡ ·Î±×ÀÎ Á¤º¸ ÀúÀå
function saveLogin(id)
{
 if(id != "")
 {
  // userid ÄíÅ°¿¡ id °ªÀ» 7ÀÏ°£ ÀúÀå
  setCookie("userid", id, 7);
 }else{
  // userid ÄíÅ° »èÁ¦
  setCookie("userid", id, -1);
 }
}
//=======================================================================================================
//¾ÆÀÌµð Ã£±â
function idFindOk(){
	TheURL = "/thejohn/userHtml/common/pop_idfn.asp";
	posx = (screen.width - 450)/2;
	posy = (screen.height - 200)/2;
	Popupwin = window.open(TheURL, "idPopupWin", "width=430, height=250, toolbars=no,menubars=no,scrollbars=no,left="+posx+",top="+posy);     
	Popupwin.focus();

}
function popIdFindOk(){
	TheURL = "/thejohn/userHtml/common/pop_idfn.asp";
	document.location.href=TheURL;
	window.resizeTo(450,280);

}
//¾ÏÈ£Ã£±â
function pwdFindOk(){
	TheURL = "/thejohn/userHtml/common/pop_pwfn.asp";
	posx = (screen.width - 450)/2;
	posy = (screen.height - 200)/2;
	Popupwin = window.open(TheURL, "idPopupWin", "width=430, height=250, toolbars=no,menubars=no,scrollbars=no,left="+posx+",top="+posy);     
	Popupwin.focus();

}
function popPwdFindOk(){
	TheURL = "/thejohn/userHtml/common/pop_pwfn.asp";
	document.location.href=TheURL;
	window.resizeTo(450,300);
	
}
//=======================================================================================================