﻿
// Flash   id_name : IDName , swf_name :  (,GET), wdith: , height:  
function swf_func(id_name, swf_name, width, height) {
    document.writeln("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='/asset/flash/swflash.cab#version=8,0,0,0' width='" + width + "' height='" + height + "' id='" + id_name + "' align='middle'>");
    document.writeln("<param name='allowScriptAccess' value='always'>");
    document.writeln("<param name='movie' value='" + swf_name + "'>");
    document.writeln("<param name='quality' value='high'>");
    document.writeln("<param name='bgcolor' value='white'>");
    document.writeln("<param name='wmode' Value='Transparent'>");
    document.writeln("<param name='wmode' value='opaque'>");
    document.writeln("<EMBED src='" + swf_name + "' width='" + width + "' height='" + height + "' type='application/x-shockwave-flash' wmode='transparent'></EMBED>");
    document.writeln("</object>");
}


//  
function mov_func(id, name, width, height) {
    document.writeln("<OBJECT classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' width='" + width + "' height='" + height + "' id='" + id + "'>");
    document.writeln("<PARAM NAME='Filename' VALUE='" + name + "'>");
    document.writeln("<PARAM NAME='Showcontrols' VALUE='false'>");
    document.writeln("<PARAM NAME='Autostart' VALUE='false'>");
    document.writeln("<PARAM NAME='uimode' VALUE='false'>");
    document.writeln("<PARAM NAME='Volume' VALUE='-1000'>");
    document.writeln("<EMBED src='" + name + "' width='" + width + "' height='" + (Number(height) + 60) + "' id='" + id + "' autostart='0' controller='0' volume='-1000'></EMBED>");
    document.writeln("</OBJECT>");
}

//   (  )
function imageChange(imgSize) {
    for (i = 0; i < document.images.length; i++) {
        if (document.images[i].id == "userIMAGE") {
            if (document.images[i].width > imgSize) {
                document.images[i].height = document.images[i].height / (document.images[i].width / imgSize);
                document.images[i].width = imgSize;
            }
        }
    }
}

// 
function Check_onlyKorean(str) {
    for (var i = 0; i < str.length; i++) {
        if (str.charCodeAt(i) < 0xAC00 || str.charCodeAt(i) > 0xD7A3) {
            if ((str.charCodeAt(i) < 12593 || str.charCodeAt(i) > 12643) && (str.charCodeAt(i) != 32)) {
                return true;
            }
        }
    }
    return false;
}


// : openPopup('auth_write.asp','auth',667,500,'scrollbars=yes,width=667,height=500')
function openPopup(url, name, width, height, features) {
    var left = (screen.width - width) / 2;
    var top = (screen.height - height) / 2;
    return window.open(url, name, features + ',left=' + left + ', top=' + top);
}

/*
 :      
 : onkeyup="onlyNumber(this);"
*/

function onlyNumber(el) {
    el.value = el.value.replace(/\D/g, '');
}

//  ()
function Trim(str) {

    var resultStr = "";

    resultStr = TrimLeft(str);
    resultStr = TrimRight(resultStr);

    return resultStr;
}

//  ()
function TrimLeft(str) {
    var resultStr = "";
    var i = len = 0;
    if (str + "" == "undefined" || str == null) return null;
    str += "";

    if (str.length == 0) resultStr = "";
    else {
        len = str.length;
        while ((i <= len) && (str.charAt(i) == " ")) i++;
        resultStr = str.substring(i, len);
    }

    return resultStr;
}

//  ()
function TrimRight(str) {
    var resultStr = "";
    var i = 0;

    if (str + "" == "undefined" || str == null) return null;
    str += "";

    if (str.length == 0) resultStr = "";
    else {
        i = str.length - 1;
        while ((i >= 0) && (str.charAt(i) == " "))
            i--;
        resultStr = str.substring(0, i + 1);
    }

    return resultStr;
}

/*
 :  Input Box Blank Check
1 : setInputAlert(form1.field, fieldName);
*/
function setInputAlert(field, fieldName) {
    if (Trim(field.value) == "") {
        alert(fieldName + " .");
        field.focus();
        return false;
    } else {
        return true;
    }
}

/*
 :  Select Box Blank Check
1 : setSelectAlert(form1.field, fieldName);
*/
function setSelectAlert(field, fieldName) {
    if (Trim(field.value) == "") {
        alert(fieldName + " .");
        field.focus();
        return false;
    } else {
        return true;
    }
}

/*
 :  Check Box Blank Check
1 : setCheckAlert(form1.field, fieldName);
*/
function setCheckAlert(field, fieldName) {
    var temp = 0;
    for (i = 0; i < field.length; i++) {
        if (field[i].checked == true) {
            temp = temp + 1;
        }
    }

    if (temp == 0) {
        alert(fieldName + " .");
        return false;
    } else {
        return true;
    }
}

/*
 : 
1 : popresize()
*/
function popresize() {
    scrollheight = parseInt(document.body.scrollHeight);
    scrollwidth = parseInt(document.body.scrollWidth);

    clientheight = parseInt(document.body.clientHeight);
    clientwidth = parseInt(document.body.clientWidth);

    height = scrollheight - clientheight
    width = scrollwidth - clientwidth

    this.resizeBy(width, height);
}



/*   * obj : (this), chk :  true - over, false - out*/

function imgOver(obj, chk) {
    if (chk) {

        obj.src = obj.src.replace(/_off/gi, "_on")

    } else {

        obj.src = obj.src.replace(/_on/gi, "_off")

    }

}

/* DIV IL    */
function ilsize(firstIL, lastIL) {

    if ($(firstIL).offsetHeight > $(lastIL).offsetHeight) {
        $(firstIL).offsetHeight = $(lastIL).offsetHeight + "px";
    }
    else {
        $(lastIL).offsetHeight = $(firstIL).offsetHeight + "px";
    }

}



/*   */
function init() {

    if ($("contentsLNB").offsetHeight > $("contentsMain").offsetHeight) {
        $("contentsMain").style.height = $("contentsLNB").offsetHeight + "px";
    }
}


/*    START*/

function openSelBox(id) {

    var obj = $(id + "_Items");
    var tempID = "";

    displaySelBox(obj, "block");

    if (document.all) {


        for (i = 1; i < 10; i++) {
        
            tempID = id.substring(0,id.indexOf("0") + 1);
        
            if($(tempID + i)){

                if ((tempID + i) == id) {

                    $(tempID + i).parentNode.style.position = "relative";

                }
                else {

                    $(tempID + i).parentNode.style.position = "static";

                }

            }
            

        }
                

    }


}

function displaySelBox(obj, display) {

    $(obj).style.display = display;

}

function selectItem(obj) {

    if (document.all) {
        var textbox = obj.parentNode.parentNode.childNodes[0]
    } else {
        var textbox = obj.parentNode.parentNode.childNodes[1]
    }


    textbox.value = obj.innerHTML

    obj.parentNode.style.display = "none";

}

/*    END*/


/*   START */

function selectRadio(obj) {

    var tempID = obj.id;
    var radio = $(obj).previousSibling

    radio.checked = true;

    for (i=0; i < document.getElementsByName(radio.name).length; i++) {

        if (document.getElementsByName(radio.name)[i].checked == true) {
            document.getElementsByName(radio.name)[i].nextSibling.src = document.getElementsByName(radio.name)[i].nextSibling.src.replace(/_off/, "_on")
        }
        else {
            document.getElementsByName(radio.name)[i].nextSibling.src = document.getElementsByName(radio.name)[i].nextSibling.src.replace(/_on/, "_off")
        }
    
    }
    
}    

/*   END */