﻿/// <reference path="jquery-1.4.4.js" type="text/javascript" />
/// <reference path="jquery-1.4.4-vsdoc.js" type="text/javascript" />
function $$(id, context) {
    var el = $("#" + id, context);
    if (el.length < 1) {
        el = $("[id$=_" + id + "]", context);
        
        if (el.length < 1) {
            return null;
        }
    }

    return el;
}

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, "");
};

String.prototype.startsWith = function(str) {
    return (this.match("^" + str) === str);
};

String.prototype.endsWith = function(str) {
    return (this.match(str + "$") === str);
};

Array.prototype.remove = function(name, value) {
    var rest = $.grep(this, function(item) {
        if (typeof item[name] === 'function') {
            return (item[name]() !== value);
        }
        else {
            return (item[name] !== value); // <- no strict equality
        }
    });

    this.length = 0;
    this.push.apply(this, rest);
    return this; // <- This seems like a jQuery-ish thing to do but is optional
};
