
function px(i){ return i.round() + 'px'; }

// Return a Flash movie suitable for ExternalInterface calls.
function $S(name){ 
    var element = (Prototype.Browser.IE)? window[name] : document[name];
    if(element.length > 0) element = element[1];
    return $(element);
}

Element.addMethods({
    // Insert all items in collection Enumerable into parent element.
    insertCollection: function(element, collection, position){
        element = $(element);
        if(!position) position = 'bottom';
        collection.each(function(item){
            var insertion = {};
            insertion[position] = item;
            this.insert(insertion);
        }, element);
        return element;
    }, 
    
    swapClassName: function(element, from, to){
        return element.removeClassName(from).addClassName(to);
    }
});


Object.extend(Object, {
    merge: function(bottom, top){
        destination = Object.clone(bottom);
        for(var property in top)
            destination[property] = top[property];
        return destination;
    }
});


