<!--
// ---------------------------------------------------------------------------------------------- //
// Global Value Set
// ---------------------------------------------------------------------------------------------- //
var regEmail    = new RegExp('^[_a-zA-Z0-9-\.]+@[\.a-zA-Z0-9-]+\.[a-zA-Z]+$');
var regPasswd   = new RegExp('^[a-zA-Z0-9]{4,}$');
var regSubPasswd= new RegExp('^[a-zA-Z0-9]{4,}$');
var regName     = new RegExp('^[a-zA-Z0-9]{1,}[a-zA-Z0-9-, ]+$');
var regNumber   = new RegExp('^[0-9]+$');// only number;
var regAlpha    = new RegExp('^[a-zA-Z]+$');// only alphabet;
var regNormal   = new RegExp('^[a-zA-Z0-9_-]+$');// normal string;

// ---------------------------------------------------------------------------------------------- //
// Base 
// ---------------------------------------------------------------------------------------------- //
function ezDisplay(e)
{
    if ((document.getElementById(e).style.display == 'block') )
    {
        document.getElementById(e).style.display = "none";
    }
    else
    {
        document.getElementById(e).style.display = "block";
    }
}
function ezShow(e, control_method)
{
    if (control_method == 'vi') document.getElementById(e).style.visibility='visible';
    else document.getElementById(e).style.display = 'block';
    return;
}
function ezHide(e, control_method)
{
    if (control_method == 'vi') document.getElementById(e).style.visibility='hidden';
    else document.getElementById(e).style.display = 'none';
    return;
}

// ---------------------------------------------------------------------------------------------- //
// StyleSheet
// ---------------------------------------------------------------------------------------------- //
ezcss = {
    show : function(e, control_method)
    {
        if (control_method == 'vi') document.getElementById(e).style.visibility='visible';
        else document.getElementById(e).style.display = 'block';
        return;
    },
    hide : function(e, control_method)
    {
        if (control_method == 'vi') document.getElementById(e).style.visibility='hidden';
        else document.getElementById(e).style.display = 'none';
        return;
    },
    Display : function(e)
    {
        if ((document.getElementById(e).style.display == 'block') )
        {
            document.getElementById(e).style.display = "none";
        }
        else
        {
            document.getElementById(e).style.display = "block";
        }
    },
    setPosition : function(e, x, y)
    {
        document.getElementById(e).style.position  = 'absolute';
        document.getElementById(e).style.left      = x + 'px';
        document.getElementById(e).style.top       = y + 'px';
        return;
    },
    setWidth : function(e, width)
    {
        document.getElementById(e).style.width = width + "px";
        return;
    },
    setHeight : function(e, height)
    {
        document.getElementById(e).style.height = ezHeight + "px";
        return;
    },
    setBackground : function(e, color)
    {
        document.getElementById(e).style.background = color;
        return;
    },
    setCursor : function(e, type)
    {
        document.getElementById(e).style.cursor=type;
    }
}

function ezSetPosition(e, x, y)
{
    document.getElementById(e).style.position  = 'absolute';
    document.getElementById(e).style.left      = x + 'px';
    document.getElementById(e).style.top       = y + 'px';
    return;
}
function ezSetWidth(e, ezWidth)
{
    document.getElementById(e).style.width = ezWidth + "px";
    return;
}
function ezSetHeight(e, ezHeight)
{
    document.getElementById(e).style.height = ezHeight + "px";
    return;
}
function ezSetPadding(e)
{
    document.getElementById(e).style.padding = "5px 20px";
    return;
}
function ezSetBorder(e, b_width, b_style, b_color)
{
    document.getElementById(e).style.border= b_width + 'px ' + b_style + ' ' + b_color;
    return;
}
function ezSetBackground(e, rgb_code)
{
    document.getElementById(e).style.background = rgb_code;
    return;
}

function setOpacity(e, arg)
{
    if (document.getElementById)
    {
        if(document.all)
        {
            document.getElementById(e).style.filter="alpha(opacity=100)";
            document.getElementById(e).filters.alpha.opacity  = arg;
        }
        else
        {
            var opaci=""+arg/100+""
            document.getElementById(e).style.opacity = opaci;
        }
    }
}
function setCursor(e, type)
{
    if (document.getElementById)
    {
        document.getElementById(e).style.cursor=type;
    }
}
// ---------------------------------------------------------------------------------------------- //
// Event
// ---------------------------------------------------------------------------------------------- //
function ezGetCoordX(e) {
    return document.getElementById(e).offsetLeft;
}
function ezGetCoordY(e) {
    return document.getElementById(e).offsetTop;
}
function ezGetWidth(e)
{
    return document.getElementById(e).offsetWidth;
}
function ezGetHeight(e)
{
    return document.getElementById(e).offsetHeight;
}

// ---------------------------------------------------------------------------------------------- //
// ¸¶¿ì½ºÀÇ ÁÂÇ¥¸¦ screen_coordsÆûÀÇ ¿¤·¹¸ÕÆ®¿¡ ÀúÀåÇÑ´Ù.
// ---------------------------------------------------------------------------------------------- //
function ezSetCoordScreen(e)
{
    var x,y
    x = (document.all) ? event.clientX : e.pageX;
    y = (document.all) ? event.clientY : e.pageY;
    document.screen_coords.coordX.value = x;
    document.screen_coords.coordY.value = y;
}

function ezGetCoordScreenX()
{
    return document.screen_coords.coordX.value;
}
function ezGetCoordScreenY()
{
    return document.screen_coords.coordY.value;
}

function goTop()
{
    window.scrollTo(0,0);
}

// ---------------------------------------------------------------------------------------------- //
// Image Controll
// ---------------------------------------------------------------------------------------------- //
function changeImg(e, src, alt)
{
    if (e && src)
    {
        document.getElementById(e).setAttribute('src', src);
        document.getElementById(e).setAttribute('alt', alt);
    }
}

function preloadImg()
{
	var image = new Image();
	for (var i = 0; i < preloadImg.arguments.length; i++) {image.src = preloadImg.arguments[i];}
}

// ---------------------------------------------------------------------------------------------- //
// Cookie controll Class;
// ---------------------------------------------------------------------------------------------- //
Cookie = {
	set	: function(name, value, expireDay)
    {
		var expires = "";
		if (expireDay)
        {
			var date = new Date();
			date.setTime(date.getTime() + expireDay * 24 * 60 * 60 * 1000);
			expires = "; expires=" + date.toGMTString();
		}
		document.cookie = name + "=" + value + expires + "; path=/";
		return true;
	},
	get	: function(name)
    {
		var re = new RegExp("(\;|^)[^;]*(" + name + ")\=([^;]*)(;|$)");
		var res = re.exec(document.cookie);
		return res != null ? res[3] : null;
	},
	del	: function(name)
    {
		this.set(name, "", -1);
	}
}
// ÁöÁ¤ÇÑ ±â°£µ¿¾È Ã¢À» ¿­Áö ¾Ê´Â´Ù.
// fe : Æû¿¤·¹¸ÕÆ®°´Ã¼, cookie_name : ÄíÅ°ÀÌ¸§, cookie_value : ÄíÅ°°ª, expire_day : ÄíÅ°À¯È¿±â°£
function never_open_window(fe, cookie_name, cookie_value, expire_day)
{
    if (fe.checked)
    {
        Cookie.set(cookie_name, cookie_value, expire_day);
        self.close();
    }
}
// ---------------------------------------------------------------------------------------------- //
// FORMS
// ---------------------------------------------------------------------------------------------- //
// make select box; selOBJ is name of selectbox object;
// @ obj  : document.form.element
// @ data : Array(
//              Array(value0, key0),
//              Array(value1, key1),
//              .
//              .
//              Array(valueN, keyN)
Form = {
    select : function(obj, data)
    {
        var opt = new Array();
        
        for (var i = 0; i < data.length; i++)
        {
            obj.options[i] = opt[i] = new Option(data[i][1], data[i][0]);
        }
    }
}
// for textarea;
function usetab(e)
{
    if (event.keyCode ==9)
    {
        (e.selection = document.selection.createRange()).text = '\t';
        event.returnValue = false;
    }
}
function ezSelectbox(selOBJ, select_array)
{
    for (m = selOBJ.options.length-1; m > 0; m--)
    {
        selOBJ.options[m]=null;
    }
    selectedarray = eval(select_array);
    for (i = 0; i < selectedarray.length; i++)
    {
        selOBJ.options[i] = new Option(selectedarray[i].text, selectedarray[i].value);
    }
    selOBJ.options[0].selected=true;
}

function ClearTextBox(e)
{
    if (document.getElementById(e).value != null)
    {
        document.getElementById(e).value = '';
    }
}
// »ç¿ë»óÀÇ ¹«¸®°¡ ÀÖÀ½, ¸ðÁú¶ó Áö¿ø ¾ÈÇÔ;
function previewImg(e, fv)
{
    document.getElementById(e).setAttribute('src', fv.value);
}
// ---------------------------------------------------------------------------------------------- //
// Anchors
// ---------------------------------------------------------------------------------------------- //
function ezSetBlurAnchors()
{
    if (document.getElementsByTagName)
    {
        var anchors = document.getElementsByTagName("a");
        for (var i = 0; i < anchors.length; i++)
        {
            anchors.item(i).onfocus = function(){this.blur()};
        }
    }
}
// ---------------------------------------------------------------------------------------------- //
// Windows
// ---------------------------------------------------------------------------------------------- //
function open_window(url, name, features)
{
    var window_name = (name == null) ? '_blank' : name;
    window.open(url, name, features);
}

function openwin(page, name, w, h, x, y, features)
{
    var win = null;
    var posx;
    var posy;
    var opt;
    
    if (name == null) name = '_blank';
    
    posx = (x == null) ? (screen.width - w)/2 : x;
    posy = (y == null) ? (screen.height - h)/2 : y;
    
    opt  = 'width=' + w + 'px,';
    opt += 'height=' + h + 'px,';
    opt += 'left=' + posy + 'px,';
    opt += 'top=' + posy + 'px';
    opt += (features != null) ? ',' + features : '';
    
    win = window.open(page, name, opt);
    win.window.focus();
}

// ---------------------------------------------------------------------------------------------- //
// Frames
// ---------------------------------------------------------------------------------------------- //

//
// @ ÇÁ·¹ÀÓÀÌ¸é TRUE, ¾Æ´Ï¸é FALSE;
function is_frames()
{
    return ((typeof parent.frames[0]) == 'undefined') ? false : true;
}
// @ Á¢±Ù ÇÒ ¼ö ÀÖ´Â ÇÁ·¹ÀÓÀÏ °æ¿ì trur ¾Æ´Ï¸é false;
function is_access_frame(frame_name)
{
    return (eval('typeof parent.frames.' + frame_name + '.document') == 'unknown') ? false : true;
}
// Adds a function to the onload event
function addonload(func)
{
    // If window.onload is a function
	if(typeof window.onload == "function")
	{
    	var preonload= window.onload;

	    // New window.onload
		window.onload = function()
		{
			preonload();
			func();
		}
	}
	else
	{
		window.onload = func;
	}
}
function removeFrames()
{
    // If the page location does not equal the window location
    if (window.self.location.href != window.top.location.href)
    {
        window.top.location.replace(window.self.location.href);
    }
}
// ---------------------------------------------------------------------------------------------- //
// Strings Check validity
// ---------------------------------------------------------------------------------------------- //
STR = {
    is_empty : function(str)
    {
        var _str = trim(str);
        if (_str.length == 0) return true;
        else return false;
    },
    is_num : function(n)
    {
        var n;
        var anum=/(^\d+$)|(^\d+\.\d+$)/ 
        if (anum.test(n)) return true;
        else return false;
    },
    trim : function(str)
    {
        if (str)
        {
            return str.replace(/^\s+|\s+$/g, '');
        }
        else
        {
            return '';
        }
    },
    ltrim : function(str)
    {
        return str.replace(/^\s+/g, '');
    },
    rtrim : function(str)
    {
        return str.replace(/\s+$/g, '');
    },
    cut_str : function(str, limit)
    {
        var tmpStr = str;
        var byte_count = 0;
        var len = str.length;
        var dot = "";

        for (i = 0; i < len; i++)
        {
            byte_count += chr_byte(str.charAt(i)); 
            if (byte_count == limit-1)
            {
                if (chr_byte(str.charAt(i+1)) == 2)
                {
                    tmpStr = str.substring(0,i+1);
                    dot = "...";
                }
                else
                {
                    if (i+2 != len) dot = "...";
                    tmpStr = str.substring(0,i+2);
                }
                break;
            }
            else if(byte_count == limit)
            {
                if (i+1 != len) dot = "...";
                tmpStr = str.substring(0,i+1);
                break;
            }
        }
        //document.writeln(tmpStr+dot);
        return (tmpStr + dot);
    }
}

// ºñ¾îÀÖÀ» °æ¿ì true ±×·¸Áö ¾ÊÀ¸¸é false return;
function is_empty(str)
{
    var _str = trim(str);
    if (_str.length == 0) return true;
    else return false;
}
// ¼ýÀÚÀÎÁö Ã¼Å© ¼ýÀÚÀÏ°æ¿ì true, ¾Æ´Ò °æ¿ì false¹ÝÈ¯
function is_num(n)
{ 
    var n;
    var anum=/(^\d+$)|(^\d+\.\d+$)/ 
    if (anum.test(n)) return true;
    else return false;
}

function trim(str)
{
    return str.replace(/^\s+|\s+$/g, '');
}

function ltrim(str)
{
    return str.replace(/^\s+/g, '');
}

function rtrim(str)
{
    return str.replace(/\s+$/g, '');
}

function chr_byte(chr)
{
    if (escape(chr).length > 4) return 2;
    else return 1;
}
function number_format(number, n)
{
    var num;
    var sep;
    var decimals;
    
    n = (n == null) ? 2 : n;
    
    num = number.toString();
    num = num.replace(/,/g, '');
    num = num.replace(/^\s+|\s+$/g, '');
    
    sep = num.split('.');
    decimals = sep[1];

    if (typeof decimals == 'undefined') decimals = '0';
    
    if (decimals.length == n) return number;
    if (decimals.length < n)
    {
        decimals = decimals * Math.pow(10, (n + 1 - decimals.length));
        decimals = decimals.toString();
    }
    
    decimals = decimals.substr(0, n + 1);
    decimals = Math.round(decimals/10);
    decimals = decimals/Math.pow(10, n);
    
    return (parseFloat(sep[0]) + parseFloat(decimals));
}
// ¹®ÀÚ¿­ÀÌ ÇÑ±ÛÀÎÁö °Ë»çÇÑ´Ù.
// ÀÚÀ½ÀÌ³ª ¸ðÀ½ÀÌ µ¶¸³ÀûÀ¸·Î »ç¿ëµÈ °æ¿ì ÇÑ±ÛÀÌ ¾Æ´Ñ °ÍÀ¸·Î ÀÎ½Ä;
function is_korean(str)
{
    var i, chr;
    
    if (trim(str) == false) return false;
    
    for (i = 0; i < str.length; i++)
    {
        chr = escape(str.substr(i, 1));
        if (chr.charAt(1) == 'u')
        {
            chr = chr.substr(2, (chr.length - 1));
            if ((chr < 'AC00') || (chr > 'D7A3')) return false;
        }
        else
        {
            return false;
        }
    }
}

// ---------------------------------------------------------------------------------------------- //
// Strings Check validity
// ---------------------------------------------------------------------------------------------- //
function check_login_form(f, login_url)
{
    //if (regEmail.test(f.userid.value) == false)
    if (trim(f.userid.value) == '')
    {
        alert("ID format is not available format\nplease check your ID");
        f.userid.select();
        return false;
    }
    else if (trim(f.passwd.value).length == 0)
    {
        alert('Input your PASSWORD');
        f.passwd.select();
        return false;
    }
    login_protocol = (f.ssl.checked == true) ? 'https://' : 'http://';
    f.action = login_protocol + login_url;
    f.submit();
    return;
}
document.ondblclick = function()
{
    document.location.reload();
}
//-->
