﻿(function ($) {
  $.fn.center = function () {
    this.css("position", "absolute");
    this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
    this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
    return this;
  };
})(jQuery);

(function ($) {
  $.fn.shuffle = function () {
    // remove styling on parent list
    this.css("list-style-image", "none !important").css("list-style-type", "none !important");

    // get the child list items
    var lis = this.children().filter("li");

    // hide each of the li's
    lis.each(function(index) {
      $(lis.get(index)).css("display", "none");
    });

    // show a random li
    var index = Math.floor(Math.random() * lis.length);
    $(lis.get(index)).css("display", "");

    // show ul
    this.css("display", "");

    return this;
  };
})(jQuery);

//gets querystring client side (usage - $.QueryString["param"])
(function ($) {
  $.QueryString = (function (a) {
    if (a == "") return {};
    var b = {};
    for (var i = 0; i < a.length; ++i) {
      var p = a[i].split('=');
      if (p.length != 2) continue;
      b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
    }
    return b;
  })(window.location.search.substr(1).split('&'))
})(jQuery);

