﻿(function($) {
    $.fn.vAlign = function() {
        return this.each(function(i) {
            var h = $(this).height();
            var oh = $(this).outerHeight();
            var mt = (h + (oh - h)) / 2;
            $(this).css("margin-top", "-" + mt + "px");
            $(this).css("top", "50%");
            $(this).css("position", "absolute");
        });
    };
})(jQuery);

(function($) {
    $.fn.hAlign = function() {
        return this.each(function(i) {
            var w = $(this).width();
            var ow = $(this).outerWidth();
            var ml = (w + (ow - w)) / 2;
            $(this).css("margin-left", "-" + ml + "px");
            $(this).css("left", "50%");
            $(this).css("position", "absolute");
        });
    };
})(jQuery);

jQuery.extend({
    'Q': window.location.search.length <= 1 ? {}
            : function(a) {
                var i = a.length,
                r = /%25/g,  // Ensure '%' is properly represented
                h = {};      // (Safari auto-encodes '%', Firefox 1.5 does not)
                while (i--) {
                    var p = a[i].split('=');
                    h[p[0]] = r.test(p[1]) ? decodeURIComponent(p[1]) : p[1];
                }
                return h;
            } (window.location.search.substr(1).split('&'))
});
