function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

//¿ìÆí¹øÈ£ °Ë»ö
function zipopen(url,f,ctl1,ctl2,ctl3,ctl4){  
    url = url + "?formctl=" + f + "&ctl1=" + ctl1 + "&ctl2=" + ctl2 + "&ctl3=" + ctl3 + "&ctl4=" + ctl4;
    myWindow = window.open(url, "postnumber", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,copyhistory=0,width=450 ,height=350");
}

//ÀÌ¹ÌÁöº¸±â
function popview(value) {
    window.open("/_src/view_image.asp?image=" + value,"image","left=1, top=1, height=300, width=400, resizable=1, scrollbars=1");
}

function CheckEmail(strEmail) {
  var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
  var check=/@[\w\-]+\./;
  var checkend=/\.[a-zA-Z]{2,3}$/;

  if(((strEmail.search(exclude) != -1)||(strEmail.search(check)) == -1)||(strEmail.search(checkend) == -1)){
      return false;
  }
  else {
      return true;
  }
}

// Ã¢À» ¿ÀÇÂ½ÃÅ²´Ù.
function URL_Open(v_url) {
  open(v_url,'¸µÅ©');
}

// ¼ýÀÚ¸¸ ÀÔ·Â¹Þ´Â´Ù. Æ¯¼ö¹®ÀÚ('-','.',...)µµ Çã¿ëÇÑ´Ù.
function onlyNumber() {
  if((event.keyCode > 31) && (event.keyCode < 45) || (event.keyCode > 57)) {
    event.returnValue = false;
  }
}

// ¼ýÀÚ¸¸ ÀÔ·Â¹Þ´Â´Ù. "-"µµ ¹ÞÁö¾Ê´Â´Ù.
function onlyNumber2(loc) {
  if(/[^0123456789]/g.test(loc.value)) {
    alert("¼ýÀÚ°¡ ¾Æ´Õ´Ï´Ù.\n\n0-9ÀÇ Á¤¼ö¸¸ Çã¿ëÇÕ´Ï´Ù.");
    loc.value = "";
    loc.focus();
  }
}

// ¼ýÀÚ¸¸ ÀÔ·Â¹Þ´Â´Ù. "-"µµ ¹Þ´Â´Ù.
function onlyNumber3(loc) {
  if(/[^0123456789-]/g.test(loc.value)) {
    alert("¼ýÀÚ°¡ ¾Æ´Õ´Ï´Ù.\n\n0-9ÀÇ Á¤¼ö¿Í -¸¸ Çã¿ëÇÕ´Ï´Ù.");
    loc.value = "";
    loc.focus();
  }
}

// ¼ýÀÚ¸¸ ÀÔ·Â¹Þ´Â´Ù. "-"µµ ¹ÞÁö¾Ê´Â´Ù.
function onlyNumber4(loc) {
  if(/[^0123456789,]/g.test(loc.value)) {
    alert("¼ýÀÚ°¡ ¾Æ´Õ´Ï´Ù.\n\n0-9 Á¤¼ö¸¸ Çã¿ëÇÕ´Ï´Ù.");
    loc.value = "";
    loc.focus();
  }
}

// " ¿Í '´Â ÀÔ·Â¹ÞÁö ¾Ê´Â´Ù.
function keylimit() {
  if((event.keyCode == 34) || (event.keyCode == 39)) {
    event.returnValue = false;
  }
}

// & ¿Í / ¿Í ? ´Â ÀÔ·Â¹ÞÁö ¾Ê´Â´Ù.
function keylimit_sms() {
  if((event.keyCode == 38) || (event.keyCode == 47) || (event.keyCode == 63)) {
    event.returnValue = false;
  }
}

// reset
function resetit(frm) {
  form = eval(frm);

  bool = confirm("ÀÔ·ÂµÈ ³»¿ëÀÌ ÀüºÎ Áö¿öÁý´Ï´Ù. °è¼ÓÇÏ½Ã°Ú½À´Ï±î?");
  if (bool) {
     form.reset();
  }
}

// ±×¸²È­ÀÏÀÎÁö °É·¯³½´Ù.
function getextension(filename) {
  if(filename.length > 0) {
    sp = filename.lastIndexOf('.');
    ex = filename.substring(sp+1,sp+5);

//    if((ex.toLowerCase() == "gif") || (ex.toLowerCase() == "jpeg") || (ex.toLowerCase() == "jpe") ||
//       (ex.toLowerCase() == "jpg") || (ex.toLowerCase() == "mpeg") || (ex.toLowerCase() == "mpg") ||
//       (ex.toLowerCase() == "avi")) {
    if((ex.toLowerCase() == "gif") || (ex.toLowerCase() == "jpeg") ||
       (ex.toLowerCase() == "jpe") || (ex.toLowerCase() == "jpg")) {
       return false;
    } else {
       return true;
    }
  } else {
    return false;
  }
}

// ÁÖ¹Îµî·Ï¹øÈ£ Ã¼Å©
function residentno_chk(RegNo1,RegNo2) {
  No1  = parseInt(RegNo1.substring(0,1))
  No2  = parseInt(RegNo1.substring(1,2))
  No3  = parseInt(RegNo1.substring(2,3))
  No4  = parseInt(RegNo1.substring(3,4))
  No5  = parseInt(RegNo1.substring(4,5))
  No6  = parseInt(RegNo1.substring(5,6))

  No7  = parseInt(RegNo2.substring(0,1))
  No8  = parseInt(RegNo2.substring(1,2))
  No9  = parseInt(RegNo2.substring(2,3))
  No10 = parseInt(RegNo2.substring(3,4))
  No11 = parseInt(RegNo2.substring(4,5))
  No12 = parseInt(RegNo2.substring(5,6))
  No13 = parseInt(RegNo2.substring(6,7))

  tot = (No1*2)+(No2*3)+(No3*4)+(No4*5)+(No5*6)+(No6*7)+(No7*8)+(No8*9)+(No9*2)+(No10*3)+(No11*4)+(No12*5);
  rst = ""+(11-(tot-(parseInt(""+(tot/11))*11)))

  if(parseInt(rst) >= 10) {
    rst = ""+(parseInt(rst)-10)
  }

  if(rst != No13) {
    return false;
  } else {
    return true;
  }
}

//ÇÑ±ÛÀÎÁö ¿©ºÎÈ®ÀÎ
function ishangul (target){
    for ( var i=0; i<target.length; i++){
        if ( target.charCodeAt(i) > 256){
            return  true;
        }
    }
    return  false;
}

//Æ¯¼ö¹®ÀÚ Á¦°Å½Ã È®ÀÎ
function hasspecialchar(target){
  for ( i=0; i < target.length; i++){
    if ((target.charAt(i) == "~") ||
    (target.charAt(i) == "`") ||
    (target.charAt(i) == "!") ||
    (target.charAt(i) == "@") ||
    (target.charAt(i) == "#") ||
    (target.charAt(i) == "$") ||
    (target.charAt(i) == "%") ||
    (target.charAt(i) == "^") ||
    (target.charAt(i) == "&") ||
    (target.charAt(i) == "*") ||
    (target.charAt(i) == "(") ||
    (target.charAt(i) == ")") ||
    (target.charAt(i) == "+") ||
    (target.charAt(i) == "=") ||
    (target.charAt(i) == "\\") ||
    (target.charAt(i) == "|") ||
    (target.charAt(i) == "{") ||
    (target.charAt(i) == "}") ||
    (target.charAt(i) == "[") ||
    (target.charAt(i) == "]") ||
    (target.charAt(i) == ";") ||
    (target.charAt(i) == ":") ||
    (target.charAt(i) == "'") ||
    (target.charAt(i) == "\"") ||
    (target.charAt(i) == "<") ||
    (target.charAt(i) == ">") ||
    (target.charAt(i) == ",") ||
    (target.charAt(i) == ".") ||
    (target.charAt(i) == "?") ||
    (target.charAt(i) == "/") ||
    (target.charAt(i) == " ")
    )
    return  true;
    }
  return  false;
}

// ÄÁÆ®·Ñ Ä«¿îÆ®...
function ctl_cnt(frmname,ctlname) {
  frm = eval(frmname);
  cnt = 0;

  for(i=0; i < frm.elements.length; i++) {
     if(frm.elements[i].name == ctlname) {
       cnt = cnt + 1;
     }
  }

  return cnt;
}

// ÀÚ¸®¼ö Ã¤¿ì±â(°ª,Ã¤¿ï¹®ÀÚ,°ªÆ÷ÇÔÀÚ¸®¼ö,Ã¤¿ì´ÂÀ§Ä¡-¿ÞÂÊ,¿À¸¥ÂÊ)
function fillstring(s_str, f_str, tot_cnt, po) {
  if(s_str.length > 0) {
    f_cnt = tot_cnt - s_str.length;
    fill_str = "";
    for(i=0; i<f_cnt; i++) {
       fill_str = fill_str + f_str;
    }
    // Æ÷Áö¼Ç¿¡µû¶ó Ã¤¿öÁØ´Ù.
    if(po == 'LEFT') {
      return fill_str + "" + s_str;
    } else
    if(po == 'RIGHT') {
      return s_str + "" + fill_str;
    } else {
      return s_str;
    }
  } else {
    return "";
  }
}

function format_money(ctl) {
  resultprice = "";
  cnt = 0;
  i = ctl.value.length;
  if(ctl.value.length > 0) {
     while(i > 0) {
        if(ctl.value.substr((i-1),1) != ",") {
           if(cnt == 3) {
              resultprice = "," + resultprice;
              cnt = 0;
           } else {
              resultprice = ctl.value.substr((i-1),1) + resultprice;
              cnt++;
              i--;
           }
        } else {
           i--;
        }
     }
  }
  ctl.value = resultprice;
}

function money_format_trans(price) {
  price = price + "";
  resultprice = "";
  cnt = 0;
  i = price.length;
  if(price.length > 0) {
     while(i > 0) {
        if(price.substr((i-1),1) != ",") {
           if(cnt == 3) {
              resultprice = "," + resultprice;
              cnt = 0;
           } else {
              resultprice = price.substr((i-1),1) + resultprice;
              cnt++;
              i--;
           }
        } else {
           i--;
        }
     }
  }
  return resultprice;
}

function money_format_remove(price) {
    price = price + "";
    resultprice = "";
    cnt = 0;
    i = price.length;
    if(price.length > 0) {
       while(i > 0) {
          if(price.substr((i-1),1) != ",") {
              resultprice = price.substr((i-1),1) + resultprice;
          }
          i--;
       }
    }
    return parseInt(resultprice);
}

function format_money_value(price) {
  resultprice = "";
  cnt = 0;
  i = price.length;
  if(price.length > 0) {
     while(i > 0) {
        if(price.substr((i-1),1) != ",") {
           if(cnt == 3) {
              resultprice = "," + resultprice;
              cnt = 0;
           } else {
              resultprice = price.substr((i-1),1) + resultprice;
              cnt++;
              i--;
           }
        } else {
           i--;
        }
     }
  }
  return resultprice;
}

function mailsend(tomail) {
    window.open('/include/mail_write.asp?toemail=' + tomail,'','width=510,height=430');
}

// ÀÌ¹ÌÁö onLoad¿¡ º»¹® ÀÌ¹ÌÁö »çÀÌÁî ÁÙÀÌ±â
function resizeImg(img,size) {
    var thumb = new Image;
    thumb.src = img.src;
    var w = thumb.width;
//    var refw = screen.width - 240;
//    if ( w > refw ) {
    if ( w > size ) {
//        img.width = refw;
        img.width = size;
    }
    return;
}

    //°Ô½ÃÆÇµî ÃÖ´ë ÀÔ·Â Çã¿ë ±ÛÀÚ¼ö ±îÁö¸¸ 
    function cal_pre(ctl,ctlsize,len) {
        var tmpStr;
        tmpStr = ctl.value;
        cal_byte(ctl,ctlsize,len,tmpStr);
    }
    function cal_byte(ctl,ctlsize,len,aquery) {
        var tmpStr;
        var temp=0;
        var onechar;
        var tcount;
        tcount = 0;
        tmpStr = new String(aquery);
        temp = tmpStr.length;
        for(k=0;k<temp;k++) {
          onechar = tmpStr.charAt(k);
          if (escape(onechar) == '%0D') { } 
          else if (escape(onechar).length > 4) {
            tcount += 2;
          }
          else {
            tcount++;
          }
        }
        if(tcount > len*2) {
            alert("ÀÔ·ÂÇÑ ±ÛÀÚ¼ö°¡ " + len + "ÀÚ¸¦ ³ÑÀ» ¼ö ¾ø½À´Ï´Ù.");
            var str = ctl.value;
            ctl.value = "";
            cut_str(ctl,ctlsize,len,str);
        } else {
            if(tcount%2 == 0) ctlsize.value = len - parseInt(tcount/2);
        }
    }
    function cut_str(ctl,ctlsize,len,str) {
        var temp=0;
        var message_str = "";
        var onechar;
        var tcount;
        tcount = 0;
        temp = str.length;
        for(k=0;k<temp;k++) {
          onechar = str.charAt(k);
          if(tcount >= len*2) { break; }
          if (escape(onechar) == '%0D') { } 
          else if (escape(onechar).length > 4) {
            tcount += 2;
            if(tcount >= len*2) { tcount -= 2; break; }
            message_str += str.substr(k,1);
          } else {
            tcount++;
            if(tcount >= len*2) { tcount--; break; }
            message_str += str.substr(k,1);
          }
        }
        ctl.value = message_str;
        ctlsize.value = len - parseInt(tcount/2);
    }

    function ContentsDecode(str){
        str = str.replace(/&lt;/gi,"<");
        str = str.replace(/&gt;/gi,">");
        str = str.replace(/&amp;/gi,"&");
        return str;
    }

function setCookie(name, value, dd, domain) {
    var expdate = new Date();
    expdate.setTime(expdate.getTime() + 1000 * 3600 * 24 * dd);
    if(domain.length > 0) {
        document.cookie = name + "=" + escape (value) + "; path=/; expires=" + expdate.toGMTString() + "; domain=" + domain + ";";
    } else {
        document.cookie = name + "=" + escape (value);
//        document.cookie = sName + "=" + escape(sValue);
    }
}

function getCookie(Name) {
    var search = Name + "="
    if (document.cookie.length > 0) { // ÄíÅ°°¡ ¼³Á¤µÇ¾î ÀÖ´Ù¸é
        offset = document.cookie.indexOf(search)
        if (offset != -1) { 
            offset += search.length
            end = document.cookie.indexOf(";", offset)
            if (end == -1)
                end = document.cookie.length
            return unescape(document.cookie.substring(offset, end))
        }
    }
    return "";
}

    //Ä«Å»·Î±× º¸±â
    function catalog_view(id) {
        url = "http://catalog.housing24.com/default.asp?c_id=" + id;
        op = open(url,"","");
        op.focus();
    }

    function p_windowopen(pID, pPopSrc, pWidth, pHeight){
        var pTop, pLeft;
        pTop = posPopup.offsetTop + 20;
        pLeft = popLeft.offsetLeft + 10;

//        arrPopup[nPopup] = pID;
//        if ( nPopup != 0 ){
//            pTop = posPopup.offsetTop + (nPopup * 40);
//            pLeft = popLeft.offsetLeft + (nPopup * 200);
//        }
//        nPopup = nPopup + 1;
        
        strPopupScript = "<div id='" + pID + "' onclick='javascript:alert(\"d\")' style='border-width:0px;POSITION: absolute;TOP: " + pTop + "px; LEFT: " + pLeft + "px;z-index:199'>\
                <IFRAME src='" + pPopSrc + "' frameBorder=0 scrolling=no width=" + pWidth + " height=" + pHeight + "></IFRAME>\
                </div>";
        document.writeln(strPopupScript); 
    }

    function p_windowclose(pID, bSetCookie, strURL) {
        if (bSetCookie == "1"){    //´õÀÌ»ó¿­Áö¾Ê±â
            SetCookie(pID, "1");
        } else if(bSetCookie == "2"){ //ÇÏ·çµ¿¾È¿­Áö¾Ê±â
            SetCookie(pID, "2");
        }
        //document.all[pID].style.display = "none";
        if (strURL != "") document.location.href = strURL;
    }

    function SetCookie(sName, sValue) {
        if(sValue == "1") {
            document.cookie = sName + "=" + escape(sValue) + "; path=/;"
        } else {
            var todayDate = new Date();
            todayDate.setDate(todayDate.getDate() + 1);
            document.cookie = sName + "=" + escape(sValue) + "; path=/; expires=" + todayDate.toGMTString() + ";"
        }
    }
    function GetCookie(sName) {
      var aCookie = document.cookie.split("; ");
      for (var i=0; i < aCookie.length; i++) {
        var aCrumb = aCookie[i].split("=");
        if (sName == aCrumb[0]) {
            return unescape(aCrumb[1]);
        }
      }
      return null;
    }
    function collect_imgsize(img,limitw,limith) {
        var tmpw = 0;
        var tmph = 0;
        if(limitw > 0 && limith > 0) {
            var maxw = limitw;
            var maxh = limith;
        } else {
            var maxw = 100;
            var maxh = 70;
        }
        var viewimg = new Image;
        viewimg.src = img.src;
        var tmpw = viewimg.width;
        var tmph = viewimg.height;
        if ((tmpw > maxw) && (tmph <= maxh)) {
            tmph = (maxw / tmpw) * tmph;
            tmpw = maxw;
        } else if ((tmph > maxh) && (tmpw <= maxw)) {
            tmpw = (maxh / tmph) * tmpw;
            tmph = maxh;
        } else if ((tmph > maxh) && (tmpw > maxw)) {
            difWidth = tmpw / maxw;
            difHeight = tmph / maxh;
            if (difWidth > difHeight) {
                tmph = (maxw * tmph) / tmpw;
                tmpw = maxw;
            } else {
                tmpw = (maxh * tmpw) / tmph;
                tmph = maxh;
            }
        }
        if(tmpw != 0 && tmph != 0) {
            img.width = tmpw;
            img.height = tmph;
        }
    }

    function company_email_send(company_name, charge_email) {
        if(company_name.length > 0 && charge_email.length > 0) {
            open("/_src/sendmail.asp?coname=" + company_name + "&to_email=" + charge_email,"","width=650,height=473");
        }
    }

    /* 2006-03-20 Ãß°¡ */
    //ÇÃ·¡½Ã ¼Ò½º »ý¼º
    function make_flash(img,url,target,width,height,wmode,pop_w,pop_h){
        src = img;
        if(src.length > 0 && url.length > 0) src += "?click=" + url;
        if(src.length > 0 && target.length > 0) src += "&target=" + target;
        if(src.length > 0 && pop_w.length > 0) src += "&pop_w=" + pop_w;
        if(src.length > 0 && pop_h.length > 0) src += "&pop_h=" + pop_h;
        str = "";
        str = "<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='" + width + "' height='" + height + "'>";
        if(wmode.length > 0) {
            str += "<param name='wmode' value='" + wmode + "'>";
        }
        str += "<param name='movie' value='" + src + "'>";
        str += "<param name='quality' value='high'><param name='menu' value='false'>";
        str += "<embed src='" + src + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + width + "' height='" + height + "'></embed>";
        str += "</object>";
        return str;
        alert(str);
    }
    //embed ¼Ò½º »ý¼º
    function make_embed(src,width,height){
        str = "";
        str = "<EMBED id='vod' style='width:" + width + ";height:" + height + "' src='" + src + "' autostart='true'>";
        return str;
    }
    //vod ¼Ò½º »ý¼º
    function make_vod(src,width,height) {
        str = "";
        str = "<object id='mp1' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' type='application/x-oleobject' width='" + width + "' height='" + height + "'>";
        str += "  <param name='Filename'  value='" + src + "'>";
        str += "  <param name='AutoStart'            value='1'>";
        str += "  <param name='AutoSize'             value='1'>";
        str += "  <param name='AutoResize'           value='1'>";
        str += "  <param name='AnimationAtStart'     value='0'>";
        str += "  <param name='TransparentAtStart'   value='1'>";
        str += "  <param name='AutoRewind'           value='1'>";
        str += "  <param name='ShowDisplay'          value='0'>";
        str += "  <param name='ClickToPlay'          value='1'>";
        str += "  <param name='EnableContextMenu'    value='0'>";
        str += "  <param name='ShowPositionControls' value='0'>";
        str += "  <param name='ShowStatusBar'        value='1'>";
        str += "</object>";
        return str;
    }
    function object_write(src){
        document.write(src);
    }
