
String.prototype.trim = function(){
  return this.replace(/(^\s*)|(\s*$)/gi, "");
}

String.prototype.replaceAll = function(str1, str2){
  var temp_str = this.trim();
  temp_str = temp_str.replace(eval("/" + str1 + "/gi"), str2);
  return temp_str;
}


function checkNull(input) {
    if (input.value == null || input.value.replace(/ /gi,"") == "") {
        return true;
    }
    return false;
}

function checkString(input,chars) {
    var result = true ; 
    for (var inx = 0; inx < input.value.length; inx++) {
       if (chars.indexOf(input.value.charAt(inx)) == -1){
            result = false ;
            break ;
       }     
    }
    return result ;
}
function containsChars(input,chars) {
    for (var inx = 0; inx < input.value.length; inx++) {
       if (chars.indexOf(input.value.charAt(inx)) != -1)
           return true;
    }
    return false;
}
function checkAlphabet(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
    return checkString(input,chars);
}
function checkUpperCase(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    return checkString(input,chars);
}
function checkLowerCase(input) {
    var chars = "abcdefghijklmnopqrstuvwxyz";
    return checkString(input,chars);
}
function checkNumber(input) {
    var chars = "0123456789";
    return checkString(input,chars);
}
function checkAlphaNum(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    return checkString(input,chars);
}
function checkNumDash(input) {
    var chars = "0123456789-";
    return checkString(input,chars);
}
function checkNumComma(input) {
    var chars = "0123456789,";
    return checkString(input,chars);
}
function checkNumDot(input) {
    var chars = "0123456789.";
    return checkString(input,chars);
}

function removeComma(input) {
    return input.value.replace(/,/gi,"");
}

function removeBlank(input) {
    return input.value.replace(/ /gi,"");
}

function removeDash(input) {
    return input.replace(/-/gi,"");
}

function compareNumber(input1,input2) {
    return parseInt(removeComma(input1),10) < parseInt(removeComma(input2),10);
}

function checkFormat(input,format) {
    if (input.value.search(format) == -1) {
        return true;
    }
    return false;
}

function onlyAlpha(input) {
    var k = input.value
    for(i=0; i<k.length; i++) {
        if(k.charAt(i) >= 'A' && k.charAt(i) <= 'Z' || k.charAt(i) >= 'a' && k.charAt(i) <= 'z' ||  k.charAt(i) == ' ') {

        } else {
            return false;
        }
     }
     return true;
}


function checkRadio(radio) {
    var isNotChecked = true;
    if (radio.length > 1) {
        for (var inx = 0; isNotChecked && inx < radio.length; inx++) {
            if (radio[inx].checked) isNotChecked = false;
        }
    } else {
        if (radio.checked) isNotChecked = false;
    }
    return isNotChecked;
}

 function clearRadio(radio) {

    if (typeof(radio) == "undefined") return;

    if (radio.length > 1) {
        for (var inx = 0;  inx < radio.length; inx++) {
            radio[inx].checked  = false;
        }
    } else {
        radio.checked = false;
    }
}

function checkRadioToValue(radio, inVal) {
    if (typeof(radio) == "undefined") return;

    if (typeof(radio.length) != "undefined") {
        for (var inx = 0; inx < radio.length; inx++) {
            if (radio[inx].value == inVal) radio[inx].checked = true;
        }
    } else {
         radio.checked = true;
    }
}

function checkRadioValue(radio) {

    if(typeof(radio) == 'undefined') return "";

    if (radio.length > 1) {
        for (var inx = 0; inx < radio.length; inx++) {
            if (radio[inx].checked) {
                 return radio[inx].value;
            }
        }
    } else {
        return radio.value;
    }
    return
}

function getSelRdoIndex(radio) {

    if(typeof(radio) == 'undefined') return "";

    if (radio.length > 1) {
        for (var inx = 0; inx < radio.length; inx++) {
            if (radio[inx].checked) {
                 return inx ;
            }
        }
    } else {
        return -1 ;
    }
    return
}

function checkCheckBox(box) {
    return checkRadio(box);
}

function getLength(input) {
    return input.value.length;
}

function getByteLength(input) {
    var byteLength = 0;
    for (var inx = 0; inx < input.value.length; inx++) {
        var oneChar = escape(input.value.charAt(inx));
        if ( oneChar.length == 1 ) {
            byteLength ++;
        } else if (oneChar.indexOf("%u") != -1) {
            byteLength += 2;
        } else if (oneChar.indexOf("%") != -1) {
            byteLength += oneChar.length/3;
        }
    }
    return byteLength;
}



function checkShorterByteLength(input,length) {
    return (getByteLength(input) <= length ? false : true)
}

function getJMFormat(strParam,iPosn) {

    if (strParam.length == 13 ) {
        if (iPosn == 1)
            return strParam.substring(0,6);
        else if (iPosn == 2)
            return strParam.substring(6,13);
        else if (iPosn == 0)
            return strParam.substring(0,6) +  "-" + strParam.substring(6,13);

    } else {
        return "";
    }

}


function getDTFormat(strParam, iPosn) {

        if (strParam == "")  return "";

        if (strParam.length == 4) {
            return strParam;
        } else if (strParam.length == 8) {
        if (iPosn == 1)
            return strParam.substring(0,4);
        else if (iPosn == 2)
            return strParam.substring(4,6);
        else if (iPosn == 3)
            return strParam.substring(strParam.length,strParam.length-2);
        else if (iPosn == 0)
            return strParam.substring(0,4) + "-" + strParam.substring(4,6) + "-" + strParam.substring(strParam.length,strParam.length-2);
    } else if (strParam.length == 6) {
        if (iPosn == 1)
            return strParam.substring(0,4);
        else if (iPosn == 2)
            return strParam.substring(strParam.length,strParam.length-2);
        else if (iPosn == 0)
            return strParam.substring(0,4) + "-" + strParam.substring(strParam.length,strParam.length-2);
          else if (iPosn == 3)
                return "";
        }

}

function myRound(num, pos) {
    var posV = Math.pow(10, (pos ? pos : 2))
    return Math.round(num*posV)/posV
}


function padding(what, digit) {
       var xx = what.indexOf('.')

    var dif = what.length - xx;
    var ii = 0 ;
    var padstr = what ;
    var pad = "0"
    for (ii = 0 ; ii < dif ; ii++) {
        padstr += pad
    }

       return padstr
}

function round(what, places, iplaces) {

    return roundit(what, places, iplaces, "0");

}

function getTokenComma(val,patt ) {
    var i = 0, iFst=0;
    var sCheckValue=val;
    var arrRst = new Array();
    while((iFst = sCheckValue.indexOf(patt)) >= 0) {
        if((sCheckValue.length > 0)) arrRst[i++] = sCheckValue.substring(0,iFst);
        sCheckValue = sCheckValue.substring(iFst+1, sCheckValue.length);
    }
    arrRst[i] = sCheckValue;
    return arrRst;
}


function checkYear(input) {

    if(!checkNumber(input)){
        if (!checkNull(input)) {

           var format = /^(1900|1901|1902|1903|1904|1905|1906|1907|1908|1909|1910|1911|1912|1913|1914|1915|1916|1917|1918|1919|1920|1921|1922|1923|1924|1925|1926|1927|1928|1929|1930|1931|1932|1933|1934|1935|1936|1937|1938|1939|1940|1941|1942|1943|1944|1945|1946|1947|1948|1949|1950|1951|1952|1953|1954|1955|1956|1957|1958|1959|1960|1961|1962|1963|1964|1965|1966|1967|1968|1969|1970|1971|1972|1973|1974|1975|1976|1977|1978|1979|1980|1981|1982|1983|1984|1985|1986|1987|1988|1989|1990|1991|1992|1993|1994|1995|1996|1997|1998|1999|2000|2001|2002|2003|2004|2005|2006|2007)$/;
           if (checkFormat(input, format)) {
                input.value="";
                input.focus();
                input.select();
                return;
           }
       }
    }else{
        input.value = '';
        input.focus();
        input.select();
        return false;
    }
}




function hangul(){
    if((event.keyCode < 12592) || (event.keyCode > 12687)){
        event.returnValue = false;
    }
}

//- 
function disabledFocus(inVal){
 if(typeof(inVal) == 'object'){
  for(var i =0 ; i < inVal.length ; i++){
   if(inVal[i].disabled == false){
    inVal[i].focus();
    return;
   }
  }
 }
}



function getSelComboVal(obj) 
{
    var length = obj.length ;
    alert(length) ;
    if (length > 0 )
    {
        for (var i = 0 ; i < length ; i ++ )
        {
            if (obj[i].selected == true)
            {
                return obj[i].value ;
                break;
            }
        }
    }
}



function chkInput2(input , type , msg) {
    var validate = false ; 
    var typeStr ; 
    if ( type == "numeric" ) {
        validate = checkNumber(input) ;
        typeStr = "¼ýÀÚ" ;
    } else if ( type == "engno" ) {    
        validate = checkAlphaNum(input) ;
        typeStr = "¼ýÀÚ¿Í ¿µ¹®" ;
    }
    if (!validate) {
        alert (msg) ; 
        input.value="" ;
        input.focus() ;
    }
    return validate ; 
}

function checkLength(obj , allowedLen) {
    if ( obj.value.length < allowedLen) {
        return false ;
    } else {
        return true ; 
    }
}

function PageGo(uri, strTyp , cmd ){
    var frm = document.MnuForm;
    frm.cmd.value = cmd ; 
    frm.action = uri + ".run";
    frm.typ.value = strTyp;
    frm.submit();
}

function check_busino(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);
    sidliy = sum % 10;
    sidchk = 0;
    if(sidliy != 0) { sidchk = 10 - sidliy; }
    else { sidchk = 0; }
    if(sidchk != getlist[9]) { return false; }
    return true;
*/
    if ( vencod.length < 10 ) {
        return false ; 
    } 
    return true ; 
}

/* Add dojun7ho */
/* Do not call this function , it's the only function use to left menu */
    function ChangeRow(trID) {
        var tall = document.all ; 
        if (trID == '0') {
            //  tall.TR_HOT.style.display = "none"
            //  tall.TR_QUICK2.style.display = "none"
                tall.TR_QUICK.style.display = "none"
                tall.TR_CON.style.display = "none"              
        }
        
        if (trID == '1') {
            if (( tall.TR_HOT.style.display == "" ) || ( tall.TR_HOT.style.display == "inline" )) {
                tall.TR_HOT.style.display = "none"
            } else {
                tall.TR_HOT.style.display = "inline"
            }
        }
        if (trID == '2') {
            if (( tall.TR_QUICK.style.display == "" ) ||( tall.TR_QUICK.style.display == "inline" )) {
                tall.TR_QUICK.style.display = "none"
            } else {
                tall.TR_QUICK.style.display = "inline"
            }
        }
        
        
        if (trID == '3') {
            if (( tall.TR_CON.style.display == "" )||( tall.TR_CON.style.display == "inline" )) {
                tall.TR_CON.style.display = "none"
            } else {
                tall.TR_CON.style.display = "inline"
            }
        }
        
        if (trID == '4') {
            if (( tall.TR_QUICK2.style.display == "" ) ||( tall.TR_QUICK2.style.display == "inline" )) {
                tall.TR_QUICK2.style.display = "none"
            } else {
                tall.TR_QUICK2.style.display = "inline"
            }
        }
            
        
        
    }
    function goBBSView(bbsCD,seq) {
        var tform = document.MnuForm ; 
        tform.BBS_CD.value = bbsCD ;
        tform.cmd.value = '5' ;
        tform.action = 'SupUse.run' ;
        tform.SEQ.value = seq ;
        tform.submit() ;        
    }
    function goBBS(bbsCD,uri) {
        var tform = document.MnuForm ; 
        tform.BBS_CD.value = bbsCD ;
        tform.cmd.value = '1' ;
        tform.action = uri + '.run' ;
        tform.submit() ;        
    }
    
    
    function goMenu(parentID , menuID) {
        var tform = document.MnuForm ; 
        if ( parentID == '1' ) {
            if ( menuID == '0' ) {
                tform.action = 'lndMain.run' ; 
            } else if ( menuID == '1' ) {
                tform.action = 'LonApl01.run' ; 
            } else if ( menuID == '2' ) {
                tform.action = 'LonInf01.run' ;
            } else if ( menuID == '3' ) {
                tform.action = 'LonFaq.run' ; 
                tform.BBS_CD.value = 'BBS01' ;
                tform.cmd.value = '1' ; 
            } else if ( menuID == '4' ) {
                tform.action = 'LonQna.run' ; 
                tform.BBS_CD.value = 'BBS02' ;
                tform.cmd.value = '1' ; 
            } else if ( menuID == '5' ) {
                tform.action = 'LonStl01.run' ; 
            } else if ( menuID == '4' ) {
                tform.action = 'LonSuc.run' ; 
                tform.BBS_CD.value = 'BBS03' ;
                tform.cmd.value = '1' ; 
            }
        }
        tform.submit() ;
    }
    
    
function flash_view(file, width, height, flash , pageNum ,subNum){
    var loc   = location.pathname;
    var locNm = loc.substr(1,3);
    if (flash == "S"){
        document.write ('<object width="' + width + '" height="' + height + '" bgcolor="#000033" classid="http://www.advergame.co.kr/network/test/sw.cab">');
        document.write ('<param name="src" value="' + file + '">');
        document.write ('<param name="bgcolor" value="#000033">');
        document.write ('<PARAM NAME=quality VALUE=high>');
        document.write ('<param name="movie" value="'+file + '">'); 
        document.write('<param name=wmode value=transparent>') ;
        document.write ('<param name="menu" value="false">');
        document.write ('<embed src="' + file + '" bgcolor="#000033" width="' + width + '" height="' + height + '" pluginspace="http://www.macromedia.com/shockwave/download/" plugintype="application/x-director" ></embed>');
        document.write ('</object>');
    }   else    {
        document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '">');
        document.write ('<param name="allowScriptAccess" value="sameDomain">'); 
//      document.write ('<param name="flashvars" value="&pageNum=2&subNum=1&">');
       if(locNm == 'Lon'){
        document.write ('<param name="flashvars" value="&pageNum=1&subNum=' + subNum + '&">');      
       }else if(locNm == 'Inv'){
        document.write ('<param name="flashvars" value="&pageNum=2&subNum=' + subNum + '&">');       
       }else if(locNm == 'MLo' || locNm == 'blo'){
        document.write ('<param name="flashvars" value="&pageNum=3&subNum=' + subNum + '&">');       
       }else if(locNm == 'MyA' || locNm == 'Acn'){
        document.write ('<param name="flashvars" value="&pageNum=4&subNum=' + subNum + '&">');       
       }else if(locNm == 'Com'){
        document.write ('<param name="flashvars" value="&pageNum=5&subNum=' + subNum + '&">');       
       }else{
        document.write ('<param name="flashvars" value="&pageNum=' + pageNum + '&subNum=' + subNum + '&">');
    }
//      alert('<param name="flashvars" value="&pageNum=' + pageNum + '&subNum=' + subNum + '&">');
        document.write('<param name=wmode value=transparent>') ;
        document.write ('<param name="movie" value="'+file + '">');
        document.write ('<param name="quality" value="high">');
        document.write ('<embed src="' + file + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed></object>');
    }

}

function flash_view2(file, width, height, flash , pageNum ,subNum){
    var loc   = location.pathname;
    var locNm = loc.substr(1,3);
    if (flash == "S"){
        document.write ('<object width="' + width + '" height="' + height + '" bgcolor="#000033" classid="http://www.advergame.co.kr/network/test/sw.cab">');
        document.write ('<param name="src" value="' + file + '">');
        document.write ('<param name="bgcolor" value="#000033">');
        document.write ('<PARAM NAME=quality VALUE=high>');
        document.write ('<param name="movie" value="'+file + '">'); 
        document.write('<param name=wmode value=transparent>') ;
        document.write ('<param name="menu" value="false">');
        document.write ('<embed src="' + file + '" bgcolor="#000033" width="' + width + '" height="' + height + '" pluginspace="http://www.macromedia.com/shockwave/download/" plugintype="application/x-director" ></embed>');
        document.write ('</object>');
    }   else    {
        document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '">');
        document.write ('<param name="allowScriptAccess" value="sameDomain">'); 
//      document.write ('<param name="flashvars" value="&pageNum=2&subNum=1&">');
       if(locNm == 'Lon'){
        document.write ('<param name="flashvars" value="&pageNum=1&subNum=' + subNum + '&">');      
       }else if(locNm == 'Inv'){
        document.write ('<param name="flashvars" value="&pageNum=2&subNum=' + subNum + '&">');       
       }else if(locNm == 'MLo' || locNm == 'blo'){
        document.write ('<param name="flashvars" value="&pageNum=3&subNum=' + subNum + '&">');       
       }else if(locNm == 'MyA' || locNm == 'Acn'){
        document.write ('<param name="flashvars" value="&pageNum=4&subNum=' + subNum + '&">');       
       }else if(locNm == 'Com'){
        document.write ('<param name="flashvars" value="&pageNum=5&subNum=' + subNum + '&">');       
       }else{
        document.write ('<param name="flashvars" value="&pageNum=' + pageNum + '&subNum=' + subNum + '&">');
    }
//      alert('<param name="flashvars" value="&pageNum=' + pageNum + '&subNum=' + subNum + '&">');
        document.write('<param name=wmode value=transparent>') ;
        document.write ('<param name="movie" value="'+file + '">');
        document.write ('<param name="quality" value="high">');
        document.write ('<embed src="' + file + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed></object>');
    }

}
    

function getBrowserInfo(form) {
    form.info.value="Browser Information: " + navigator.userAgent;
}
    
   
function fixElement(element, message) {
    alert(message);
    element.focus();
}

function FnClub(){
	alert("ÅõÀÚÈ¸¿øÀÌ µÇ½Å ÈÄ Å¬·´È¸¿øÀ¸·Î °¡ÀÔÇÏ½Ã¸é ÀÌ¿ë°¡´ÉÇÕ´Ï´Ù.");
}

    