﻿String.prototype.QueryStringToObject = 
function()
{
    return convertToObject(this, "&", "=");
}

String.prototype.ParamsToObject = 
function()
{
    return convertToObject(this, ";", "=");
}

function convertToObject(str, strPairDelim, strNameValDelim)
{
    var rePairDelimHead = new RegExp("^" + strPairDelim);
    var rePairDelim = new RegExp(strPairDelim, "g");
    var reNameValDelim = new RegExp(strNameValDelim, "g");
    
    return eval("({" + str.replace(rePairDelimHead, "").replace(reNameValDelim, ":").replace(rePairDelim, ", ") + "})");
}

if(jQuery)
{
    jQuery.fn.center = 
    function () 
    {
        this.css("position", "absolute");
        this.css("top", ( jQuery(window).height() - this.height() ) / 2 + jQuery(window).scrollTop() + "px");
        this.css("left", ( jQuery(window).width() - this.width() ) / 2 + jQuery(window).scrollLeft() + "px");
        return this;
    }
}
