var HashManager = {
    delimiter: '&',
    
    get: function(){
        var hash = location.hash,
            parts = hash.split(this.delimiter),
            len = parts.length,
            res = {};
            
        for(var i = 0; i < len; i++){
            var pieces = parts[i].split('=');
            
            if(pieces[0].test(/^#/)){
                pieces[0] = pieces[0].substring(1);
            }
            
            res[pieces[0]] = pieces[1];
        }
        
        return res;
    },
    
    set: function(key, value){
        var hash = this.get(),
            new_hash = [];
        
        hash[key] = value;
        
        for(var i in hash){
            if(i && hash[i]) new_hash.push(i + '=' + hash[i]);
        }
        
        window.location.hash = new_hash.join(this.delimiter);
        
        return this;
    },
    
    key: function(key){
        return this.get()[key] || false;
    }
};

Element.implement({
    getContent: function(){
        if(this.contentWindow.document){
            return this.contentWindow.document;
        }else if(this.contentDocuement){
            return this.contentDocument;
        }
        
        return this;
    },
    
    getEvents: function(eType) {
        var events = $H(this.retrieve("events"));
        
        if (!events)
            return false;
        
        if (eType) {
            if (events[eType] && events[eType].keys) {
                return events[eType].keys.length;
            }
            
            return false;
        }
        
        return events && events.getLength() ? events.getLength() : false;
    }
});