(function($) { $.fn.center=function(){ return this.each(function(i,n){ var jqelmt=$(n); jqelmt.css('display','block'); var height=$(n).height(); var width=$(n).width(); jqelmt.css('display','none'); var posY=($(window).height()/2)-(height/2); var posX=($(window).width()/2)-(width/2); if(posY<0) posY=10; jqelmt.css('top',posY+'px'); jqelmt.css('left',posX+'px'); jqelmt.css('display','block'); }); } $.fn.hCenter=function(){ return this.each(function(i,n){ var jqelmt=$(n); jqelmt.css('display','block'); var width=$(n).width(); jqelmt.css('display','none'); var posX=($(window).width()/2)-(width/2); jqelmt.css('top',0); jqelmt.css('left',posX+'px'); jqelmt.css('display','block'); }); } $.fn.windowsHeight=function(alter){ if(typeof alter=='undefined') alter=0; return this.each(function(i,n){ var jqelmt=$(n); jqelmt.css('height',($(window).height()-alter)); }); } })(jQuery);