// ÆÄÀÏ »çÀÌÁî ±¸ÇÏ±â
function get_filesize(filepath) {
    var len = 0;
    
    if(navigator.appName.indexOf("Netscape") != -1) {
        try {
            netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
        } catch(e) {
            return -1;
        }
        try {
            var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
            file.initWithPath(filepath);
            
            len = file.fileSize;
        } catch(e) {
            return -1;
        }
    } else if (navigator.appName.indexOf('Microsoft') != -1) {
        try {
            var img = new Image();
            img.dynsrc = filepath;
            len = img.fileSize;
        } catch(e) {
            return -1;
        }
    }
    return len;
}

/* Æ¯¼ö¹®ÀÚ ¾Õ¿¡ \ Ãß°¡ */
function addslashes(str) {
    return (str+'').replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0');
}

/* Æ¯¼ö¹®ÀÚ¾ÕÀÇ \ Á¦°Å */
function stripslashes(str) {
    return (str+'').replace(/\\(.?)/g, function (s, n1) {
        switch (n1) {
            case '\\':
                return '\\';
            case '0':
                return '\u0000';
            case '':
                return '';
            default:
                return n1;
        }
    });
}

function AlertSuccess() {
    alert("Á¤»óÀûÀ¸·Î Ã³¸®µÇ¾ú½À´Ï´Ù.");
}

function AlertError() {
    alert("¿À·ù°¡ ¹ß»ýµÇ¾ú½À´Ï´Ù.");
}

function chkBusiness(vencod) {
    var sum = 0;
    var getlist = new Array(10);
    var chkvalue = new Array("1", "3", "7", "1", "3", "7", "1", "3", "5");
    
    for(var i=0; i<10; i++){
        getlist[i] = vencod.substring(i,i+1);
    }
    
    for(var i=0; i<9; i++){
        sum += getlist[i] * chkvalue[i];
    }
    sum = sum + parseInt((getlist[8] * 5) / 10);
    var sidliy = sum % 10;
    var sidchk = 0;
    
    if(sidliy != 0) {
        sidchk = 10 - sidliy;
    } else {
        sidchk = 0;
    }
    if(sidchk != getlist[9]) return true;
    return false;
}

// ÄÞ¸¶ ¾ø¾Ö±â
function removeComma(n){
    n = n.toString();
    return n.replace(/,|\s/g,'');
}

// ÄÞ¸¶ Âï±â
function setComma(n){
    var temp = n.toString();
    n = n.toString();
    n = parseFloat(n.replace(/,|\s/g,''));
    if(isNaN(n)) {
        return temp;
    } else if(n == 0) {
        return n;
    } else {
        var reg = /(^[-]?\d+)(\d{3})/;
        n += '';
        while(reg.test(n)) n = n.replace(reg, '$1'+','+'$2');
        return n;
    }
}

// ¹®ÀÚ¸¦ ³¯Â¥ÇüÅÂ·Î
function str2date(n) {
    return n.substr(0,4)+"."+n.substr(4,2)+"."+n.substr(6,2);
}

// À©µµ¿ì Ã¢´Ý±â
function fnWindowClose() {
    if (/MSIE/.test(navigator.userAgent)) { 
        if(navigator.appVersion.indexOf("MSIE 7.0")>=0 || navigator.appVersion.indexOf("MSIE 8.0")>=0) {
            window.open('about:blank','_self').close();
        } else { 
            window.opener = self; 
            self.close(); 
        }                       
    } else {
        window.opener = self; 
        self.close(); 
    }
}

// OBJECT Ãâ·Â
function FlashShow(url, width, height) { 
    document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' "); 
    document.write("codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' "); 
    document.write("width='" + width + "' height='" + height + "'>"); 
    document.write(" <param name='movie' value='" + url + "'>"); 
    document.write(" <param name='quality' value='high'>"); 
    document.write(" <param name='wmode' value='transparent'>"); 
    document.write(" <embed src='" + url + "' quality='high' "); 
    document.write(" pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' "); 
    document.write(" type='application/x-shockwave-flash' "); 
    document.write(" width='" + width + "' height='" + height + "'>"); 
    document.write(" </embed>"); 
    document.write("</object>"); 
}

function fnSleep(msec) {
    var start = new Date().getTime();
    var current = start;
    if(current-start < msec) current = new Date().getTime();
}

// ÀÌ¹ÌÁö º¸±â
function fnImageView(path) {
    var imgwin = window.open("",'ImageView','scrollbars=yes,status=yes,toolbar=no,resizable=no,location=no,menu=no,width=10,height=10');
    imgwin.focus();
    imgwin.document.open();
    imgwin.document.write("<html><head><title>ÀÌ¹ÌÁö º¸±â</title>\n"); 
    imgwin.document.write("<sc"+"ript language='javascript'>\n");
    imgwin.document.write("function resize() {\n");
    imgwin.document.write("pic = document.image;\n");
    imgwin.document.write("if(eval(pic).height) {\n");
    imgwin.document.write("var name = navigator.appName;\n");
    imgwin.document.write("if(name == 'Microsoft Internet Explorer') {\n");
    imgwin.document.write("myHeight = eval(pic).height+50;\n");
    imgwin.document.write("myWidth = eval(pic).width+10;\n");
    imgwin.document.write("} else {\n");
    imgwin.document.write("myHeight = eval(pic).height+50;\n");
    imgwin.document.write("myWidth = eval(pic).width;\n");
    imgwin.document.write("}\n");
    imgwin.document.write("var heightPic = pic.height;\n");
    imgwin.document.write("var widthPic = pic.width;\n");
    imgwin.document.write("if(widthPic <= 1024 && heightPic <= 768){\n");
    imgwin.document.write("self.resizeTo(myWidth, myHeight+20);\n");
    imgwin.document.write("self.moveTo(80,80);\n");
    imgwin.document.write("document.body.style.overflow='hidden';\n");
    imgwin.document.write("} else {\n");
    imgwin.document.write("if(widthPic > 1024 && heightPic <= 768) {\n");
    imgwin.document.write("self.resizeTo(1024, myHeight+20);\n");
    imgwin.document.write("self.moveTo(80,80);\n");
    imgwin.document.write("} else if(widthPic <= 1024 && heightPic > 768) {\n");
    imgwin.document.write("self.resizeTo(myWidth+20, 768);\n");
    imgwin.document.write("self.moveTo(80,80);\n");
    imgwin.document.write("} else {\n");
    imgwin.document.write("self.resizeTo(1024, 768);\n");
    imgwin.document.write("self.moveTo(80,80);\n");
    imgwin.document.write("}\n");
    imgwin.document.write("}\n");
    imgwin.document.write("} else setTimeOut(resize(), 100);\n");
    imgwin.document.write("}\n");
    imgwin.document.write("</sc"+"ript>\n");
    imgwin.document.write("</head>\n");
    imgwin.document.write("<body bgcolor='#FFFFFF' style='margin:0'>\n");
    imgwin.document.write("<div align='center' valign='middle'><a href='javascript:self.close()' onfocus='this.blur()'><img border='0' src='"+path+"' xwidth='10' xheight='9' name='image' onload='resize();'></a></div>\n");
    imgwin.document.write("</body>\n");
    imgwin.document.write("</html>\n");
    imgwin.document.close();
}

// ÆË¾÷ º¸±â
function fnPopupView(path) {
    var popupwin = window.open("",'PopupView','scrollbars=yes,status=yes,toolbar=no,resizable=no,location=no,menu=no,width=10,height=10');
    popupwin.focus();
    popupwin.document.open();
    popupwin.document.write("<html><head><title>ÆË¾÷</title>\n"); 
    popupwin.document.write("<sc"+"ript src='/js/jquery.min.js' type='text/javascript'></sc"+"ript>\n");
    popupwin.document.write("<sc"+"ript language='javascript'>\n");
    popupwin.document.write("function fnClose() {\n");
    popupwin.document.write("$.ajax({\n"); 
    popupwin.document.write("type : 'POST',\n"); 
    popupwin.document.write("url: '/info/popup.php',\n"); 
    popupwin.document.write("data: {'type': 'update'},\n"); 
    popupwin.document.write("dataType: 'json',\n"); 
    popupwin.document.write("success: function(data) {\n"); 
    popupwin.document.write("var response = data.response;\n"); 
    popupwin.document.write("if(response == 'success') {\n"); 
    popupwin.document.write("self.close();\n"); 
    popupwin.document.write("}\n"); 
    popupwin.document.write("}\n"); 
    popupwin.document.write("});\n"); 
    popupwin.document.write("}\n");
    popupwin.document.write("</sc"+"ript>\n");
    popupwin.document.write("<sc"+"ript language='javascript'>\n");
    popupwin.document.write("function resize() {\n");
    popupwin.document.write("pic = document.image;\n");
    popupwin.document.write("if(eval(pic).height) {\n");
    popupwin.document.write("var name = navigator.appName;\n");
    popupwin.document.write("if(name == 'Microsoft Internet Explorer') {\n");
    popupwin.document.write("myHeight = eval(pic).height+70;\n");
    popupwin.document.write("myWidth = eval(pic).width+10;\n");
    popupwin.document.write("} else {\n");
    popupwin.document.write("myHeight = eval(pic).height+70;\n");
    popupwin.document.write("myWidth = eval(pic).width;\n");
    popupwin.document.write("}\n");
    popupwin.document.write("var heightPic = pic.height;\n");
    popupwin.document.write("var widthPic = pic.width;\n");
    popupwin.document.write("if(widthPic <= 1024 && heightPic <= 768){\n");
    popupwin.document.write("self.resizeTo(myWidth, myHeight+20);\n");
    popupwin.document.write("self.moveTo(80,80);\n");
    popupwin.document.write("document.body.style.overflow='hidden';\n");
    popupwin.document.write("} else {\n");
    popupwin.document.write("if(widthPic > 1024 && heightPic <= 768) {\n");
    popupwin.document.write("self.resizeTo(1024, myHeight+20);\n");
    popupwin.document.write("self.moveTo(80,80);\n");
    popupwin.document.write("} else if(widthPic <= 1024 && heightPic > 768) {\n");
    popupwin.document.write("self.resizeTo(myWidth+20, 768);\n");
    popupwin.document.write("self.moveTo(80,80);\n");
    popupwin.document.write("} else {\n");
    popupwin.document.write("self.resizeTo(1024, 768);\n");
    popupwin.document.write("self.moveTo(80,80);\n");
    popupwin.document.write("}\n");
    popupwin.document.write("}\n");
    popupwin.document.write("} else setTimeOut(resize(), 100);\n");
    popupwin.document.write("}\n");
    popupwin.document.write("</sc"+"ript>\n");
    popupwin.document.write("</head>\n");
    popupwin.document.write("<body bgcolor='#FFFFFF' style='margin:0'>\n");
    popupwin.document.write("<div align='center' valign='middle'><img border='0' src='"+path+"' xwidth='10' xheight='9' name='image' onload='resize();'></div>\n");
    popupwin.document.write("<table><tr><td height='20px' style='font-size:12px; cursor:pointer' onclick='javascript:fnClose();'>ÀÌÃ¢À» ¿­Áö ¾ÊÀ½</td></tr></table>\n");
    popupwin.document.write("</body>\n");
    popupwin.document.write("</html>\n");
    popupwin.document.close();
}

function addFavorite(obj, title) { 
    if($.browser.mozilla) { // Mozilla Firefox
        window.sidebar.addPanel(title, obj, ''); 
    } else if($.browser.msie) { // IE
        window.external.AddFavorite(obj, title); 
    } else if($.browser.safari) { // Safari
        return true;
    } else { 
        alert('Ctrl+D (Safari, Chrome) or Ctrl+B (Konqueror)'); 
    } 
    return false; 
}
