﻿// JScript File

$.fn.centerDiv = function() {
   
   var winHorizCenter = Math.floor($(window).width()/2);
   var winVertCenter = Math.floor($(window).height()/2);
   var divWidth = this.width();
   var divHeight = this.height();
   
   var newTop = winVertCenter - (Math.floor(divHeight/2));
   var newLeft = winHorizCenter - (Math.floor(divWidth/2));
   
   if (newTop<0) {newTop = 0;}
   if (newLeft<0) {newLeft = 0;}
   
   this.positionDiv(newLeft,newTop);
 
   return this;
}

$.fn.positionDiv = function(newLeft,newTop) {
   this.css('top',newTop + 'px');
   this.css('left',newLeft + 'px');
   
   return this;
}



