﻿String.prototype.wrapSearchTerm = function(searchTerm, htmlElementType) {

    var regex = new RegExp("(^|[ ])" + searchTerm, "i");
    var result = regex.exec(this);

    if (result != null)
        return this.replace(regex, "<" + htmlElementType + ">" + result[0] + "</" + htmlElementType +">");

    return this;

}

jQuery.extend({
    random: function(X) {
        return Math.floor(X * (Math.random() % 1));
    },
    randomBetween: function(MinV, MaxV) {
        return MinV + jQuery.random(MaxV - MinV + 1);
    }
});

/*
jQuery Url Plugin
* Version 1.0
* 2009-03-22 19:30:05
* URL: http://ajaxcssblog.com/jquery/url-read-get-variables/
* Description: jQuery Url Plugin gives the ability to read GET parameters from the actual URL
* Author: Matthias Jäggli
* Copyright: Copyright (c) 2009 Matthias Jäggli under dual MIT/GPL license.
*/
(function($) {
    $.url = {};
    $.extend($.url, {
        _params: {},
        init: function() {
            var paramsRaw = "";
            try {
                paramsRaw =
					(document.location.href.split("?", 2)[1] || "").split("#")[0].split("&") || [];
                for (var i = 0; i < paramsRaw.length; i++) {
                    var single = paramsRaw[i].split("=");
                    if (single[0])
                        this._params[single[0]] = unescape(single[1]);
                }
            }
            catch (e) {
                alert(e);
            }
        },
        param: function(name) {
            return this._params[name] || "";
        },
        paramAll: function() {
            return this._params;
        }
    });
    $.url.init();
})(jQuery);

