//------------------------------------------------------------------------------------
// ÃÊ±âÈ­
//------------------------------------------------------------------------------------

function InitSetUp() {
   
    this.IE = (window.attachEvent && !window.opera) ? true : false; //ie
    this.Opera = !!window.opera ? true : false; //¿ÀÆä¶ó
    this.WebKit = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? true : false; //Å©·Ò& »çÆÄ¸®
    this.Gecko = navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1 ? true : false; //ÆÄÆø
    this.MobileSafari = !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) ? true : false;

    this.IEVersion;
    if (this.IE) {             // ¸¶ÀÌÅ©·Î¼ÒÇÁÆ® ÀÍ½ºÇÃ·Î·¯ÀÎÁö È®ÀÎ
        if (navigator.appVersion.indexOf("MSIE 8") != -1) {         // ÀÍ½ºÇÃ·Î·¯ÀÌ¸é ¹öÀü 6ÀÎÁö È®ÀÎ
            this.IEVersion = "8";
        }
        else if (navigator.appVersion.indexOf("MSIE 7") != -1) {    // ÀÍ½º ÇÃ·Î·¯ÀÌ¸é ¹öÀü 7ÀÎÁö È®ÀÎ
            this.IEVersion = "7";
        }
        else if (navigator.appVersion.indexOf("MSIE 6") != -1) {    // ÀÍ½º ÇÃ·Î·¯ÀÌ¸é ¹öÀü 8ÀÎÁö È®ÀÎ
            this.IEVersion = "6";
        }
    }
}

var InitConfig=new InitSetUp();



//------------------------------------------------------------------------------------
// ´ÙÀ½Æ÷Ä¿½º
//------------------------------------------------------------------------------------
function NextFocus(id1,id2,e)
{
    if(e.keyCode==13)
    {
	    if(eval("document.getElementById('"+id1+"').value==''"))
	    {
		    eval("document.getElementById('"+id1+"').focus();");
		    return false;
	    }
	    else
	    {
		    eval("document.getElementById('"+id2+"').focus();");
		    return false;
	    }
    }
}





//------------------------------------------------------------------------------------
// ¹öÆ°Å¬¸¯
//------------------------------------------------------------------------------------		
function ClickButton(id1, id2, e) {
    if (e.keyCode == 13) {
        if (eval("document.getElementById('" + id1 + "').value==''")) {
            eval("document.getElementById('" + id1 + "').focus();");
            return false;
        }
        else {
            eval("document.getElementById('" + id2 + "').focus();");
            eval("document.getElementById('" + id2 + "').click();");
            return false;
        }
    }

}



//------------------------------------------------------------------------------------
// keyÄÚµå¾ò±â
//------------------------------------------------------------------------------------
function GetKeyCode(e) {
    var result = window.event ? window.event.keyCode : e.which;
    return result;
}

//------------------------------------------------------------------------------------
// ÀÌº¥Æ® °ü·Ã
//------------------------------------------------------------------------------------
function addEvent(elm, eventType, func) {
    if (elm.addEventListener) {
        elm.addEventListener(eventType, func, false);
        return true;
    } else if (elm.attachEvent) {
        var r = elm.attachEvent('on' + eventType, func);
        return r;
    } else {
        elm['on' + eventType] = func;
    }
};


function removeEvent(elm, eventType, func, useCapture) {
    if (elm.removeEventListener) {
        elm.removeEventListener(eventType, func, useCapture);
        return true;
    } else if (elm.detachEvent) {
        var r = elm.detachEvent('on' + eventType, func);
        return r;
    } else {
        elm['on' + eventType] = null;
    }
};


//------------------------------------------------------------------------------------
//ÇÃ·¹½¬¸¦ ·ÎµåÇØ¼­ È¸»ö Å×µÎ¸®¸¦ ¾ø¾Ö±âÀ§ÇÔÀÌ´Ù. 
// Áö´ë·ÎÇÏ±â À§¿¡´Â ¾à½Ä.
// s=¼Ò½º // i:¾ÆÀÌµð //w:³ÐÀÌ //h:³ôÀÌ //t:Åõ¸íµµ,ÀÚ¸®¹èÄ¡)
//------------------------------------------------------------------------------------
function openflash(s, i, w, h, t) {
    var str;
    if (window.navigator.appName == "Microsoft Internet Explorer") {

        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=" + w + " height=" + h + " id='" + i + "'>" +
    "<param name='movie' value='" + s + "'>" +
    "<param name='quality' value='high'>" +
    "<param name='menu' value='false'>" +
    "<param name='wmode' value='" + t + "'>" +
    "<embed src='" + s + "' quality=high pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width=" + w + " height=" + h + "></embed>" +
    "</object>";
    }
    else {
        str = "<embed src='" + s + "' width='" + w + "' height='" + h + "' wmode='" + t + "' id='" + i + "' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' >";
    }


    document.write(str);


}


function openflash(s, i, w, h, t) {
    var str;
    if (window.navigator.appName == "Microsoft Internet Explorer") {

        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=" + w + " height=" + h + " id='" + i + "'>" +
    "<param name='movie' value='" + s + "'>" +
    "<param name='quality' value='high'>" +
    "<param name='menu' value='false'>" +
    "<param name='wmode' value='" + t + "'>" +
    "<embed src='" + s + "' quality=high pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width=" + w + " height=" + h + "></embed>" +
    "</object>";
    }
    else {
        str = "<embed src='" + s + "' width='" + w + "' height='" + h + "' wmode='" + t + "' id='" + i + "' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' >";
    }


    document.write(str);


}

function open_flash2(url, width, height) {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="' + width + '" height="' + height + '" VIEWASTEXT>');
    document.write('<param name="allowScriptAccess" value="always" />');
    document.write('<param name="movie" value="' + url + '">');
    document.write('<param name="quality" value="high">');
    document.write('<param name="wmode" value="transparent">');
    document.write('<param name="menu" value="false" />');
    document.write('<param name="scale" value="noscale" />');
    document.write('<param name="FlashVars" value="hid=' + domain + '"/>');
    document.write('<embed src="' + url + '" flashvars="hid=' + domain + '" allowScriptAccess="sameDomain" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent"></embed>');
    document.write('</object>');
}


function openflash3(s, i, w, h, t) {
    var str;
    if (window.navigator.appName == "Microsoft Internet Explorer") {

        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=" + w + " height=" + h + " id='" + i + "'>" +
    "<param name='movie' value='" + s + "'>" +
    "<param name='quality' value='high'>" +
    "<param name='menu' value='false'>" +
    "<param name='wmode' value='" + t + "'>" +
    "<param name='allowFullScreen' value='true'>"+
    "<embed src='" + s + "' quality=high pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width=" + w + " height=" + h + "></embed>" +
    "</object>";
    }
    else {
        str = "<embed src='" + s + "' width='" + w + "' height='" + h + "' wmode='" + t + "' id='" + i + "' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' >";
        
    }


    document.write(str);


}

function render_flash(url, width, height) {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="' + width + '" height="' + height + '" VIEWASTEXT>');
    document.write('<param name="allowScriptAccess" value="always" />');
    document.write('<param name="movie" value="' + url + '">');
    document.write('<param name="quality" value="high">');
    document.write('<param name="wmode" value="transparent">');
    document.write('<param name="menu" value="false" />');
    document.write('<param name="scale" value="noscale" />');

    document.write('<embed src="' + url + '" allowScriptAccess="sameDomain" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent"></embed>');
    document.write('</object>');
}

//------------------------------------------------------------------------------------
// ¼¼·ÎÁ¤·Ä div
//------------------------------------------------------------------------------------
function vAlign() {

    objs = document.getElementsByTagName('DIV');
    for (var i = 0; i < objs.length; i++) {
        if (objs[i].className == "vAlign")
            objs[i].style.marginTop = Math.floor(parseInt(objs[i].parentNode.offsetHeight - objs[i].offsetHeight) / 2) + "px";
    }
}


//------------------------------------------------------------------------------------
// valid
//------------------------------------------------------------------------------------
// ½ºÅ©¸³Æ®»èÁ¦
function removeScript(str) {
    var pattern = /\r\n/g
    var returnStr = str.replace(pattern, "@!-_-!@");

    pattern = /<\s*script.+?<\/\s*script\s*>/gi
    returnStr = returnStr.replace(pattern, "");

    pattern = /@!-_-!@/g
    returnStr = returnStr.replace(pattern, "\r\n");

    pattern = /^\r\n/g
    returnStr = returnStr.replace(pattern, "");

    return returnStr;
}

//ÅÂ±×»èÁ¦
function removeTag(str) {
    var pattern = /<[^>]*>/gi
    var returnStr = str.replace(pattern, "");
    return returnStr;
}

//ÆÐÅÏ
function removePattern(str, pattern) {
    var returnStr = str.replace(pattern, "");
    return returnStr;
}


// xml ¹®À» À§ÇÑ <,> »èÁ¦
function removeForXml(str) {
    var pattern = /<|>/gi
    var returnStr = str.replace(pattern, "");
    return returnStr;
}


//ÆÐÅÏÃ¼Å©
function checkPattern(str, pattern) {
    var bExist = false;
    bExist = pattern.test(str);
    return bExist;
}

//ÆÐÅÏÃ¼Å©
function checkNumber(str, pattern) {
    var bExist = false;
    pattern = /[0-9]/gi
    str = str.replace(pattern, "");
    if (str.length == 0) {
        bExist = true;
    }

    return bExist;
}

//ÀüÈ­Ã¼Å©
function checkPhone(n1, n2, n3) {
    var bExist = false;
    var str = n1 + "-" + n2 + "-" + n3;
    var pattern = /(02|051|053|032|062|042|052|031|033|043|041|054|055|063|061|064|070)-(\d{3,4})-(\d{4})/i;
    bExist = pattern.test(str);

    return bExist;
}

//ÇÚµåÆùÃ¼Å©
function checkMobile(n1, n2, n3) {
    var bExist = false;
    var str = n1 + "-" + n2 + "-" + n3;
    var pattern = /(010|011|016|017|018|019)-(\d{3,4})-(\d{4})/i;
    bExist = pattern.test(str);

    return bExist;
}

//ÀÌ¸ÞÀÏÃ¼Å©
function checkEmail(e1, e2) {
    var bExist = false;
    var str = e1 + "@" + e2;
    var pattern = /[a-z0-9]{2,}@[a-z0-9-]{2,}\.[a-z0-9]{2,}/i;
    bExist = pattern.test(str)
    return bExist;
}

//ÀÌ¸ÞÀÏÃ¼Å©2
function checkEmail2(email) {
    var bExist = false;
    var str = email;
    var pattern = /[a-z0-9]{2,}@[a-z0-9-]{2,}\.[a-z0-9]{2,}/i;
    bExist = pattern.test(str)
    return bExist;
}

//³âµµÃ¼Å©
function checkDay(day)
{
    var bExist = false;
    var str = day;
    var pattern = /(\d{1,4})-(\d{1,2})-(\d{1,2})/i;
    bExist = pattern.test(str)
    return bExist;
}

//¾ÆÀÌµðÃ¼Å©
function checkID(str) {
    var bExist = false;
    var pattern = /[a-z0-9]{4,10}/i;
    bExist = pattern.test(str);
    return bExist;
}

//ÇÑ±ÛÀÌ¸§Ã¼Å©
function checkName(str) {

    var bExist = false;

    pattern = /[¤¡-¤¾¤¿-¤Ó°¡-Èþ]/gi
    str = str.replace(pattern, "");
    if (str.length == 0) {
        bExist = true;
    }

    return bExist;

}

//ÁÖ¹Î¹øÈ£Ã¼Å©
function checkSerial(n1, n2) {

    var bExist = false;



    var jumin1 = n1;
    var jumin2 = n2;

    var total = 0;
    var temp = new Array(13);

    for (i = 1; i <= 6; i++) {
        temp[i] = jumin1.charAt(i - 1);
    }

    for (i = 7; i <= 13; i++) {
        temp[i] = jumin2.charAt(i - 7);
    }

    for (i = 1; i <= 12; i++) {
        k = i + 1;

        if (k >= 10)
            k = k % 10 + 2;

        total = total + temp[i] * k;
    }

    var mm = temp[3] + temp[4];
    var dd = temp[5] + temp[6];

    var totalmod = total % 11;
    var chd = 11 - totalmod;

    if (chd == 11) {
        chd = 1;
    }
    else if (chd == 10) {
        chd = 0;
    }

    if (chd == temp[13] && mm < 13 && dd < 32 && (temp[7] == 1 || temp[7] == 2 || temp[7] == 3 || temp[7] == 4)) {
        bExist = true;

    }
    else {
        bExist = false;
    }



    return bExist;

}


//------------------------------------------------------------------------------------
// send 
//------------------------------------------------------------------------------------

var objPopup = null;

//°¡ÀÚ.. °Ô½Ã¹°º¸±â·Î.. °Ë»öÀÌ´Ù.
function gourl_searchbyid(url, select_id) {

    document.location.href = url + "&txt=" + select_id;

}


function gourl_sendmemo(url, select_id) {
    var w = 530;
    var h = 520;
    var leftPos = (parseInt(window.screen.width) - w) / 2;
    var topPos = (parseInt(window.screen.height) - h) / 2;
    if (objPopup != null) objPopup.close();
    objPopup = window.open(url + "?toid=" + select_id, "child", "scrollbars=0,toolbar=0,menubar=0,status=0,location=0, resizable=0,top=" + topPos + ", left=" + leftPos + ",  width=" + w + " , height=" + h);
}

function gourl_sendemail(url, select_id) {
    var w = 530;
    var h = 520;
    var leftPos = (parseInt(window.screen.width) - w) / 2;
    var topPos = (parseInt(window.screen.height) - h) / 2;
    if (objPopup != null) objPopup.close();
    objPopup = window.open(url + "?toid=" + select_id, "child", "scrollbars=0,toolbar=0,menubar=0,status=0,location=0, resizable=0,top=" + topPos + ", left=" + leftPos + ", width=" + w + " , height=" + h);
}



function gourl_addfriend(url) {
    var w = 530;
    var h = 520;
    var leftPos = (parseInt(window.screen.width) - w) / 2;
    var topPos = (parseInt(window.screen.height) - h) / 2;
    if (objPopup != null) objPopup.close();
    objPopup = window.open(url + "?toid=" + select_id, "child", "scrollbars=0,toolbar=0,menubar=0,status=0,location=0, resizable=0,top=" + topPos + ", left=" + leftPos + ", width=" + w + " , height=" + h);

}


function closePopup() {
    if (objPopup != null) {
        objPopup.close();
    }
}


function closePopupSend(str) {
    if (objPopup != null) {
        objPopup.close();alert(str);
    }
}


//------------------------------------------------------------------------------------------------------------------------------------------------------------
//´ÜÃàÅ°¼¼ÆÃ
//------------------------------------------------------------------------------------------------------------------------------------------------------------
var arrKey = new Array();
arrKey['1'] = "index.htm";
arrKey['2'] = "index.htm";
arrKey['3'] = "index.htm";
arrKey['4'] = "index.htm";
arrKey['5'] = "index.htm";
arrKey['/'] = "http://www.google.com";

function getKey(keyStroke) {
    var keyevent;
    var eventChooser;
    var keycode;
    

    if (window.showModelessDialog) {
        keyevent = window.event.srcElement;
        eventChooser = window.event.keyCode;
        
    } else {
        keyevent = keyStroke.target;
        eventChooser = keyStroke.which
    }
    if ((keyevent.tagName != 'INPUT') && (keyevent.tagName != 'TEXTAREA') && (keyevent.tagName != 'SELECT') && (keyevent.tagName != 'select') && (keyevent.tagName != 'FILE')) {
        keycode = String.fromCharCode(eventChooser).toLowerCase();
        for (var i in arrKey) {
            if (keycode == i) window.location = arrKey[i];
        }
        if (keycode == ',') history.go(-1);
        if (keycode == '.') history.go(1);
        if (eventChooser == 13) return false; 
    }
}


//À¥»çÀÌÆ® ¼¼ÆÃ

function config()
{
    this.keystroke=true;
}

var config =new config();

if (config.keystroke) {
    addEvent(document, "keypress", getKey);
}


/*
//------------------------------------------------------------------------------------------------------------------------------------------------------------
//´ÜÃàÅ°¼¼ÆÃ
//------------------------------------------------------------------------------------------------------------------------------------------------------------
// ÇØ´ç ´Ü¾î¿¡ ´ëÇÑ Á¶»ç¸¦ ±¸ÇØ¿Â´Ù 
// type = 1 : (À»/¸¦), 2: (Àº/´Â), 3: (ÀÌ/°¡)
function getAux(val, type) {
    hanTable = new Array();
    hanTable[0] = '¤¡¤¢¤¤¤§¤¨¤©¤±¤²¤³¤µ¤¶¤·¤¸¤¹¤º¤»¤¼¤½¤¾'; // 19 ÃÊ¼º
    hanTable[1] = '¤¿¤À¤Á¤Â¤Ã¤Ä¤Å¤Æ¤Ç¤È¤É¤Ê¤Ë¤Ì¤Í¤Î¤Ï¤Ð¤Ñ¤Ò¤Ó'; //21 Áß¼º
    hanTable[2] = ' ¤¡¤¢¤£¤¤¤¥¤¦¤§¤©¤ª¤«¤¬¤­¤®¤¯¤°¤±¤²¤´¤µ¤¶¤·¤¸¤º¤»¤¼¤½¤¾'; //28 Á¾¼º

    b = val.charCodeAt(val.length - 1);
    hcode = b - 0xAC00;
    cho = new Array();
    cho[0] = parseInt(hcode / 588); //ÃÊ¼º
    hcode2 = hcode % 588;
    cho[1] = parseInt(hcode2 / 28); //Áß¼º
    cho[2] = hcode2 % 28; //Á¾¼º ¤¡,,,¤¤ 

    mun = new Array();
    mun[0] = hanTable[0].charAt(cho[0]);
    mun[1] = hanTable[1].charAt(cho[1]); //ÀÚÀ½
    mun[2] = hanTable[2].charAt(cho[2]); //0¹øÀº Á¾¼ºÀ¯¹«

    var aux = "À»¸¦Àº´ÂÀÌ°¡"
    return (mun[2].trim() != "") ? aux.charAt((type * 2) - 2) : aux.charAt((type * 2) - 1);
}
*/


function setPng24(obj) {
    obj.width = obj.height = 1;
    obj.className = obj.className.replace(/\bpng24\b/i, '');
    obj.style.filter =
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + obj.src + "',sizingMethod='image');"
    obj.src = '';
    return '';
}



function mouseClickRight() {

    if ((event.button == 2) || (event.button == 3)) {

        document.body.oncontextmenu = function() { return false; };
        document.body.ondragstart = function() { return false; };
        document.body.onselectstart = function() { return false; };
        return;
    }
}


function bluring() {
    if (event.srcElement.tagName == "A" || event.srcElement.tagName == "IMG") document.body.focus();
}
document.onfocusin = bluring;    
