ApplyMethods = function( o ) {
    if ( o instanceof Array ) {
        for ( var i = 0, j = o.length; i < j; i++ ) {
            for ( var method in Methods ) {
                o[i][method] = Methods[method];
            }
        }
    } else {
        for ( var method in Methods ) {
            o[method] = Methods[method];
        }
    }
    return o;
}

Methods = {
    addElementMethods: function( jsclass ) {
        
    },
    addEvent: function( e, fn ) {
        if ( this.addEventListener ) {
            this.addEvent = function( e, fn ) {
                return this.addEventListener( e, fn, false );
            }
        } else if ( this.attachEvent ) {
            this.addEvent = function( e, fn ) {
                return this.attachEvent( 'on' + e, fn );
            }            
        }
        return this.addEvent( e, fn );
    },
    getChildrenByClass: function( selector, tag ) {
        var classels = [], els, tag = tag ? tag : '*';
        els = this.getElementsByTagName( tag );
        for ( var i = 0, j = els.length; i < j; i++ ) {
            if ( els[i].className.match( selector ) ) {
                classels.push( els[i] );
            }
        }
        return classels;
    },
    addCssClass: function( css ) {
        if ( !this.className.match( new RegExp( '\s?' + css.trim() + '\s?', 'g' ) ) ) {
            return this.className = this.className.trim() + ' ' + css.trim();
        }
    },
    hasCssClass: function( css ) {
        return ( this.className.match( css.trim() ) );
    },
    removeCssClass: function( css ) {
        if ( this.className.match( new RegExp( '\s?' + css.trim() + '\s?', 'g' ) ) ) {
            return this.className = this.className.trim().replace( css.trim(), '' ).trim();
        }
    }
}
Array.prototype.indexOf = function( o ) {
    for ( var i = 0, j = this.length; i < j; i ++ ) {
        if ( this[i] == o ) {
            var $ = i;
            break;
        }
    }
    return $ ? $ : -1;
}
Array.prototype.lastIndexOf = function( o ) {
    for ( var i = this.length-1; i >= 0; i-- ) {
        if ( this[i] == o ) {
            var $ = i;
        }
        break
    }
    return $ ? $ : -1;
}
String.prototype.trim = function() {
    return this.replace( /^\s*|\s*$/g, '' );
}
