    /**
     * Lenchyo Framework for Javascript
     *
     * Lenchyo Framework Development Project 2007-2009
     *
     * @author Kim Dong-Hyeon (kdh0107@gmail.com)
     * @character encode UTF-8
     *
     * @copyright Kim Dong-Hyeon (mail : kdh0107@gmail.com, website : http://lenchyo.com) All rights reserved.
     * @Republic of Korea (ROK)
     *
     * --- Update log ---
     * 1.3.6 - Changing css style declaration. (2009-03-29)
     * 1.3.7 - Add event variable. (2009-04-09)
     * 1.3.8 - setSubmit method modify (2009-04-15)
     * 1.3.9 - getStyle method modify (2009-04-15)
     * 1.4.0 - Add method - web.getFile (2009-04-27)
     * 1.4.1 - Add function sourceEncode, sourceDecode (2009-04-30)
     */

    var lenchyo = {
        pgVersion : '1.4.2' ,
        pgVersionArr : null ,
        pgName : 'Lenchyo Framework for Javascript' ,
        powered : null ,
        checkVersion : function(verStr) {
            var tempVer = verStr.split('.');
            for(var idx = 0; idx < tempVer.length; idx++) {
                if(tempVer[idx].toInt() > lenchyo.pgVersionArr[idx].toInt()) {
                    return true;
                } else if((idx + 1) == lenchyo.pgVersionArr.length && tempVer[idx].toInt() == lenchyo.pgVersionArr[idx].toInt()) {
                    return true;
                }
            }
            return false;
        }
    };
    lenchyo.pgVersionArr = lenchyo.pgVersion.split('.');

    var Ajax = function(setting) {
        this.url = null;
        this.ready = false;
        this.method = null;
        this.xmlHttp = null;
        this.completeFunction = null;
        this.errorFunction = null;
        this.resultText = null;
        this.resultXml = null;


        this.recycle = function(dataList) {
            return this.setData(dataList);
        };

        this.setData = function(dataList) {
            try {
                for(var idx in dataList) {
                    switch(idx) {
                        case 'url' :
                            this.url = dataList[idx];
                            break;
                        case 'method' :
                            this.method = dataList[idx];
                            this.open(dataList[idx]);
                            break;
                        case 'return' :
                        case 'call' :
                            this.setFunction(dataList[idx]);
                            break;
                        case 'error' :
                            this.setErrorFunction(dataList[idx]);
                            break;
                    }
                }
            } catch(e) {}
        };

        this.Initialize = function() {
            try {
                this.xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch(e) {
                try {
                    this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch(oc) {
                    this.xmlHttp = null;
                }
            }
            if(!this.xmlHttp && typeof XMLHttpRequest != "undefined") this.xmlHttp = new XMLHttpRequest();
            if(this.xmlHttp != null) this.ready = true;
        };

        this.autoReady = function() {
            if(this.xmlHttp == null) this.Initialize();
        };

        this.setFunction = function(func) {
            var pointer = this;
            this.autoReady();
            this.completeFunction = func;
            this.xmlHttp.onreadystatechange = function() { pointer.trueRun(); };
        };

        this.setErrorFunction = function(func) {
            this.errorFunction = func;
        };

        this.open = function(method, ajaxType) {
            this.autoReady();
            this.xmlHttp.open(method.toUpper(), this.url, true);
            if(method.toUpper() == 'POST') this.xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        };

        this.send = function(parameters) {
            this.autoReady();
            if(!this.url || this.url == null) return;
            this.xmlHttp.send(parameters);
        };

        this.trueRun = function() {
            if(this.xmlHttp.readyState == 4) {
                switch(this.xmlHttp.status) {
                    case 200 :
                        try {
                            this.resultText = this.xmlHttp.responseText;
                            this.resultXml = this.xmlHttp.responseXML;
                            this.completeFunction({string : this.resultText, xml : this.resultXml});
                        } catch(e) {
                            this.resultText = this.xmlHttp.responseText;
                            this.resultXml = this.xmlHttp.responseXML;
                        }
                        break;
                    default :
                        try {
                            this.resultText = this.xmlHttp.responseText;
                            this.resultXml = this.xmlHttp.responseXML;
                            this.errorFunction(this.xmlHttp.status, {string : this.resultText, xml : this.resultXml});
                        } catch(e) {
                            alert('Ajax Error : code [' + this.xmlHttp.status + ']');
                        }
                        break;
                }
            }
        };

        this.setData(setting);
    };

    var form = function(formName) {
        this.formObj = $f(formName);

        this.getValue = function(itemName) {
            return this.get(itemName).value;
        };

        this.setValue = function(itemName, setVal) {
            return this.get(itemName).value = setVal;
        };

        this.isValue = function(itemName) {
            try {
                var itemValue = this.get(itemName).value.replaceAll(' ', '');
                if(itemValue) return true;
            } catch(e) {
                return false;
            }
        };

        this.isReg = function(itemName, pattern) {
            try {
                var temp = this.getValue(itemName).replaceAll(pattern, '');
                if(temp) return false; else return true;
            } catch(e) {
                return false;
            }
        };

        this.tidyValue = function(itemName) {
            if(!this.isValue(itemName)) return;
            var temp = this.getValue(itemName);
            temp = temp.trim();
            this.setValue(itemName, temp);
        };

        this.tidyValues = function(itemList) {
            for(var idx = 0; idx < itemList.length; idx++) this.tidyValue(itemList[idx]);
        };

        this.safeValue = function(itemName) {
            if(!this.isValue(itemName)) return;
            var temp = this.getValue(itemName);
            temp = temp.stripTags();
            temp = temp.trim();
            temp = temp.replaceAll("<", "&lt;");
            temp = temp.replaceAll(">", "&gt;");
            temp = temp.replaceAll("\"", "&quot;");
            this.setValue(itemName, temp);
        };

        this.safeValues = function(itemList) {
            for(var idx = 0; idx < itemList.length; idx++) this.safeValue(itemList[idx]);
        };

        this.setEncode = function(itemName) {
            try {
                this.setValue(itemName, escape(this.getValue(itemName)));
            } catch(e) {}
        };

        this.setEncodes = function(itemList) {
            for(var idx = 0; idx < itemList.length; idx++) this.setEncode(itemList[idx]);
        };

        this.setDecode = function(itemName) {
            try {
                this.setValue(itemName, unescape(this.getValue(itemName)));
            } catch(e) {}
        };

        this.setDecodes = function(itemList) {
            for(var idx = 0; idx < itemList.length; idx++) this.setEncode(itemList[idx]);
        };

        this.getLength = function(itemName) {
            if(!this.isValue(itemName)) return;
            try {
                return this.getValue(itemName).length;
            } catch(e) {
                return null;
            }
        };

        this.setMethod = function(method) {
            this.formObj.method = method;
        };

        this.setAction = function(url) {
            this.formObj.action = url;
        };

        this.setTarget = function(target) {
            this.formObj.target = target;
        };

        this.submit = function() {
            this.formObj.submit();
        };

        this.reset = function() {
            this.formObj.reset();
        };

        this.get = function(itemName) {
            if(!itemName) return this.formObj;
            return eval('this.formObj.' + itemName);
        };

        this.getForm = function() {
            return this.formObj;
        };

        this.disableItem = function(itemName) {
            var obj = this.get(itemName);
            obj.disabled = true;
        };

        this.enableItem = function(itemName) {
            var obj = this.get(itemName);
            obj.disabled = false;
        };

        this.setReadOnly = function(itemName, bValue) {
            var obj = this.get(itemName);
            obj.readOnly = (!bValue ? false : bValue);
        };

        this.focus = function(itemName) {
            try {
                this.get(itemName).focus();
            } catch(e) {}
        };

        this.select = function(itemName) {
            try {
                this.get(itemName).select();
            } catch(e) {}
        };

        this.setFileTrans = function() {
            this.setEntype('multipart/form-data');
        };

        this.setEntype = function(type) {
            this.get().encoding = type;
        };

        this.setSubmit = function(func) {
            if(isIE()) {
                try {
                    var frm = this.get();
                    eval("Event.setEvent(frm, 'submit', "+func+")");
                } catch(e) {}
            } else {
                try {
                    this.get().setAttribute('onsubmit', 'return '+func+'()');
                } catch(e) {}
            }
        };
    };

    var object = function(obj) {
        this.setObj = element.isElement(obj) ? obj : $(obj);
        this.isOpener = function() {
            if(opener != null) return true; else return false;
        };

        this.isParent = function() {
            if(parent != null) return true; else return false;
        };

        this.getTop = function() {
            var sTop = 0;
            var pObj = this.get().offsetParent;
            while(pObj != null && pObj != 'undefined') {
                sTop += getRealOffsetTop(pObj).toInt();
                if(typeof pObj.offsetParent != 'object') {
                    break;
                } else {
                    try {
                        pObj = pObj.offsetParent;
                    } catch(e) {
                        break;
                    }
                }
            }
            return getRealOffsetTop(this.get()) + sTop;
        };

        this.getLeft = function() {
            var sLeft = 0;
            var pObj = this.get().offsetParent;
            while(pObj != null && pObj != 'undefined') {
                sLeft += getRealOffsetLeft(pObj).toInt();
                if(typeof pObj.offsetParent != 'object') {
                    break;
                } else {
                    try {
                        pObj = pObj.offsetParent;
                    } catch(e) {
                        break;
                    }
                }
            }
            return getRealOffsetLeft(this.get()) + sLeft;
        };

        this.getWidth = function() {
            return this.get().offsetWidth;
        };

        this.getHeight = function() {
            return this.get().offsetHeight;
        };

        this.setTop = function(size) {
            try {
                intSize = size.toInt();
                this.setStyle('top', intSize.toString() + 'px');
            } catch(e) {
                this.setStyle('top', size);
                return;
            }
        };

        this.setLeft = function(size) {
            try {
                intSize = size.toInt();
                this.setStyle('left', intSize.toString() + 'px');
            } catch(e) {
                this.setStyle('left', size);
                return;
            }
        };

        this.setHeight = function(size) {
            try {
                var intSize = size.toInt();
                this.get().style.height = intSize.toString() + 'px';
            } catch(e) {
                this.get().style.height = size;
                return;
            }
        };

        this.setWidth = function(size) {
            try {
                var intSize = size.toInt();
                this.get().style.width = intSize.toString() + 'px';
            } catch(e) {
                this.get().style.width = size;
                return;
            }
        };

        this.setOpacity = function(opacity) {
            try {
                if(!opacity.toString().isNum()) {
                    return;
                }
                if(parseInt(opacity, 10) < 0 || parseInt(opacity, 10) > 100) {
                    return;
                }
                if(isIE()) {
                    this.get().style.filter = 'progid:DXImageTransform.Microsoft.alpha(opacity=' + opacity + ');';
                } else {
                    this.get().style.opacity = (opacity * 0.01);
                }
            } catch(e) {
                return;
            }
        };

        this.setBg = function(color) {
            this.get().style.background = color;
        };

        this.sameSize = function(oriObj) {
            var temp = new object(oriObj);
            this.setTop(temp.getTop());
            this.setLeft(temp.getLeft());
            this.setWidth(temp.getWidth());
            this.setHeight(temp.getHeight());
        };

        this.get = function() {
            return this.setObj;
        };

        this.setStyle = function(attribute, value) {
            try {
                if(!attribute) {
                    return;
                } else {
                    var obj = this.get();
                    if(value) {
                        eval('obj.style.' + convertStyle(attribute) + ' = value');
                    } else {
                        eval('obj.style.' + convertStyle(attribute) + " = ''");
                    }
                }
            } catch(e) {
                return;
            }
        };

        this.setStyles = function(attributes, values) {
            try {
                for(var att in attributes) {
                    if(typeof attributes[att] != 'string') { continue; }
                    this.setStyle(convertStyle(att) , attributes[att]);
                }
            } catch(e) {}
        };

        this.getStyle = function(attribute) {
            attribute = convertStyle(attribute);
             try {
                 return this.get().currentStyle.getAttribute(attribute);
             } catch(e) {
                 try {
                    return document.defaultView.getComputedStyle(this.get(), '').getPropertyValue(attribute);
                 } catch(e) {
                     return null;
                 }
             }
        };

        this.hidden = function() {
            this.get().style.display = 'none';
        };

        this.show = function(type) {
            if(type) {
                this.get().style.display = type;
            } else {
                this.get().style.display = 'inline';
            }
        };

        this.disable = function() {
            try {
                this.get().disabled = true;
            } catch(e) {
                return;
            }
        };

        this.endable = function() {
            try {
                this.get().disabled = false;
            } catch(e) {
                return;
            }
        };

        this.setReadOnly = function(boolValue) {
            try {
                this.get().readOnly = boolValue;
            } catch(e) {
                return;
            }
        };

        this.print = function(str) {
            try {
                this.get().innerHTML = str;
            } catch(e) {
                return;
            }
        };

        this.printAppend = function(str) {
            try {
                this.get().innerHTML += str;
            } catch(e) {
                return;
            }
        };

        this.getContentType = function(attribute) {
            var tempContenttype = this.getAttribute('contenttype');
            if(!tempContenttype || tempContenttype == '') {
                return '';
            }
            if(!attribute) {
                return tempContenttype.trim();
            }
            var tempSplit = tempContenttype.split(';');
            for(var idx = 0; idx < tempSplit.length; idx++) {
                if(!tempSplit[idx]) {
                    break;
                }
                var temp = tempSplit[idx].split(':');
                if(temp[0].trim() == attribute.trim()) {
                    return temp[1].trim();
                }
            }
            return null;
        };

        this.getAttribute = function(attribute) {
            try {
                return this.get().getAttribute(attribute);
            } catch(e) {
                alert('Exception : %s'.replacereplaceMatch(e.toString()));
                return '';
            }
        };

        this.setAttribute = function(attribute, value) {
            this.get().setAttribute(attribute, value);
        };

        this.setValue = function(value) {
            try {
                this.get().value = value;
            } catch(e) {
                return false;
            }
        };

        this.getValue = function() {
            try {
                return this.get().value;
            } catch(e) {
                return null;
            }
        };

        this.getText = function() {
            try {
                return this.get().innerHTML;
            } catch(e) {
                return null;
            }
        };
    };

    var StringBuffer = function() {
        this.resultStr = new Array();

        this.append = function(str) {
            if(!str) {
                return;
            }
            this.resultStr.push(str.toString());
        };

        this.toString = function() {
            return this.resultStr.join('');
        };
    };

    var StringTokenizer = function(str, pattern) {
        this.str = str;
        this.pattern = pattern;
        this.tempStr = str.split(pattern);
        this.idx = 0;

        this.size = function() {
            return this.tempStr.length;
        };

        this.nextToken = function() {
            try {
                var temp = this.tempStr[this.idx];
                this.idx++;
                return temp;
            } catch(e) {
                return false;
            }
        };

        this.hasMoreTokens = function() {
            if(typeof this.tempStr[this.idx] != 'undefined') {
                return true;
            } else {
                return false;
            }
        };

        this.reset = function() {
            this.idx = 0;
        };
    };

    var Vector = function() {
        this.vectorElement = new Array();
        this.temp = null;

        this.addElement = function(obj) {
            if(!obj) {
                return;
            }
            this.vectorElement.push(obj);
        };

        this.elementAt = function(idx) {
            try {
                if(this.vectorElement[idx - 1] != null) {
                    return this.vectorElement[idx - 1];
                }
                return null;
            } catch(e) {
                return;
            }
        };

        this.insertElementAt = function(obj, idx) {
            if(!obj || !idx) {
                return;
            }
            this.vectorElement[idx] = obj;
        };

        this.firstElement = function() {
            return this.elementAt(1);
        };

        this.lastElement = function() {
            return this.elementAt(this.size());
        };

        this.getSize = function() {
            return this.vectorElement.length;
        };

        this.find = function(obj) {
            var cnt = this.getSize();
            for(var idx = 1; idx <= cnt; idx++) {
                if(obj == this.elementAt(idx)) {
                    return cnt;
                }
            }
            return 0;
        };

        this.remove = function(obj) {
            this.temp = new Array();
            for(var idx = 1; idx <= this.getSize(); idx++) {
                if(this.elementAt(idx) != obj) {
                    this.temp.push(this.elementAt(idx));
                } else {}
            }
            this.vectorElement = this.temp;
        };
    };

    var Event = {
        setEvent : function(obj, event, callback) {
            try {
                if(obj.addEventListener) var setElementEvent = obj.addEventListener(event, callback, false); else var setElementEvent = obj.attachEvent("on" + event, callback);
                return setElementEvent;
            } catch(e) {
                return null;
            }
        } ,
        getElement : function(evt) {
            if(!evt.target) return evt.srcElement;
            return evt.target;
        }
        ,lo: 'load'
        ,ul: 'unload'
        ,mOver: 'mouseover'
        ,mOut: 'mouseout'
        ,md: 'mousedown'
        ,mu: 'mouseup'
        ,mm: 'mousemove'
        ,fo: 'focus'
        ,bl: 'blur'
        ,ch: 'change'
        ,cl: 'click'
        ,dc: 'dbclick'
        ,se: 'select'
        ,kd: 'keydown'
        ,ku: 'keyup'
        ,kp: 'keypress'
        ,mv: 'move'
        ,re: 'resize'
        ,er: 'error'
    };

    var _window = {
        getHeight : function() {
            if(isIE()) return document.documentElement.offsetHeight;
            return window.innerHeight;
        } ,
        getWidth : function() {
            if(isIE()) return document.documentElement.offsetWidth;
            return window.innerWidth;
        }
    };

    var element = {
        create : function(tag) {
            var tempObj = document.createElement(tag);
            document.body.appendChild(tempObj);
            return tempObj;
        } ,
        createAt : function(parent, tag) {
            var tempObj = document.createElement(tag);
            parent.appendChild(tempObj);
            return tempObj;
        } ,
        writeAttribute : function(obj, attribute, value) {
            if(obj != null) obj.setAttribute(attribute, value);
        } ,
        readAttribute : function(obj, attribute) {
            if(obj != null) return obj.getAttribute(attribute);
        } ,
        isElement : function(obj) {
            if(typeof obj == 'object') return true; else return false;
        }
    };

    var web = {
        encodeUrl : function(str) {
            return encodeURI(str);
        } ,
        decodeUrl : function(str) {
            return decodeURI(str);
        } ,
        encodeUrlC : function(str) {
            return encodeURIComponent(str);
        } ,
        decodeUrlC : function(str) {
            return decodeURIComponent(str);
        } ,
        getTrueUrl : function() {
            var temp = document.location.href.split('?');
            return temp[0];
        } ,
        getDomain : function() {
            var temp = this.getTrueUrl().replaceAll('http://', '').split('/');
            return 'http://%s'.replaceMatch(temp[0]);
        } ,
        getFile: function() {
            try {
                var temp = this.getTrueUrl().replaceAll('http://', '').split('/');
                return temp[temp.length - 1];
            } catch(e) {
                return '';
            }
        } ,
        redirect : function(url) {
            if(!url.trim()) return;
            document.location.href = url.trim();
        } ,
        moveBack : function() {
            history.back(-1);
        } ,
        refresh : function() {
            try {
                document.location.reload();
            } catch(e) {
                this.redirect(document.location.href);
            }
        }
    };

    var request = {
        parameterHeads : new Array() ,
        parameters : new Object() ,
        catchParameters : function() {
            var temp = document.location.href.replaceAll("#.*", '').split('?');
            if(temp.length > 1) {
                temp = temp[1].split('&');
                for(var i = 0; i < temp.length; i++) {
                    var pTemp = temp[i].split('=');
                    this.parameters[pTemp[0]] = pTemp[1];
                    this.parameterHeads[i] = pTemp[0];
                }
            }
        } ,
        getParameter : function(pName) {
            if(this.parameterHeads.length == 0) this.catchParameters();
            try {
                if(!this.parameters[pName]) return null;
                return this.parameters[pName];
            } catch(e) {
                return null;
            }
        } ,
        getParameterHeader : function() {
            if(this.parameterHeads.length == 0) this.catchParameters();
            return this.parameterHeads;
        }
    };

    var cookie = {
        setAttribute : function(name, value, expires, path, domain, secure) {
            var argv = this.setAttribute.arguments;
            var argc = this.setAttribute.arguments.length;
            var expires = (2 < argc) ? argv[2] : null;
            var path = (3 < argc) ? argv[3] : null;
            var domain = (4 < argc) ? argv[4] : null;
            var secure = (5 < argc) ? argv[5] : false;
            document.cookie = name + '=' + escape(value) + ((expires == null) ? '' : ('; expires=' + expires.toGMTString())) + ((path == null) ? '' : ('; path=' + path)) + ((domain == null) ? '' : ('; domain=' + domain)) + ((secure == true) ? '; secure' : '');
        } ,
        getAttribute : function(name) {
            var endOfCookie = null;
            var x = null;
            var nameOfCookie = name + '=';

            for(var i = 0; i < document.cookie.length; i++) {
                var y = (x + nameOfCookie.length);
                if(document.cookie.substring(x, y) == nameOfCookie) {
                    if((endOfCookie = document.cookie.indexOf(';', y)) == -1) {
                        endOfCookie = document.cookie.length;
                    }
                    return unescape(document.cookie.substring(y, endOfCookie));
                }
                x = document.cookie.indexOf(' ', x) + 1;
                if(x == 0) {
                    break;
                }
            }
            return '';
        }
    };

    var System = {
        getBrowser : navigator.appName ,
        getBrowserShort : navigator.appName.charAt(0) ,
        getBrowserVersion : navigator.appVersion ,
        getBrowserPlatform : navigator.platform ,
        getBrowserAgent : navigator.userAgent ,
        getLanguage : navigator.browserLanguage ,
        out : {
            print : function(str) {
                document.body.innerHTML += str;
            } ,
            println : function(str) {
                document.body.innerHTML += str + "\n";
            }
        } ,
        setData : function(fName, fData) {
            System.tempDataObject[fName] = fData;
        } ,
        getData : function(fName) {
            if(typeof System.tempDataObject[fName] == 'undefined') {
                return '';
            }
            return System.tempDataObject[fName];
        } ,
        tempDataObject : new Object()
    };

    var $ = function(objID) {
        return document.getElementById(objID);
    };

    var $n = function(objName) {
        return document.getElementsByName(objName);
    };

    var $t = function(tagName) {
        return document.getElementsByTagName(tagName);
    };

    var $c = function(cn, tn) {
        if(!tn) { tn = '*'; }
        if(!isIE()) { return document.getElementsByClassName(cn); }
        var returnObj = new Array();
        var objs = $t(tn);
        for(var idx = 0; idx < objs.length; idx++) {
            if(objs[idx].className == cn) {
                returnObj.push(objs[idx]);
            }
        }
        return returnObj;
    };

    var $f = function(formName) {
        if(System.getBrowserShort == 'M') {
            return document.forms(formName);
        } else {
            return eval('document.%s'.replaceMatch(formName));
        }
    };

    var $$ = function(objID, parent, tagName, param) {
        var returnObj = $(objID);
        if(returnObj == null) {
            parent = (parent ? parent : (document.body || document.documentElement));
            var tempObj = document.createElement((tagName ? tagName : 'div'));
            element.writeAttribute(tempObj, 'id', objID);
            if(param) {
                for(var key in param) {
                    if(typeof param[key] == 'string') {
                        element.writeAttribute(tempObj, key, param[key]);
                    }
                }
            }
            parent.appendChild(tempObj);
            return $(objID);
        }
        return returnObj;
    };

    var setPng24 = function(obj) {
        obj.width = obj.height = 1;
        obj.className = obj.className.replace(/\bpng24\b/i,'');
        obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='%s',sizingMethod='image');".replaceMatch(obj.src);
        obj.src = '';
        return '';
    };

    var getEvent = function(event) {
        if(!event) {
            event = window.event;
            event.target = event.srcElement;
        }
        return event;
    };

    var randomStr = function(length) {
        if(!length || length == 0) {
            length = 1;
        }
        var rndStr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
        var rndCnt = rndStr.length;
        var rndResult = new StringBuffer();
        for(var step = 0; step < length; step++) {
            var rndIdx = Math.floor(Math.random() * rndCnt);
            var isUpper = Math.floor(Math.random() * 2);
            rndResult.append(((isUpper == 1) ? rndStr[rndIdx].toUpper() : rndStr[rndIdx]));
        }
        return rndResult.toString();
    };

    var getRealOffsetLeft = function(obj) {
        return obj.offsetLeft;
    };

    var getRealOffsetTop = function(obj) {
        return obj.offsetTop;
    };

    var replaceAll = function(str, pattern, restr) {
        var strTemp = str;
        strTemp.replace(new RegExp(pattern, "g"), restr);
        return strTemp.replace(new RegExp(pattern, "g"), restr);
    };

    var convertStyle = function(attribute) {
        try {
            var arr = attribute.split('-');
            var sb = new StringBuffer();
            for(var indx = 0; indx < arr.length; indx++) {
                if(indx > 0) {
                    sb.append(getFUpper(arr[indx]));
                    continue;
                }
                sb.append(arr[0]);
            }
            return sb.toString();
        } catch(e) { return ''; }
    };

    var getFUpper = function(str) {
        return str.charAt(0).toUpper()+str.substring(1, str.length);
    };

    var evalEx = function(str) {
        return (new Function('', 'return ' + str + ';'))();
    };

    var isIE = function() {
        return (System.getBrowserShort == 'M' ? true : false);
    };

    var sourceEncode = function(str) {
        eval(unescape("var%20_source%3Dstr%3Bfor%28var%20kandl%3D0%3B%20kandl%20%3C%205%3B%20kandl++%29%20_source%20%3D%20escape%28_source%29%3B"));
        return _source;
    };

    var sourceDecode = function(source) {
        eval(unescape("var%20_source%3Dsource%3Bfor%28var%20kandl%3D0%3B%20kandl%20%3C%205%3B%20kandl++%29%20_source%20%3D%20unescape%28_source%29%3B"));
        return _source;
    };

    String.prototype.fill = function(pattern, count) {
        try {
            var item = new Array();
            item.push(this);
            for(var idx = 0; idx < count; idx++) {
                item.push(pattern);
            }
            return item.join('');
        } catch(e) {
            return this;
        }
    };

    String.prototype.replaceAll = function(pattern, str) {
        var strTemp = this;
        strTemp.replace(new RegExp(pattern, "g"), str);
        return strTemp.replace(new RegExp(pattern, "g"), str);
    };

    String.prototype.trim = function() {
        return this.replace(/^\s*/, '').replace(/\s*$/, '');
    };

    String.prototype.isTrueChar = function() {
        var strTemp = this.replaceAll('[°¡-ÆRa-zA-Z0-9]', '');
        if(strTemp) {
            return false;
        } else {
            return true;
        }
    };

    String.prototype.isHangul = function() {
        var strTemp = this.replaceAll('[°¡-ÆR]', '');
        if(strTemp) {
            return false;
        } else {
            return true;
        }
    };

    String.prototype.isAlphabet = function() {
        var strTemp = this.replaceAll('[a-zA-Z]', '');
        if(strTemp) {
            return false;
        } else {
            return true;
        }
    };

    String.prototype.isNum = function() {
        if(this.replaceAll("[0-9]", '')) {
            return false;
        }
        return true;
    };

    String.prototype.isFloat = function() {
        if(this.replaceAll("([0-9]|[.])", '')) {
            return false;
        }
        return true;
    };

    String.prototype.numberFormat =  function() {
        if(!this.isNum()) {
            return 0;
        }
        return this.replace(/(\d)(?=(?:\d{3})+(?!\d))/g, '$1,');
    };

    String.prototype.stripTags = function() {
        return replaceAll(this, "<[^>]*>", '');
    };

    String.prototype.stripTagList = function(removeTagList) {
        try {
            var removeTags = removeTagList.join('|');
            alert(removeTags);
            return replaceAll(this, "<[ ]*[\/]*[ ]*[{%s}][^>]*>".replaceMatch(removeTags), '');
        } catch(e) {
            return null;
        }
    };

    String.prototype.replaceTags = function() {
        var temp = replaceAll(this, '&', '&amp;');
        temp = replaceAll(temp, '<', '&lt;');
        temp = replaceAll(temp, '>', '&gt;');
        return temp;
    };

    String.prototype.nl2br = function() {
        var temp = this.split("\n");
        var result = '';
        for(var i = 0; i < temp.length; i++) {
            result += temp[i];
            if(i != (temp.length -1)) {
                result += "<br />";
            }
        }
        return result;
    };

    String.prototype.br2nl = function() {
        return this.replaceAll("<[ ]*[b|B][r|R][ ]*[/]*>", "\n");
    };

    String.prototype.toUpper = function() {
        return this.toUpperCase();
    };

    String.prototype.toLower = function() {
        return this.toLowerCase();
    };

    String.prototype.toReverse = function() {
        var idx = this.length;
        var tempStr = new StringBuffer();
        while(idx >= 0) {
            tempStr.append(this.substr(idx, 1));
            idx--;
        }
        return tempStr.toString();
    };

    String.prototype.replaceMatch = function() {
        var args = arguments;
        if(args.length == 0) return this;
        var idx = 0;
        return this.replace(/%([s|S|f|d|x|X|o])/g, function __tmpleplace(pattern, type, arg, str) {
            if(idx >= args.length) return '%' + type;
            switch(type) {
                case 's' : return args[idx++].toString(); break;
                case 'S' : return args[idx++].toString().toUpper(); break;
                case 'd' : return args[idx++].toInt(); break;
                case 'f' : return args[idx++].toFloat(); break;
                case 'x' : return args[idx++].toInt().toString(16); break;
                case 'X' : return args[idx++].toInt().toString(16).toUpper(); break;
                case 'o' : return args[idx++].toInt().toString(8); break;
            }
        });
    };

    String.prototype.left = function(len) {
        try {
            return this.toString().substr(0, len);
        } catch(e) {
            return '';
        }
    };

    String.prototype.right = function(len) {
        try {
            return this.toString().substr((this.length - len.toInt()), len);
        } catch(e) {
            return '';
        }
    };

    String.prototype.isPhoneNumber = function() {
        try {
            if(this.replace(/(^0[1-7][0-9]|02)([-]*)([0-9][0-9][0-9][0-9]|[0-9][0-9][0-9])([-]*)([0-9][0-9][0-9][0-9])/g, '')) {
                return false;
            }
            return true;
        } catch(e) {
            return false;
        }
    };

    String.prototype.isReg = function(pattern) {
        try {
            var temp = this.replaceAll(pattern, '');
            if(!temp) {
                return true;
            } else {
                return false;
            }
        } catch(e) {
            return false;
        }
    };

    String.prototype.cut = function(length) {
        var tempStr = this;
        var len = 0;
        for (var i=0; i<tempStr.length; i++) {
            len += (tempStr.charCodeAt(i) > 128) ? 2 : 1;
            if(len > length) {
                return tempStr.substring(0,i);
            }
        }
        return tempStr;
    };

    String.prototype.isSpam = function(spamWordList, spamFilterCnt) {
        if(!spamFilterCnt) {
            spamFilterCnt = 3;
        }
        try {
            var tempStr = this.replaceAll('[^°¡-ÆRa-zA-Z]', '');
            var detectCnt = 0;
            for(var idx = 0; idx < spamWordList.length; idx++) {
                if(tempStr.indexOf(spamWordList[idx]) >= 0) {
                    detectCnt++;
                }
            }
            alert(detectCnt);
            if(spamFilterCnt <= detectCnt) {
                return true;
            }
            return false;
        } catch(e) {
            return false;
        }
    };

    String.prototype.toByte = function() {
        var totalLength = 0;
        for(var i = 0; i < this.length; i++) {
            var temp = this.charAt(i);
            if(escape(temp).length > 4) {
                totalLength += 2;
            } else {
                totalLength++;
            }
        }
        return totalLength;
    };

    Object.prototype.toInt = function() {
        try {
            var temp = this.replaceAll("^[0]+", '');
            return parseInt((temp ? temp : '0'));
        } catch(e) {
            return parseInt(this);
        }
    };

    Object.prototype.toFloat = function() {
        return parseFloat(this);
    };

    Object.prototype.isArray = function() {
        return (typeof this.length == 'undefined') ? false : true;
    };

    Event.setEvent(window, 'load', function() {
        System.tempDataObject = new Object();
        System.setData('loadingComplete', true);
    });

    window.onload = function() {
        try {
            eval('Initialize()');
        } catch(e) {}
    };

    Event.setEvent(window, 'load', function() {
        lenchyo.powered = new object($$(randomStr(32)));
        var powered = lenchyo.powered;
        var tempTop = (document.body.scrollTop == 0 ? document.documentElement.scrollTop : document.body.scrollTop);
        powered.setOpacity(3);
        var attributes = {
            'letter-spacing' : '0px' ,
            'cursor' : 'pointer' ,
            'position' : 'absolute' ,
            'border' : '1px solid #E0DE8F' ,
            'background' : '#F3EEC1' ,
            'padding' : '10px' ,
            'color' : '#00A5EE' ,
            'font-family' : 'Verdana' ,
            'font-weight' : 'bold' ,
            'font-size' : '9pt' ,
            'z-index' : '100'
        };
        powered.setStyles(attributes);
        powered.setTop(tempTop + 10);
        powered.setLeft(10);
        powered.hidden();
        powered.printAppend("Powered by <u>L</u>enchyo fram<u>E</u>work for <u>J</u>avascript"+lenchyo.pgVersion);
        Event.setEvent(powered.get(), 'click', function(e) {
            clearTimeout(System.getData('tempInterval'));
            lenchyo.powered.hidden();
            System.setData('poweredShow', false);
        });
        Event.setEvent(powered.get(), 'mouseover', function(e) {
            lenchyo.powered.setOpacity(50);
            clearTimeout(System.getData('tempInterval'));
        });
        Event.setEvent(powered.get(), 'mouseout', function(e) {
            var tempInterval = setTimeout(function() {
                clearTimeout(System.getData('tempInterval'));
                lenchyo.powered.hidden();
                System.setData('poweredShow', false);
            }, 5000);
            System.setData('tempInterval', tempInterval);
            lenchyo.powered.setOpacity(3);
        });
    });

    Event.setEvent(document.documentElement, 'keydown', function(e) {
        try {
            var evt = getEvent(e);
            switch(e.keyCode) {
                case 220 :
                    if(e.ctrlKey && e.altKey) {
                        try {
                            if(System.getData('poweredShow') == true) {
                                lenchyo.powered.hidden();
                                System.setData('poweredShow', false);
                                return;
                            }
                            lenchyo.powered.show('block');
                            clearTimeout(System.getData('tempInterval'));
                            var tempInterval = setTimeout(function() {
                                clearTimeout(System.getData('tempInterval'));
                                lenchyo.powered.hidden();
                                System.setData('poweredShow', false);
                            }, 5000);
                            System.setData('tempInterval', tempInterval);
                            System.setData('poweredShow', true);
                        } catch(e) {}
                    }
                    break;
            }
        } catch(e) {}
    });

    Event.setEvent(window, 'scroll', function(e) {
        try {
            var powered = lenchyo.powered;
            var tempTop = (document.body.scrollTop == 0 ? document.documentElement.scrollTop : document.body.scrollTop);
            powered.setTop(tempTop + 10);
        } catch(e) {}
    });
