/* OLD Version ---------------------------------------------------------------------------------------------------- */
// Check Browser Version
var bName       = navigator.appName;
var bVer        = parseInt(navigator.appVersion);
var bVersion    = navigator.appVersion;
var bUserAgent  = navigator.userAgent
var bPlatform   = navigator.platform
var NS          = (bName == "Netscape" );
var IE          = (bName == "Microsoft Internet Explorer" );

var NS4 = (bName == "Netscape" && bVer >= 4);
var IE4 = (bName == "Microsoft Internet Explorer" && bVersion.indexOf("MSIE 4") != -1);
var NS3 = (bName == "Netscape" && bVer < 4);
var IE3 = (bName == "Microsoft Internet Explorer" && bVer < 4);

var NS4_7   = (bName == "Netscape" && bVersion.substring(0,3) >= 4.7);
var IE5     = (bName == "Microsoft Internet Explorer" && bVersion.indexOf("5.") != -1);
var NS6     = (bName == "Netscape" && bUserAgent.indexOf("6.0") != -1 );

var IE5_5 = (bName == "Microsoft Internet Explorer" && bVersion.indexOf("MSIE 5.5") != -1);
var IE6   = (bName == "Microsoft Internet Explorer" && bVersion.indexOf("MSIE 6") != -1);
/////////////////////////////////////////////////////////////////////////////////////////


var  showImage    = '';

var  clickImage    = '';


var clickObj = null;


function funcLinkFile( file_path )
{

    if( NS ) {
        file_type = funcGetFileType(file_path).toLowerCase();
        if (isBlankOpenOfNetscape(file_type)) { 
            location.href = escape(file_path);
        }else {                                
            var link_file = window.open( escape(file_path), 'file_view', 'scrollbars=yes,status=yes,menubar=no,location=top,toolbar=no,directory=no,resizable=yes,top=200,left=200,width=500,height=500');
            link_file.focus();
       }
    }else {
        var link_file = window.open( file_path, 'file_view', 'scrollbars=yes,status=yes,menubar=no,location=top,toolbar=no,directory=no,resizable=yes,top=200,left=200,width=500,height=500');
        link_file.focus();
    }
}


function isBlankOpenOfNetscape( getFileType )
{
    var file_type = getFileType.toLowerCase();
    if ( file_type == 'cab' || file_type == 'tgz' || file_type == 'zip'  || file_type == 'xls' || file_type == 'hwp' || file_type == 'pdf' || file_type == 'rar' || file_type == 'arj' || file_type == 'ppt' || file_type == 'doc' || file_type == 'exe' || file_type == 'vcd' || file_type == 'mp3' || file_type == 'mpeg' || file_type == 'ra' ||  file_type == 'rm' ) return true;
    else return false;
}


function getListOfDay(yyObj,mmObj,ddObj)
{
    var year =yyObj.options[yyObj.selectedIndex].value;
    var month=mmObj.options[mmObj.selectedIndex].value;
    var endday= getEndOfMonthDay( year , month)

    ddObj.length=endday;

    for( i = 0; i < endday; i++ ) {
       ddObj.options[i].value =toLen2(i+1);
       ddObj.options[i].text  = i+1;
    }
    ddObj.selectedIndex = 0;
}

function toLen2 (  nums )
{
    var num=0;

    if ( nums >= 1 && nums <=9 )
        num = '0' + nums;
    else
        num=nums;
    return num;
}



function getClientProgramName(path_file)
{
    var name = "";
    var separator = "";
    if ( bPlatform.indexOf("Win") != -1 ){
         separator = "\\"
    }else {
         separator = "/"
    }

    var dash_pos = path_file.lastIndexOf(separator);
    if (dash_pos != -1 ) {
        name = path_file.substring(dash_pos+1);
    }else {
        name = path_file;
    }
    return name ;
}


function getByteLength( data )
{
    var len = 0;
    var str = data.substring(0);

    if ( str == null ) return 0;

    for(var i=0; i < str.length; i++) {
        var ch = escape(str.charAt(i));

        if( ch.length == 1 ) len++;
        else
        if( ch.indexOf("%u") != -1 ) len += 2;
        else
        if( ch.indexOf("%") != -1 ) len += ch.length/2;
   }

   return len;
}



function funcGetFileType( str ) {
    var newstr="";
    var  len=0   ;
    if (str==null )   return "";

    var text = str.substring(0);
    if (text=='' || text.length < 1 )   return '';

    var  point = text.lastIndexOf( "." );
    if( point == -1 ) len = str.length;
    else len = point;

    newstr = text.substring(len+1);

    return newstr;

}


function funcReturnWarn ( obj, str )
{
   return veiwErrMsg(obj, str);
}



function funcCheckBrowser()
{
    var bName = navigator.appName;
    var bAgent = navigator.userAgent;
    var bVer = navigator.appVersion;

    if( bName == "Netscape" && bVer.indexOf("4.") != -1 )
        return "ns";
    else
    if( bName == "Microsoft Internet Explorer" && bVer.indexOf("4.") != -1 )
        return "ie";
    else
        
        alert('Only use at Netscape 4.X\n\nMicrosoft Internet Explorer 4.X\n\nbrowser.');

    
}


function funcSendComboName(srcObj,tarObj)
{
    tarObj.value = srcObj.options[srcObj.selectedIndex].text;
}


function funcClickRow(obj)
{   var dispField   = "#E8E8E8";
    var overField   = "#87ceeb";


    if ( clickObj != null) clickObj.style.background = dispField;
    clickObj             = obj;
    obj.style.background =  overField;
}


function funcOnBlurChecked(srcObj,tgtObj)
{

    if (tgtObj.checked == false && srcObj.value.length > 0 ) tgtObj.checked = true;
    if (tgtObj.checked == true && srcObj.value.length == 0 ) tgtObj.checked = false;
}

function funcListSort(sort_name)
{
    var form = parent.con_frame.document.epis;
    form.sort_name.value = sort_name;
    parent.con_frame.funcLocation('message')
}


function funcAlertOfProcessing(obj,comment )
{

    if (obj.value=='Y')  {
       
        alert('Now '+comment+'\n Please wait until message '+comment);
        return false;
    }else {
        return true;
    }
}


function check_Combo( obj, str,check_flag )
{
    var message = "";
    var check_flag = check_flag.toUpperCase()
    var error = false;
    if ( check_flag == "") {
        if ( obj.options[obj.selectedIndex].value == "" ) {
            error = true;
            
            message = "Select" +str ;
        }
    }else if (check_flag == "0") {
        if ( obj.selectedIndex==0 ) {
            error = true;
           
            message = "Select" +str ;
        }

    }else if ( check_flag == "KEY") {
        if ( obj.selectedIndex == -1  || obj.options[obj.selectedIndex].value == ""  )  {
            error = true;
           
            message = str + " \'s value is mandatory. Not use blank.";
        }
    }else  {
        if (obj.selectedIndex == -1 ) {
            error = true;
           
            message = "Select" +str ;
        }
    }

    if (error) {
        alert(message);
        obj.focus();
        return   false;

    }
    return true
}



function check_Length(Obj,startLength,endLength,comment, mandatory)
{
    var data_length =  Obj.value.length;
    
    if( data_length == 0   && mandatory){
        var mesg = "";
        if( startLength ==  endLength && startLength !=  0) {
            
            mesg = "Length "+startLength+"";

        }else if(startLength!=0 && endLength !=0){
           
            mesg = ""+startLength+"More then " +endLength +"Less then";

        }else if(startLength==0){
           
            mesg = "Less then " +endLength +"";

        }else if(endLength ==0) {
            mesg = "More then "+startLength+"";
        }

        
        alert(comment + " Field is not fill.\n" +
              comment + " is "+mesg+" mandatory.\n  ");
        Obj.focus();

    }else if (data_length != 0) {
        if(startLength==0 && endLength ==0) {
            return true;
        }else if(startLength ==  endLength && startLength !=  data_length ) {
            
            alert(comment + "\'s length is  "+startLength+".\n");
            Obj.focus();
            Obj.select();
        }else if(startLength==0 && endLength < data_length ) {
            
            alert(comment + "\'s length is less then "+endLength+".\n");
            Obj.focus();
            Obj.select();
        }else if(startLength > data_length  && endLength == 0  ){
            
            alert(comment + "\'s length is more then "+startLength+".\n");
            Obj.focus();
            Obj.select();
        }else if( ( startLength > data_length ) || (data_length > endLength  )) {
            if (startLength !=0 && endLength !=0 )  {
                
                alert(comment + "\'s length is more"+startLength+" and less "+endLength+".\n");
                Obj.focus();
                Obj.select();
            }else {
                return true;
            }
        }else   {
            return true;
        }
    }else {
        return true;
    }

    return false;
}


function check_HangulLength(Obj,startLength,endLength,comment, mandatory)
{
    var data_length =  getByteLength( Obj.value );
    
    if( data_length == 0   && mandatory) {
        var mesg = "";
        if( startLength ==  endLength && startLength !=  0) {
           
            mesg = "Length "+startLength+"";
        }else if(startLength!=0 && endLength !=0) {
           
            mesg = ""+startLength+"More then " +endLength +"Less then";
        }else if(startLength==0){
            
            mesg = "Less then " +endLength +"";
        }else if(endLength ==0) {
            
            mesg = "More then " +endLength +"";
        }

        
        alert(comment + " Field is not fill.\n" +
            comment + " is "+mesg+" mandatory.\n  ");
        Obj.focus();

    }else if (data_length != 0) {
        if(startLength==0 && endLength ==0) {
            return true;
        }else if(startLength ==  endLength && startLength !=  data_length ) {
           
            alert(comment + "\'s length is  "+startLength+".\n");

            Obj.focus();
            Obj.select();
        }else if(startLength==0 && endLength < data_length ){
           
            alert(comment + "\'s length is less then "+endLength+".\n");
            Obj.focus();
            Obj.select();
        }else if(startLength > data_length  && endLength == 0  ){
            
            alert(comment + "\'s length is more then "+endLength+".\n");
            Obj.focus();
            Obj.select();
        }else if( ( startLength > data_length ) || (data_length > endLength  )) {
            if (startLength !=0 && endLength !=0 )  {
                
                alert(comment + "\'s length is more "+startLength+" and less "+endLength+".\n");
                Obj.focus();
                Obj.select();
            }else   {
                return true;
            }
        }else {
            return true;
        }
    }else {
        return true;
    }

    return false;
}

function check_Email(obj, comment,mandatory)
{
    var data = obj.value;

    if( obj.value.length == 0 && mandatory) {
        
        alert(comment + " Field is not fill.\n" +
        comment + " is mandatory.\n  ");
        obj.focus();
        return false;

    }else {
        return isValidEmail(obj);
    }
    return true
}

function check_text( obj,comment)
{
    if( obj.value == '' || obj.value.length == 0 )  {
        
        alert(comment + " Field is not fill.\n" +
            comment + " is mandatory.\n  ");
        obj.focus();
        obj.select();
        return false;

    }

    return true ;
}

function check_jebunTextarea(obj,comment,len,mandatory)
{
    var data = obj.value;
    if (obj.value.length == 0   && mandatory ) {
        
        alert(comment + " Field is not fill.\n" +
            comment + " is mandatory.\n  ");
        obj.focus();
        return false;
    }else if (obj.value.length != 0 ) {
        var data_array = data.split("\r\n");

        for(i=0;i< data_array.length;i++) {
            if(data_array[i].length != len) {
                
                alert((i+1)+' line\'s  '+comment+'\'s value is ['+data_array[i]+'].\n Input length'+len+'.');
                obj.focus();

                return false;
            }
        }
    }
    obj.value = obj.value.toUpperCase();
    return true;
}


function check_Range(startObj, endObj, comment)
{
    if (startObj.value > endObj.value) {
       
        alert(comment + " \'s StartValue > EndValue.\nCheck startValue and endValue.\n");
        startObj.focus();
        startObj.select();
    }else {
        return true;
    }

    return false;
}


function check_PrintCnt(obj, comment, mandatory)
{
    
    if ((obj.value.length == 0) && mandatory) {
       
        alert(comment + " Field is not fill.\n" +
              comment + " is "+mesg+" mandatory.\n ex)3 ");
        obj.focus();
        obj.select();
    }else if (isNaN(obj.value)) {
        
        alert(comment + "\'s value is only Number.\n Check Value.\n\n ex) 3");
        obj.focus();
        obj.select();
    }else if (obj.value < 1 || obj.value > 3 )  {
       
        alert(comment + "\'s value is  1 ~ 3.\n Try again after check.");
        obj.focus();
        obj.select();
    }else {
        return true;
    }
    return false;
}


function check_isFloat( obj, before_len, after_len ,comment,mandatory)
{
    var before_ex ='';
    var after_ex = '';
    var i=0;
    //if (before_len ==0 ) before_len = 20;
    for(i=1;i<=before_len;i++) {
        if (i==1)   before_ex +=  Math.floor(Math.random()*9 +1);
        else if(i <10)      before_ex +=  Math.floor(Math.random()*10);
        else                before_ex += '3';
    }

    for(i=1;i<=after_len;i++){
        if(i <10)           after_ex +=   Math.floor(Math.random()*10);
        else                after_ex += '2';
    }
    var ex = before_ex + '.'+ after_ex
    var str = obj.value ;

    point = str.indexOf('.');
    if (point == -1  && mandatory ) {
       
        alert(comment + " Field is not fill.\n" +
            comment + " is "+mesg+" mandatory.\n ex) "+ex);
        obj.focus();
        return false;

    }else if (point != -1) {
        before_str = str.substring(0, point);
        after_str = str.substring(point+1, str.length);

        if (before_len !=0  && before_str.length > before_len) {
           
            alert(comment + " \'s Field is  more length decimal point  "+before_len+".\n\t\t ex) "+ex);
            obj.focus();
            obj.select();
            return false;
        }

        if (after_str.length > after_len) {
            
            alert(comment + " \'s Field is  less length decimal point  "+before_len+".\n\t\t ex) "+ex);
            obj.focus();
            obj.select();
            return false;
        }

    }else  {
        return true;
    }
    return true;
}


function check_Number(obj, comment, mandatory)
{
	var mesg='';
    if (obj.value.length == 0 && mandatory) {
        
        alert(comment + " Field is not fill.\n" +
            comment + " is "+mesg+" mandatory.\n ex) 1234");
        obj.focus();
        return false;

    }else if(obj.value.length != 0) {
        if (isNaN(obj.value))   {
           
            alert(comment + "\'s Filed is only Number.\n" +
                            "Not use Character.");
            obj.focus();
            obj.select();

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


function funcDetailShow(L,S,e)
{
        if(NS) {
                var barron = document.layers[L];
               
                barron.top = e.pageY   +30



               
                barron.left = 15;

                barron.visibility = "visible"

                

        }
        else if(IE) {


                var barron = document.all[L]
                

                barron.style.pixelTop = event.clientY + document.body.scrollTop + 18




               
                barron.style.pixelLeft = 35

                barron.style.visibility = "visible"



     }

}

function funcDetailDown(L) {
        if(NS) {
                document.layers[L].visibility = "hidden"
        }
        else if(IE) {
                document.all[L].style.visibility = "hidden"
        }
}



function funcClickImageOn(name)
{
        if (clickImage !='') document[clickImage].src = eval(clickImage + "_off.src");
        clickImage    = name;
        if (name !='') document[name].src = eval(name + "_click.src");

}

function funcCurrClickImageOn()
{
    if (clickImage !=''){
         document[clickImage].src = eval(clickImage + "_click.src");
    }
}

function funcImageOn(name)
{
    if(name!=''){
        showImage    = name;
        document[name].src = eval(name + "_on.src");
    }
}


function funcImageOff(name)
{
    if(name!='') {
        document[name].src = eval(name + "_off.src");
    }

   
}

function check_Date_Single(dateObj, comment,date_length, mandatory)
{   var mesg = '';
    var month = new Array( "31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31" );
    var dateMonth = '';

    var dateDay = ''

    if (date_length == 4 ){
        dateMonth = '01';
        dateDay = '01';
    }else if (date_length == 6 ){
        dateMonth = dateObj.value.substring(4, 6);
        dateDay = '01';
    }else {
        dateMonth = dateObj.value.substring(4, 6);
        dateDay = dateObj.value.substring(6, 8);
    }

    var ex = "";
    if (date_length == 4) ex = "2000";
    else if (date_length == 6) ex = "200011";
    else                   ex = "20001130";


    
    if ((dateObj.value.length == 0 )  && mandatory ) {
        
        alert(comment + " Field is not fill.\n" +
              comment + " is "+mesg+" mandatory.\n  ex)"+ex);
        dateObj.focus();
    }

    
    else if (dateObj.value.length != 0) {
        if (dateObj.value.length != date_length) {
          
            alert(comment + " \'s value is Not Date Type or \n"+date_length+"\'s length is wrong.\n\n ex) "+ex);
            dateObj.focus();
            dateObj.select();
        }
        
        else if (isNaN(dateObj.value))  {

            
            alert(comment + "\'s value is only Number.\n Check Value.\n\n ex) "+ex);
            dateObj.focus();
            dateObj.select();
        }
        
        else if ((dateMonth < '01') || (dateMonth > '12'))  {
            
            alert(comment + "\'s Month value is wrong.\nMonth vlaue is 1 ~ 12.\n\n ex) "+ex);
            dateObj.focus();
            dateObj.select();
        }
        
        else if (  date_length == 8  &&   (dateDay < '01') || (dateDay > month[dateMonth - 1])         )    {
           
            alert(comment + "\'s Day value is wrong.\n" + dateMonth + " \'s Month value is 1 ~ " + month[dateMonth - 1] + ".\n\n ex) "+ex);
            dateObj.focus();
            dateObj.select();
        }else   {
            return true;
        }
    }else {
        return true;
    }

    return false;
}


function check_Date(startDate, endDate, comment, mandatory,datalength)
{
    var month = new Array( "31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31" );

    var startMonth = startDate.value.substring(4, 6);
    var endMonth = endDate.value.substring(4, 6);

    var startDay = '';
    var endDay =    '';
    var startEx = '';
    var endEx = '';
    //var datalength = 0;

    if (datalength  == null) datalength=8;

        if ( datalength == 6 )
        {
            startDay = '01';
            startEx = '200011'
            endDay = '01';
            endEx = '200012'


        }
        else
        {
            startDay = startDate.value.substring(6, 8);
            startEx = '20001130'
            endDay = endDate.value.substring(6, 8);
            endEx = '20001231'


        }



   
    if (((startDate.value.length == 0 ) && (endDate.value.length == 0)) && mandatory)
    {
        
        alert(comment + " Field is not fill.\n" +
              comment + " is  mandatory.\n\n  ex) "+startEx+" ~ " +endEx);
        startDate.focus();
    }

    
    else if ((startDate.value.length != 0) || (endDate.value.length != 0))
    {
        if (startDate.value.length != datalength)
        {
            
            alert(comment + " \'s StartDate value is not fill or \n "+datalength+" \'s length is wrong.\n\n ex) "+startEx+" ~ " +endEx);
            startDate.focus();
        }
        else if (endDate.value.length != datalength)
        {
            
            alert(comment + " \'s EndDate value is not fill or \n "+datalength+" \'s length is wrong.\n\n ex) "+startEx+" ~ " +endEx);
            endDate.focus();
        }
       
        else if (isNaN(startDate.value))
        {
           
            alert(comment + " \'s StartDate is only Number.\nCheck StartDate's value.\n\n ex) "+startEx+" ~ " +endEx);
            startDate.focus();
            startDate.select();
        }
        else if (isNaN(endDate.value))
        {
            
            alert(comment + " \'s EndDate is only Number.\nCheck EndDate's value.\n\n ex) "+startEx+" ~ " +endEx);
            endDate.focus();
            endDate.select()
        }
       
        else if ((startMonth < '01') || (startMonth > '12'))
        {
           
            alert("Start " + comment + "\'s Date Format(month) is wrong.\nMonth Value ls 1 ~ 12.\n\n ex) "+startEx+" ~ " +endEx);
            startDate.focus();
            startDate.select();
        }
        else if ((endMonth < '01') || (endMonth > '12'))
        {
           
            alert("End " + comment + "\'s Date Format(month) is wrong.\nMonth Value ls 1 ~ 12.\n\n ex) "+startEx+" ~ " +endEx);
            endDate.focus();
            endDate.select()
        }
       
        else if ((startDay < '01') || (startDay > month[startMonth - 1]))
        {
           
            alert("Start " + comment + "\'s Date Format(day) is wrong.\n"+ startMonth +"Month Value ls 1 ~ " + month[startMonth - 1] + ".\n\n ex) "+startEx+" ~ " +endEx);

            startDate.focus();
            startDate.select();
        }
        else if ((endDay < '01') || (endDay > month[endMonth - 1]))
        {
            
            alert("End " + comment + "\'s Date Format(day) is wrong.\n"+ endMonth +"\'s Month Value ls 1 ~ " + month[endMonth - 1] + ".\n\n ex) "+startEx+" ~ " +endEx);
            endDate.focus();
            endDate.select()
        }
        
        else if (startDate.value > endDate.value)
        {
           
            alert(comment + " \'s StartValue > EndValue.\nCheck startValue and endValue.\n ex) "+startEx+" ~ " +endEx);
            startDate.focus();
            startDate.select();
        }
        else
        {
            return true;
        }

    }
    else
    {
        return true;
    }

    return false;

}


function check_Date_Length(startDate, endDate, comment, mandatory)
{
    var month = new Array( "31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31" );

    var startMonth = startDate.value.substring(4, 6);
    var endMonth = endDate.value.substring(4, 6);

    var startDay = '';
    var endDay =    '';
    var startEx = '';
    var endEx = '';
    //var datalength = 0;

    if (startDate.value.length != endDate.value.length)
    {
         
         alert('StartDate\'s length <> EndDate\'s length.\n Input try again.')
         startDate.focus();
         endDate.select();
         return false;
    }

    var datalength = startDate.value.length;
    if ( datalength == 6 )
    {
        startDay = '01';
        startEx = '200011'
        endDay = '01';
        endEx = '200012'


    }
    else
    {
        startDay = startDate.value.substring(6, 8);
        startEx = '20001130'
        endDay = endDate.value.substring(6, 8);
        endEx = '20001231'

    }



    
    if (((startDate.value.length == 0 ) && (endDate.value.length == 0)) && mandatory)
    {
        
        alert(comment + " Field is not fill.\n" +
              comment + " is  mandatory.\n  ");
        startDate.focus();
    }
   
    else if ((startDate.value.length != 0) || (endDate.value.length != 0))
    {
        if (startDate.value.length != 6 && startDate.value.length != 8)
        {
           
            alert(comment + " \'s StartDate value is wrong.\n\n ");

            startDate.focus();
            startDate.select();

        }
        else if (endDate.value.length != 6 && endDate.value.length != 8)
        {
           
            alert(comment + " \'s EndDate value is wrong.\n\n ");
            endDate.focus();
            startDate.select();
        }
       
        else if (isNaN(startDate.value))
        {
           
            alert(comment + " \'s StartDate is only Number.\nCheck StartDate's value.\n\n ex) "+startEx+" ~ " +endEx);
            startDate.focus();
            startDate.select();
        }
        else if (isNaN(endDate.value))
        {
            
            alert(comment + " \'s EndDate is only Number.\nCheck EndDate's value.\n\n ex) "+startEx+" ~ " +endEx);
            endDate.focus();
            endDate.select()
        }
       
        else if ((startMonth < '01') || (startMonth > '12'))
        {
            
            alert("Start " + comment + "\'s Date Format(month) is wrong.\nMonth Value ls 1 ~ 12.\n\n ex) "+startEx+" ~ " +endEx);
            startDate.focus();
            startDate.select();
        }
        else if ((endMonth < '01') || (endMonth > '12'))
        {
           
            alert("End " + comment + "\'s Date Format(month) is wrong.\nMonth Value ls 1 ~ 12.\n\n ex) "+startEx+" ~ " +endEx);
            endDate.focus();
            endDate.select()
        }
     
        else if ((startDay < '01') || (startDay > month[startMonth - 1]))
        {
           
            alert("Start " + comment + "\'s Date Format(day) is wrong.\n"+ startMonth +"Month Value ls 1 ~ " + month[startMonth - 1] + ".\n\n ex) "+startEx+" ~ " +endEx);
            startDate.focus();
            startDate.select();
        }
        else if ((endDay < '01') || (endDay > month[endMonth - 1]))
        {
            
            alert("End " + comment + "\'s Date Format(day) is wrong.\n"+ endMonth +"Month Value ls 1 ~ " + month[endMonth - 1] + ".\n\n ex) "+startEx+" ~ " +endEx);
            endDate.focus();
            endDate.select()
        }
        
        else if (startDate.value > endDate.value)
        {
            
            alert(comment + " \'s StartValue > EndValue.\nCheck startValue and endValue.\n ex) "+startEx+" ~ " +endEx);
            startDate.focus();
            startDate.select();
        }
        else
        {
            return true;
        }

    }
    else
    {
        return true;
    }

    return false;

}

function check_date_cmp(startDate, endDate, comment,comment2)
{
    var startDate = funcReplaceStrAll(startDate.value, "-", "");
    startDate = funcReplaceStrAll(startDate, "/", "");

    var endDate = funcReplaceStrAll(endDate.value, "-", "");
    endDate = funcReplaceStrAll(endDate, "/", "");


    if  (startDate > endDate)
    {
        
        alert("Check "+comment + "\'s value and   "+comment2+"\'s value.\n\n" );
        return false;
    }
    else
    {
        return true;
    }



}

function check_AhpaNumeric(obj, comment, mandatory)
{

    if ((obj.value.length == 0) && mandatory)
    {
       
        alert(comment + " Field is not fill.\n" +
              comment + " is mandatory.\n\n ex) ABC124-01");
        obj.focus();
    } else if (obj.value.length != 0)
    {
        check_ahpaNum = true;
        for (i = 0; i < obj.value.length && check_ahpaNum; i++)
        {
            if ((obj.value.charAt(i) >= 0 && obj.value.charAt(i) <= 9) ||
                (obj.value.charAt(i) >= 'A' && obj.value.charAt(i) <= 'Z') ||
                (obj.value.charAt(i) >= 'a' && obj.value.charAt(i) <= 'z') ||
                (obj.value.charAt(i) == '-' ))
            {
                ;
            }
            else
            {
                check_ahpaNum = false;
            }
        }
        if (check_ahpaNum)
        {
            lCase2Ucase(obj);
            return true;
        }
        else
        {
           
            alert(comment + " \'s Filed is only alphabet or number.\n" +
                            "not use special character. ");
            obj.focus();
            obj.select();
        }
    } else
    {
        lCase2Ucase(obj);
        return true;
    }

    return false;
}


function checkLine_AhpaNumeric(obj, comment, mandatory)
{

    if ((obj.value.length == 0) && mandatory)
    {
        
        alert(comment + " Field is not fill.\n" +
              comment + " is mandatory.\n\n ex) ABC124-01");
        obj.focus();
    } else if (obj.value.length != 0)
    {
        check_ahpaNum = true;
        for (i = 0; i < obj.value.length && check_ahpaNum; i++)
        {
            if ((obj.value.charAt(i) >= 0 && obj.value.charAt(i) <= 9) ||
                (obj.value.charAt(i) >= 'A' && obj.value.charAt(i) <= 'Z') ||
                (obj.value.charAt(i) >= 'a' && obj.value.charAt(i) <= 'z') ||
                (obj.value.charAt(i) == '-' ) ||
                (obj.value.charAt(i) == '_' ))
            {
                ;
            }
            else
            {
                check_ahpaNum = false;
            }
        }
        if (check_ahpaNum)
        {

            return true;
        }
        else
        {
            
            alert(comment + " \'s Filed is only alphabet or number.\n" +
                            "not use special character. ");
            obj.focus();
            obj.select();
        }
    } else
    {

        return true;
    }

    return false;
}


 function check_AllFile(obj,filetype)
 {
       
        var count = 0 ;
        var length = 0;

        if ( obj.length == null)
        {
            length = 1
            if( check_File(obj ,filetype) == false ) return false;
        }
        else
        {
            length = obj.length

            for ( i=0 ; i< length ; i++)
            {
                if (obj[i].value == '' ) count ++;
            }

            if ( count == length )
            {
               
               var ans = confirm("Process with not attach file?")

               if ( ans == false )
               {
                        obj[0].focus();
                        obj[0].select();
                        return false;
               }
             }
             else
             {
                for ( i=0 ; i< length ; i++)
                {
                    if ( obj[i].value != ''  && check_File(obj[i] ,filetype)== false )  return false;
                }

             }

            for(var i=0;i<length;i++)
           {
              for (var j=i+1;j<length;j++)
              {
               
               if( obj[i].value == obj[j].value && obj[i].value !='')
               {
                 
                 alert('Same file'(i+1)+'\'s file and '+(j+1)+'\'s file.\nChoice another file');
                 obj[j].focus();
                 obj[j].select();
                return false;
              }
            }
          }




        }

        return true

     }




function check_File(obj ,type)
{
    var fileName     = obj.value;

    var errFlag      = "true";



    if(fileName == "")
    {
       
       var ans = confirm("Process with not attach file?")
       if ( ans == false )
       {
            obj.focus();
            obj.select();
            return false;
       }
       else
       {
            return true;
       }

    }
    else
    {
        
        if( fileName == '' )
        {
            
            alert('Choice File!!!');
            obj.focus();
            obj.select();
            return false;
        }
       
        else  if (  fileName.indexOf('(') != -1 ||
                    fileName.indexOf(')') != -1 ||
        //          getClientProgramName(fileName).indexOf(' ') != -1 ||
                    fileName.indexOf('<') != -1 ||
                    fileName.indexOf('>') != -1
                )
        {
            
            alert('file name is not contain (, <,>  .');
            obj.focus();
            obj.select();
            return false;


        }else
        {

            var  filetype = funcGetFileType(fileName).toLowerCase();

            if ( type.toLowerCase() != '*'  && type.toLowerCase() != filetype )
            {
                
                alert('File\'s extension is only '+type+'.');
                obj.focus();
                obj.select();
                return false;
            }

        }

        return true
    }

}


function setCookieOfDay(name,value,expiredays)
{
  var todayDate = new Date();
  todayDate.setDate(todayDate.getDate() + expiredays);
  document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"


}


function register(name, value, expire)
{


          document.cookie = name + "=" + escape(value)+" ;path=/"
          + ( (expire) ? ";expires=" + expire.toGMTString() : "")
}


function getCookie(name) {

    var flag = document.cookie.indexOf(name+'=');
    if (flag != -1) {
        flag += name.length + 1
        end = document.cookie.indexOf(';', flag)

        if (end == -1) end = document.cookie.length
        return unescape(document.cookie.substring(flag, end))
    }
}

function setCookie(name,value,hour,day)
{
        if (hour == 0)  hour=1;
        if (day > 0)    hour=24;
        var today = new Date()
        var expire = new Date(today.getTime() + 60*60*1000*hour*day)

        register(name, value, expire)
}

function check_jebunTextarea_Length(obj, comment,len ,mandatory)
{
    
    if ( obj.value.length == 0  && mandatory)  {
        
        alert(comment + " Field is not fill.\n" +
              comment + " is mandatory.\n  ");
        obj.focus();
    }

    else if (obj.value.length != 0) {
        if (len==999 )  {
            if (obj.value.length != 5 &&  obj.value.length != 6 && obj.value.length != 7 && obj.value.length != 8) {
               
                alert(comment + " \'s length is wrong.\n\n ");
                obj.focus();
                obj.select();
            }else {
                return true;
            }
        }else if(len!=999)  {
            if (obj.value.length != len) {
              
              alert(comment + " \'s length is wrong.\n\n Input length "+len);
                obj.focus();
                obj.select();
            }else {
                return true;
            }
        }else   {
            return true;
        }
    }else {
        return true;
    }

    return false;
}


function funcJoinCombo(combo,flag1,flag2)
{
    var data='';

    var len = combo.length
    for(var i=0;i < len;i++)
    {
        combo_value = combo.options[i].value
        if (i != 0)
            data +=  flag2+flag1+combo_value+flag1
        else
            //data += "'"+combo_value+"'" ;
            data += flag1+combo_value+flag1 ;
     }

    return data;
}


function enterText(docu,e,textObj,comboObj,comment,len,toChar)
{
    NS=(docu.layers)?true:false;
    IE=(docu.all)?true:false;

    if(NS) var keyValue = e.which
    else   var keyValue = event.keyCode

    if ( keyValue ==13 ) insertCombo(textObj,comboObj,comment,len,toChar);//alert('enter-init2');


}

function deleteKeyCombo(docu,e,comboObj)
{
    NS=(docu.layers)?true:false;
    IE=(docu.all)?true:false;

    if(NS) var keyValue = e.which
    else   var keyValue = event.keyCode

    if ( keyValue ==46 ) deleteCombo(comboObj);//alert('enter-init2');


}

function deleteCombo(comboObj)
{
    deleteComboData(comboObj);
}

function insertCombo(textObj,comboObj,comment,len,toChar)
{

    form = document.scs;
    if (!check_jebunTextarea_Length(textObj,comment,len,true)  )
   
    {
        return;
    }
    if (toChar.toUpperCase()=="TOUPPER")       textObj.value = textObj.value.toUpperCase()
    else if(toChar.toUpperCase()=="TOLOWER")   textObj.value = textObj.value.toLowerCase()
    else                                       textObj.value = textObj.value

    insertComboData(textObj,comboObj);

//  funcSave();

}


function deleteComboData(combo)
{

    var len = combo.length-1;
    for(var i=len;i >= 0;i--)
    {
       if(combo.options[i].selected == true )
       {
            combo.options[i]  = null;
       }
     }
}



function insertComboData(enterText,combo)
{
    var pre_length       =  parseInt(combo.length,10) ;

    if (pre_length == 1 && combo.options[0].value == '' ) pre_length=0;

    var text_value =    enterText.value;
    enterText.value='';
    option = new Option(text_value,text_value);
    combo.options[pre_length] = option
}



    function checkAll(obj)
    {
      if (obj.length ==null)
      {
            obj.checked = true;
      }
      else
      {
        for (var j = 0; j < obj.length; j++)
        {
            if (obj[j].checked == false) obj[j].checked = true;
        }

      }

    }

   
    function uncheckAll(obj)
    {
      if (obj.length ==null)
      {
            obj.checked = false;
      }
      else
      {
        for (var j = 0; j < obj.length; j++)
        {
            if (obj[j].checked == true) obj[j].checked = false;
        }

      }
    }


    function switchAll(obj)
    {
      if (obj.length ==null)
      {
            obj.checked = !obj.checked;
      }
      else
      {
        for (var j = 0; j < obj.length; j++)
        {
            obj[j].checked = !obj[j].checked;
        }

      }

    }


    function CheckBoxSwitchOfBlur(checkObj,targetObj)
    {
        targetObj.checked=checkObj.checked


    }

    
    function check_allCheckBox( obj, str ,mandatory)
    {
        //    var  chk_val='';
        var len  = obj.length;
        var check_index = 0;

        if( len == null )
        {
            if ( obj.checked == true  )
            {
                check_index++;
            }

        }else
        {
            for( var i = 0 ; i < len; i++ )
            {
                if ( obj[i].checked == true  )
                {
                    check_index++;
                }
            }

        }

        if (check_index == 0 && mandatory)
        {
            return   false;
        }
        else
        {
            return true
        }

    }

    
    function check_Checkbox( obj, str ,mandatory)
    {

        if (check_allCheckBox( obj, str ,mandatory))
        {
            return true
        }
        else
        {
            alert(str + "select");
           
            return   false;
        }

    }
    
    function confirmOfNull_Checkbox( obj, str ,mandatory)
    {

        if (check_allCheckBox( obj, str ,mandatory))
        {

            return true

        }
        else
        {
           
           var ans = confirm("Process with "+str+" not select?")
           if ( ans == false )
           {
                return false;
           }
           return    true;

        }

    }
    

    function funcJoinCheck(obj,flag1,flag2)
    {
        var data='';

        var check_index = 0;
        var len = obj.length
        if (len==null)
        {
            if (obj.checked == true )
            {
                obj_value = obj.value
                data += flag1+obj_value+flag1
                check_index++;
            }


        }
        else
        {
            for(var i=0;i < len;i++)
            {
                if (obj[i].checked == true )
                {
                    obj_value = obj[i].value

                    if (check_index != 0)
                    {
                        data +=  flag2+flag1+obj_value+flag1
                    }
                    else
                    {
                        data += flag1+obj_value+flag1
                        check_index++;
                    }
                }
             }

        }

        return data;
    }


/*
function funcOpenHelp( workPath ,pgmId)
{

    if(workPath!='' )
    {

    winMenu1 = window.open( '../blank.html', pgmId,'width=850,height=600,top=80,left=80,scrollbars=yes,status=yes,menubar=no,toolbar=no,directory=no,resizable=yes');

    winMenu1.document.writeln("<html>");
    winMenu1.document.writeln("<head>");
    winMenu1.document.writeln("<title></title>");
    winMenu1.document.writeln("</head>");
    winMenu1.document.writeln("<frameset rows=\"90,*\"  >");
    winMenu1.document.writeln(" <frame src='/help/help/home.htm'  name='det_con_frame'  scrolling='no'  scrolling='no' border='0' frameborder='no' marginwidth='0' >");
    winMenu1.document.writeln(" <frame src='/help/help/html/"+workPath.toLowerCase()+".htm#"+pgmId+"'   name='det_lst_frame' noresize  scrolling='auto' border=1 marginwidth='0' frameborder='no'>");
    winMenu1.document.writeln("</frameset></html>");
   }
   else
   {
        alert('help');
   }




}
*/

//-------------      Excel              ---------------------//
function funcOpenExcel( userTop,target)
{

   var userWidth = 0;
   var userHeight = 0;
   userWidth=(screen.availWidth-10)
   userHeight=(parseInt(screen.availHeight,10)-90-userTop)

   var stat = 'resizable=yes,scrollbars=yes,status=yes,toolbar=no,personalbar=yes,menubar=yes,locationbar=no,top='+userTop+',left=0,width='+userWidth+',height='+userHeight+'';
   var file_viewer =  window.open('/blank.html', target, stat );

}




function funcSimpleMessage(form,obj, message)
{
    if(message!='' )
    {
        obj.value = message;

        winMessage = window.open( '/blank.html', 'sim' ,'width=500,height=230,top=150,left=150,scrollbars=yes,status=yes,menubar=no,toolbar=yes,directory=no,resizable=yes');

        form.method = 'POST' ;
        form.target = 'sim' ;
        form.action = '/pbf/remark.jsp' ;
        form.submit( ) ;
   }
}



function getFormatDate( data, flag)
{

    var result = "";

    if (data.length==0 ) return data;

    if(data!="")
    {

        if (data.length==8)
        {
            var year  = data.substring(0,4);
            var month = data.substring(4,6);
            var day   = data.substring(6,8);
            if (flag.toUpperCase()=="KOR")
            {
               
                result = year+"Year "+month+"Month "+day+"Day";

            }else{

                result = year+flag+month+flag+day;
            }
        }
        else if (data.length==6)
        {
            var year  = data.substring(0,4);
            var month = data.substring(4,6);

            if (flag.toUpperCase()=="KOR")
            {
          
                result = year+"Year "+month+"Month";
            }else
            {
                result = year+flag+month;
            }
        }
        else if (data.length==4)
        {
            var month = data.substring(0,2);
            var day   = data.substring(2,4);

            if (flag.toUpperCase()=="KOR")
            {
                
                result = month+"Month "+day+"Day";
            }else
            {
                result = month+flag+day;
            }
        }
        else
        {
                result = data;
        }
    }

    return result;

}



function setComma( str )
{
    num = removeComma(str);
    len = 0;

    if( num == "" ) return "";

    
    minus = num.indexOf( '-' );
 
    if( minus == -1 )
        num = num;
    else
        num = num.substring(minus+1, num.length );

   
    point = num.indexOf( '.' );

   
    if( point == -1 )
        len = num.length;
   
    else
        len = point;

   
    rtn_num = num.substring(0, len );

   
    array_num = new Array( ((len - len % 3) / 3) + 1 );
    idx = 0;

   
    for( i = len ; i > 0 ; i -= 3 )
    {
        array_num[idx] = rtn_num.substring(i-3, i );
        idx++;
    }
    rtn_num = "";

    
    for( i = idx-1; i >= 0 ;i-- )
    {
        if( i < (idx-1) ) rtn_num += ","; 
        rtn_num += array_num[i];
    }

  
    if( point > -1 ) rtn_num += num.substring( point, num.length );
    
    if( minus > -1 ) rtn_num = '-' + rtn_num;

    return rtn_num;
}








function getValue(obj, valType)
{
    var retVal = obj.innerText;
    var objs   = obj.childNodes;
    for(var i = 0, max = objs.length; i < max; i++) {
        var obj = objs[i];
        if( obj.tagName != null && obj.tagName.toUpperCase() == 'INPUT') {
            if( obj.type.toUpperCase() == 'TEXT' ) {
                retVal += obj.value;
            }
        }
    }
    if(valType == 'NUMBER') retVal = formatNumber(retVal);
    return retVal;
}

function changeClass(objs, startRow, arg0, arg1)
{
    var baseRow = startRow % 2;
    for(var i = startRow, max = objs.length; i < max; i++) {
        tds = objs[i].cells;
        var str = (i % 2 == baseRow)?arg0:arg1;
        for(var j = 0, len = tds.length; j < len; j++) {
            tds[j].className = str;
        }
    }
}

function viewErrMsg(obj, errMsg)
{
    alert(errMsg);
    if( obj != null) {
        try {
            obj.focus();
            if(obj.tagName.toUpperCase() == 'INPUT' && obj.type.toUpperCase() == 'TEXT') obj.select();
        }catch(exception) {
        }
    }
    return false;
}

function isValid()
{
    var cnt = document.all.length;
    for(var i = 0; i < cnt; i++) {
        var obj = document.all[i];
        if(obj.tagName.toUpperCase() == 'INPUT') {
            switch(obj.className.toUpperCase()) {
                case 'INPUTKEYTEXT' :   //inputKeyText
                    if(!isValue(obj) || !isValidText(obj)) return false;
                    break;
                case 'INPUTKEYNUMBER' : //inputKeyNumber
                    if(!isValue(obj) || !isNumber(obj)) return false;
                    break;
                case 'DISPLAYKEYNUMBER' : //displayKeyNumber
                    if(!isValue(obj) || !isNumber(obj)) return false;
                    break;
                case 'INPUTKEYDATE' :   //inputKeyDate
                    if(!isValue(obj) || !isValidDate(obj, obj.maxLength)) return false;
                    break;
                case 'INPUTKEYEMAIL' :   //inputKeyEmail
                    if(!isValue(obj) || !isValidEmail(obj)) return false;
                    break;
                case 'INPUTKEYCODE' :   //inputKeyCode
                    if(!isValue(obj) || !isValidText(obj) || !checkLine_AhpaNumeric(obj, (obj.comment == '')?obj.comment:obj.name, true)) return false;
                    break;
                case 'INPUTTEXT' :      //inputText
                    if(isValue(obj, false) && !isValidText(obj)) return false;
                    break;
                case 'INPUTNUMBER' :    //inputNumber
                    if(isValue(obj, false) && !isNumber(obj)) return false;
                    break;
                case 'DISPLAYNUMBER' :    //displayNumber
                    if(isValue(obj, false) && !isNumber(obj)) return false;
                    break;
                case 'INPUTDATE' :      //inputKeyDate
                    if(isValue(obj, false) && !isValidDate(obj, obj.maxLength)) return false;
                    break;
                case 'INPUTEMAIL' :   //inputEmail
                    if(isValue(obj, false) && !isValidEmail(obj)) return false;
                    break;
                case 'INPUTCODE' :   //inputCode
                    if(isValue(obj, false) && !isValidText(obj) && !checkLine_AhpaNumeric(obj, (obj.comment == '')?obj.comment:obj.name, false)) return false;
                    break;
            }
        }    }
    return true;
}//isValid()

function isValue(obj, isMsg)
{
    isMsg = (isMsg == null || isMsg);
    if( obj == null || obj.value == '' || obj.value.length <= 0 ) {
        if(!isMsg) return false;

        
        var msg = (isMsg == null)?obj.name:isMsg;
        
        msg += ' field is mandatory.\n\nPlease, Input value!';
        return viewErrMsg(obj, msg);
    }
    return true;
}

function isNumber(obj, isMsg)
{
    isMsg = (isMsg == null || isMsg);

   
    if( obj == null || isNaN(removeComma(obj.value)) ) {
        if(!isMsg) return false;

        var msg = (obj.comment == null)?obj.name:obj.comment;
        msg += ' field is not number.\n\nPlease, Input number!!';
        return viewErrMsg(obj, msg);
    }

    var val    = formatNumber(obj.value);

   
    if( obj.maxVal != null && obj.maxVal.length > 0 && !isNaN(removeComma(obj.maxVal))) {

        var maxVal = formatNumber(obj.maxVal);
        if( val > maxVal ) {
            var msg = (obj.comment == null)?obj.name:obj.comment;
            
            msg += "max";
            return viewErrMsg(obj, msg);
        }
    }

    
    if( obj.minVal != null && obj.minVal.length > 0 && !isNaN(removeComma(obj.minVal))) {

        var minVal = formatNumber(obj.minVal);
        if( val < minVal ) {
            var msg = (obj.comment == null)?obj.name:obj.comment;
            
             msg += "min";
            return viewErrMsg(obj, msg);
        }
    }
    return true;
}//isNumber()

function isSelectedOption(obj)
{
    if(obj.tagName != 'SELECT') return false;
    var val  = obj.options[obj.selectedIndex].value;
    if( val != null && val.length > 0 ) return true;
    return false;
}

function isValidDate(obj, maxLength)
{
    var retVal = true;
    var msg    = (obj.comment == null)?obj.name:obj.comment;
        msg += ' input date!';

    if( maxLength != 4 && maxLength != 6 && maxLength != 8 ) return viewErrMsg(obj, msg);
    if(obj == null || obj.value.length != maxLength) return viewErrMsg(obj, msg);

    var inputDate = obj.value;
    var yyyy = inputDate.substring(0, 4);
    var mm   = (maxLength >= 6)?inputDate.substring(4, 6):"01";
    var dd   = (maxLength == 8)?inputDate.substring(6, 8):"01";

    if (isNaN(yyyy) || parseInt(yyyy) < 1000) return viewErrMsg(obj, msg);
    if (isNaN(mm) || parseFloat(mm) > 12 || parseFloat(mm) < 1) return viewErrMsg(obj, msg);
    if (isNaN(dd) || parseFloat(dd) < 1 || (parseFloat(dd) > getEndOfMonthDay(parseFloat(yyyy.substring(2,4)), parseFloat(mm))) ) return viewErrMsg(obj, msg);

    return true;
}


function isValidLength(obj, startLength, endLength)
{
    var retVal = true;
    var msg    = (obj.comment == null)?obj.name:obj.comment;
        msg += ' aaaa';

    if( obj == null ) return viewErrMsg(obj, msg);
    var data_length =  obj.value.length;

    if( data_length == 0 ) return viewErrMsg(obj, msg);

    if(startLength == 0 && endLength == 0) return true;

    if( endLength == 0 ) {
        if( data_length >= startLength ) return true;
        return viewErrMsg(obj, msg);
    }else {
        if( data_length >= startLength && data_length <= endLength ) return true;
        return viewErrMsg(obj, msg);
    }
}//isValidLength()




function isValidEmail(obj)
{
    var msg    = (obj.comment == null)?obj.name:obj.comment;
        msg += ' aaaa!';
    var data = obj.value;
    if (data.length != 0 ) {
        var sign = data.indexOf("@");
        var dot = data.indexOf(".");

        if( sign < 1 || dot < 2 || sign >= dot ) return viewErrMsg(obj, msg);
        return true;
    }
    return viewErrMsg(obj, msg);
}
function switchAllOfObj(obj, src_obj)
{
    if (obj == null) return;
    if (obj.length ==null) {        obj.checked = src_obj.checked;
    }else {
        for(var j = 0; j < obj.length; j++) {
            obj[j].checked = src_obj.checked;
        }
    }
}//switchAllOfObj()

/* no check checkBox or radio */
function isChecks(obj)
{
    var len  = obj.length;

    if( len == null ) {         if ( obj.checked == true  ) return true;
    }else  {
        for( var i = 0 ; i < len; i++ ) {
            if ( obj[i].checked == true  ) return true;
        }
    }
    return false;
}//isChecks()
/* END - function for checkbox ************************************************/


/* BEGIN - function for change ************************************************/
/* change locale currency */
function formatCurrency(str, locale)
{
    if( str == null ) return '0';
    var num = formatNumber(str + '');
    if( isNaN(num) ) return '0';

    if(locale == null) locale = 'KR';

    if( locale == 'KR' || locale == 'EN' ) {
        var retVal = num.toLocaleString();
        var point = retVal.lastIndexOf(".");
        while( point > 0 ) {
            var tmp   = retVal.substring(retVal.length - 1, retVal.length);
            if(tmp == '0' || tmp == '.') {
                retVal = retVal.substring(0, retVal.length - 1);
            }else {
                break;
            }
            point = retVal.lastIndexOf(".");
        }
    }

    return retVal;
}

/* String to Number */
function formatNumber( str )
{
    var num = str;

    if( num == null || num == "" ) return 0;
    var rtn_num = removeComma(num);

    if( isNaN(rtn_num) ) return 0;
    return parseFloat(rtn_num);
}

/* Right Trim */
function  funcRtrim(str)
{
    var src = new String(str);
    var tmp = new String();
    var i,lastnum, len = src.length;

    for(i = len;i >= 0;i--){
       tmp = src.substring(i,i-1);
       if (tmp != ' ' ){
         lastnum = i;
         break;
       }
    }
    tmp = src.substring(0,lastnum);
    return tmp;
}

/* Left Trim */
function  funcLtrim(str)
{
    var src = new String(str);
    var tmp = new String();
    var i,firstnum, len = src.length;

    for(i = 0;i < len ;i++) {
       tmp = src.substring(i,i+1);
       if (tmp != ' ' ) {
         firstnum = i;
         break;
       }
    }
    tmp = src.substring(firstnum);
    return tmp;
}

/* Trim */
function  funcTrim(str)
{
    var src = new String(str);
    return funcLtrim(funcRtrim(str));
}

function funcTrimALL()
{
    var objs   = document.all;
    for(var i = 0, max = objs.length; i < max; i++) {
        var obj = objs[i];
        if( obj.tagName != null && obj.tagName.toUpperCase() == 'INPUT') {
            if( obj.type.toUpperCase() == 'TEXT' ) {
                if(obj.value.length <= 0) continue;
                obj.value = funcTrim(obj.value);
            }
        }
    }
}

function removeComma( str )
{
    if( str == "" ) return "";

    var num = str;

    var i = 0;
    var pos_com = 0;
    var rtn_num = "";

    while( i < num.length ) {
        pos_com = num.indexOf(',',i);

        if( pos_com == -1 ) {
            rtn_num += num.substring(i, num.length );
            break;
        }else {
            rtn_num += num.substring(i, pos_com );
            i = pos_com+1;
        }
    }
    return rtn_num;
}
/* END   - function for change ************************************************/

/* BEGIN - function for window ************************************************/
//funcOpenWindow
function funcOpenDefaultWindow(form,method,target, url, width, height)
{
    return funcOpenWindow(form, method, target, url, 300, 300, width, height, 'no', 'no', 'no', 'no', 'no');
}

//funcOpenWindow
//funcOpenWindow(form,'post','alert', '/kor/scsalert.html', 147,185, 590, 370, 0, 0, 0, 0, 1);
function funcOpenWindow(form, method,target, url,  _left, _top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
    var toolbar_str   = (toolbar   == 0 || toolbar   == 'yes') ? 'yes' : 'no';
    var menubar_str   = (menubar   == 0 || menubar   == 'yes') ? 'yes' : 'no';
    var statusbar_str = (statusbar == 0 || statusbar == 'yes') ? 'yes' : 'no';
    var scrollbar_str = (scrollbar == 0 || scrollbar == 'yes') ? 'yes' : 'no';
    var resizable_str = (resizable == 0 || resizable == 'yes') ? 'yes' : 'no';

    var opened_win =  open('about:blank', target, 'left=' + _left + ',top=' + _top + ',width='+width+',height='+height+',toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=no');
    //var opened_win =  open('about:blank', target, 'left=' + _left + ',top=' + _top + ',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status=yes,scrollbars='+scrollbar_str+',resizable='+resizable_str);
    //var opened_win =  open('about:blank', target, 'left=' + _left + ',top=' + _top + ',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status=yes,scrollbars='+scrollbar_str+',resizable='+resizable_str);

    if( method.toUpperCase()== 'POST') {
        form.method = 'POST' ;
    }else {
        form.method = 'GET' ;
    }
    form.action = url ;
    form.target = target;
    form.submit() ;
    opened_win.focus();

    return opened_win;
}//funcOpenWindow()


function funcRadioCheckValue(obj)
{
    if (obj == null) return null;

    var len  = obj.length;
    if ( len  == null)  {
        if(obj.checked == true ) return obj.value;

    }else {
        for(var i=0 ; i< len ;i++)  {
            if(obj[i].checked == true ) return obj[i].value;
        }
    }
    return null;
}
/* END   - function for getter ************************************************/

/* BEGIN - etc ****************************************************************/
/*
function viewImage(imageFileName)
{
    //var imgFileName = encodeURI(imageFileName);
    var imgFileName = imageFileName;
    var img_win = window.open( './blank.html', '_img_pop', 'height=5,width=5,top=60,left=100,scrollbars=yes,status=no,menubar=no,location=top,toolbar=no,directory=no,resizable=no');
   
    img_win.document.write("<HTML>\n");
    img_win.document.write("<HEAD>\n");
    //img_win.document.write("<META http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n");
    img_win.document.write("<SCRIPT>\n");
    img_win.document.write("    function funcInit()\n");
    img_win.document.write("    {\n");
    img_win.document.write("        var imgWidth  = document.map.width;\n");
    img_win.document.write("        var imgHeight = document.map.height;\n");
    img_win.document.write("        window.resizeTo(imgWidth + 40, imgHeight + 40);\n");
    img_win.document.write("    }\n");
    img_win.document.write("</SCRIPT>\n");
    img_win.document.write("</HEAD>\n");
    img_win.document.write("<BODY>\n");
    img_win.document.write("<CENTER>\n");
    img_win.document.write("<IMG name='map' src='"  + imgFileName + "' onLoad='funcInit()'>\n");
    img_win.document.write("</CENTER>\n");
    img_win.document.write("</BODY>\n");
    img_win.document.write("</HTML>\n");
    
}
*/

function funcCountMsg(count, command)
{
    if ( command.toUpperCase() == 'LIST') {
        self.status = 'Total: ' +count+' lines.';
        if (count == 0) alert('nothing!');
    }
}//funcCountMsg()


function funcReplaceStrAll(org_str, find_str, replace_str)
{
    var pos = org_str.indexOf(find_str);

    while(pos != -1) {
        pre_str  = org_str.substring(0, pos);
        post_str = org_str.substring(pos + find_str.length, org_str.length);
        org_str  = pre_str + replace_str + post_str;

        pos = org_str.indexOf(find_str);
    }
    return org_str;
}//funcReplaceStrAll()


function  getEndOfMonthDay( yy, mm )
{
    var max_days=0;

    if (mm == 1)        max_days = 31 ;
    else if (mm == 2) {

        if ((( yy % 4 == 0) && (yy % 100 != 0)) || (yy % 400 == 0))
                        max_days = 29;
        else
                        max_days = 28;
    }
    else if (mm == 3)   max_days = 31;
    else if (mm == 4)   max_days = 30;
    else if (mm == 5)   max_days = 31;
    else if (mm == 6)   max_days = 30;
    else if (mm == 7)   max_days = 31;
    else if (mm == 8)   max_days = 31;
    else if (mm == 9)   max_days = 30;
    else if (mm == 10)  max_days = 31;
    else if (mm == 11)  max_days = 30;
    else if (mm == 12)  max_days = 31;
    else {

        return '';
    }
        return max_days;
}


function funcReplaceCode( str )
{
    var pos = 0;
    var len = str.length;
    var replace_chr;
    var cur_chr;
    var replace_str = '';

    for(var i=0; i < len; i++) {
        cur_chr = str.charAt(i);

        if( cur_chr=='\"') replace_chr='##34';
        else if( cur_chr=='\'') replace_chr='##39';
        else if( cur_chr=='>')  replace_chr='##60';
        else if( cur_chr=='<')  replace_chr='##62';
        else if( cur_chr=='/')  replace_chr='##47';
        else if( cur_chr=='\\') replace_chr='##92';
        else if( cur_chr=='(')  replace_chr='##40';
        else if( cur_chr==')')  replace_chr='##41';
        else if( cur_chr==',')  replace_chr='##44';
        else
            replace_chr = cur_chr;

        replace_str += replace_chr;
    }
    return replace_str;
}


function funcReplaceSign( str )
{
    var pos = 0;
    var len = str.length;
    var replace_chr;
    var cur_chr;
    var replace_str = '';

    for(var i=0; i < len; i++) {
        cur_chr = str.charAt(i);

        if( cur_chr == '#' ) {
            cur_chr = str.substring(i,i+4);
            i += 3;
        }

        if( cur_chr=='##34') replace_chr='\"';
        else if( cur_chr=='##39') replace_chr='\'';
        else if( cur_chr=='##60') replace_chr='>';
        else if( cur_chr=='##62') replace_chr='<';
        else if( cur_chr=='##47') replace_chr='/';
        else if( cur_chr=='##92') replace_chr='\\';
        else if( cur_chr=='##40') replace_chr='(';
        else if( cur_chr=='##41') replace_chr=')';
        else if( cur_chr=='##44') replace_chr=',';
        else
            replace_chr = cur_chr;

        replace_str += replace_chr;
    }
    return replace_str;
}


function lCase2Ucase(obj)
{
    var re = /[a-zA-Z]/;
    if(re.test(obj.value)) obj.value = obj.value.toUpperCase();
}//lCase2Ucase()


function funcSelectCombo(comboObj, data, dataFlag)
{
    var index = 0 ;
    var len = comboObj.length;

    for(var i=0;i < len;i++) {
        var compare = '';
        if ( dataFlag.toUpperCase()=='TEXT') {
            if(data == comboObj.options[i].text) {
                comboObj.selectedIndex = index;
                break;
            }
        }else {
            if(data == comboObj.options[i].value) {
                alert(comboObj.options[i].value);
                comboObj.selectedIndex = index;
                break;
            }
        }
    }//for
}//funcSelectCombo()


//funcRound('123.5678',2)
function funcRound(data,pntLen)
{
   if (isNaN(data) || isNaN(pntLen) )
   {
      alert('Input value '+data+'or decimal below'+pntLen+'is not numeral.');
      return ;
   }
   data   = parseFloat(data);
   pntLen = parseInt(pntLen,10)

   var round = Math.pow(10,pntLen);
   var newDoub = Math.floor(data * round +.5)/round;

   return newDoub;
}


function replaceOptions(combo, opts, isSpace)
{
    if(combo == null) return;
    if(isSpace == null) isSpace = false;

    var tmp = combo.options;
    while(tmp.length > 0) {
        combo.remove(tmp[tmp.length - 1]);
    }

    if(isSpace) combo.add(new Option('--ALL--', ''));
    if(opts == null) return;
    for( var i = 0; i < opts.length; i++) {
        combo.add(opts[i]);
    }
}


function openLangPop(pgm_id , pgm_sub_id)
{
    var command = 'LANG_POP';

    var form = makeForm(command);
    makeHidden(command, 'command',              command);
    makeHidden(command, 'con_pgm_id',           pgm_id);
    makeHidden(command, 'con_pgm_sub_id',       pgm_sub_id);

    var search_win = funcOpenDefaultWindow(form, 'POST', 'lang_pop', '/servlet/I_BAS022');
    return;
}


function makeHidden(command, key, val)
{
    if(key == null || key == '' || val == null) return null;
    var form = eval("document." + command);
    if(form == null) form = makeForm(command);

    var hid_obj = eval("form." + key);
    if(hid_obj != null) {
        hid_obj.value = val;
        return hid_obj;
    }

    hid_obj = document.createElement("<INPUT type='hidden' name='" + key + "' value='" + val + "'>");
    form.appendChild(hid_obj);
    return hid_obj;
}

function makeForm(command)
{
    var retVal = eval("document." + command);
    if(retVal != null) return retVal;
    var form = document.createElement("<FORM name='" + command + "'></FORM>");
    document.body.appendChild(form);
    return makeForm(command);
}

//common
function getIdx(obj)
{
    var trObj = obj;
    //get tr obj;
    while(trObj.tagName != 'TR' && trObj.parentNode != null) {
        trObj = trObj.parentNode;
    }
    return trObj.rowIndex;
}

function getObjByIdx(obj, idx)
{
    if(obj == null) return null;
    if(obj.length != null) {
        return obj[idx];
    }else {
        return (idx == 0)?obj:null;
    }
}



function removeStr( arg0, arg1 )
{
    if( arg0 == "" || arg1 == "" ) return "";

    var str = arg0;

    var i = 0;
    var pos_str = 0;
    var rtn_str = "";

    while( i < str.length ) {
        pos_str = str.indexOf(arg1,i);

        if( pos_str == -1 ) {
            rtn_str += str.substring(i, str.length );
            break;
        }else {
            rtn_str += str.substring(i, pos_str );
            i = pos_str+1;
        }
    }
    return rtn_str;
}
/*  jinuxer */



function lCase2Lcase(obj)
{
    var re = /[a-zA-Z]/;
    if(re.test(obj.value)) obj.value = obj.value.toLowerCase();
}//lCase2Ucase()


/* END   - etc ****************************************************************/



//½ºÅ©¸³Æ®ÀÇ Á¡¼±À» ¾ø¾Ø´Ù
function WriteEmbed(emb_id)
{ 
    document.write(document.getElementById(emb_id).value);
} 



