// vertically center something in the viewport

(function($){
  $.fn.vCenter = function(options) {
    var pos = {
      sTop : function() {

return window.pageYOffset || $.boxModel && document.documentElement.scrollTop || document.body.scrollTop;

      },
      wHeight : function() {

if ( $.browser.opera || ($.browser.safari && parseInt ($.browser.version) > 520) ) { return window.innerHeight - (($(document).height() > window.innerHeight) ? getScrollbarWidth() : 0);

                } else if ( $.browser.safari ) {
                        return window.innerHeight;
                }       else {

return $.boxModel && document.documentElement.clientHeight || document.body.clientHeight;

        }
      }
    };
    return this.each(function(index) {
      if (index == 0) {
        var $this = $(this);
        var elHeight = $this.height();
        $this.css({
          position: 'absolute',
          marginTop: '0',
          top: pos.sTop() + (pos.wHeight() / 2) - (elHeight / 2)
        });
      }
    });
  };

})(jQuery);