// vertical positioning in the viewport
// src: http://test.learningjquery.com/scripts/jquery.vcenter.js
// tweaked by Slavi
(function(x){
  x.fn.vCenter = function(options) {
    var pos = {
      sTop : function() {
        return window.pageYOffset || document.documentElement && document.documentElement.scrollTop ||	document.body.scrollTop;
      },
      wHeight : function() {
        return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body.clientHeight;
      }
    };
    return this.each(function(index) {
      if (index == 0) {
        var $this = jQuery(this);
        var elHeight = $this.height();
	    var elTop = pos.sTop() + (pos.wHeight() / 2) - (elHeight / 2);

		var width = $this.width();
		var halfWidth = (width/2) * (-1);

	    $this.css({
          position: 'absolute',
          marginTop: '0',
          width: width,
          top: elTop,
          left: '50%',
          marginLeft : halfWidth,
          'z-index' : '600'
        });
      }
    });
  };

})(jQuery);


