//String helper
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }

// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};

function setFlashMessage(msg, timeout, container) {
    container = container || "flash";
    if (timeout < 0) timeout = 4000;
    if (container.constructor == String) {
        container = "#" + container;
    }
    $(container).attr("innerHTML", msg).fadeIn("fast");
    if (timeout > 0) {
        setTimeout(function() { $(container).fadeOut("slow"); }, timeout);
    }
}
