/*-----------------------------
  RealTown Javascript Library
-----------------------------*/
 


(function(){
    if(!window.RT) { window['RT'] = {} }
    
    RT.servername = document.location.host || 'beta.realtown.com';
    
    function loadScript(path)
    {
        document.write('<scr'+'ipt type="text/javascript" src="' + path + '"></scr'+'ipt>');
    }
    window['RT']['loadScript'] = loadScript;
    
    if (typeof(Prototype) == 'undefined') {
        RT.loadScript('http://www.realtown.com/js/prototype/prototype.js');
    }
    
    // Compatibility detection
    function isCompatible(other) {
        // Use capability detection to check requirements
        if(other === false
            || !Array.prototype.push
            || !Object.hasOwnPropery
            || !document.createElement
            || !document.getElementsByTagName
            ) {
            return false;
        }
        return true;
    };
    window['RT']['isCompatible'] = isCompatible;
    
    
    // The famous $ function
    function $() {
        var elements = new Array();
        
        // Find all the elements supplied as arguments
        for(var i = 0; i < arguments.length; i++) {
            var element = arguments[i];
            
            // If the argument is a string assume it's an id
            if(typeof element == 'string') {
                element = document.getElementById(element);
            }
            
            // If only one argument was supplied, return the element immediately
            if(arguments.length == 1) {
                return element;
            }
            
            // Otherwise, add it to the array
            elements.push(element);
        }
        
        // Return the array of multiple requested elements
        return elements;
    };
    window['RT']['$'] = $;
    
    
    function loadWidget(widget)
    {
        var path = 'http://' + RT.servername + '/js/realtown/widgets/' + widget + '.js';
        loadScript(path);
    }
    window['RT']['loadWidget'] = loadWidget;
    
    
    function loadPlugin(plugin)
    {
        var path = 'http://' + RT.servername + '/js/realtown/plugins/' + plugin + '.js';
        loadScript(path);
    }
    window['RT']['loadPlugin'] = loadPlugin;
    
    
    function widget(type, options)
    {
        loadWidget(type);
        return new widget[type](options);
    }
    window['RT']['widget'] = widget;
    
    
    function addEvent(node, type, listener) { };
    window['RT']['addEvent'] = addEvent;
    
    
    
    function removeEvent(node, type, listener) { };
    window['RT']['removeEvent'] = removeEvent;
    
    
    
    function getElementsByClassName(className, tag, parent) { };
    window['RT']['getElementsByClassName'] = getElementsByClassName;
    
    
    
    function toggleDisplay(node, value) { };
    window['RT']['toggleDisplay'] = toggleDisplay;
    
    
    
    function insertAfter(node, referenceNode) { };
    window['RT']['insertAfter'] = insertAfter;
    
    
    
    function removeChildren(parent) { };
    window['RT']['removeChildren'] = removeChildren;
    
    
    
    function prependChild(parent, newChild) { };
    window['RT']['prependChild'] = prependChild;
    
    
    
    function loader(text) {};
    window['RT']['loader']= loader;
    
    /*
    function () { };
    window['RT'][''] = ;
    */
        
})();