/**
 *
 *	Ambiware's Simple Div Centering - v1.0 - 7/10/2011
 *	http://ambidev.com/ambicenter
 *
 *	Copyright (c) 2011 Seth Ciasulli
 *	Licensed under GNU General Public License
 *
 *	This jQuery plugin is free to use, duplicate, share, edit, etc.
 *	You are not required to give credit to it's original author.
 *
**/

(function($){
	$.fn.ambicenter=function(options){
		
		//-> plugin options
		var defaults={
			onWindowResize:'true',
			delay:0,
		};
		
		var options=$.extend(defaults,options);
		this.each(function(){
		
			//-> setting up variables
			var a = '#'+$(this).attr('id');
			
			//-> setting up top and left values
		    if(options.delay!=0){
			    setTimeout(function(){
					$(a).css({
				    	'top':$(window).height()/2-$(a).height()/2,
				    	'left':$(window).width()/2-$(a).width()/2
				    });
			    },options.delay);
		    }else{
			    $(a).css({
			    	'top':$(window).height()/2-$(a).height()/2,
			    	'left':$(window).width()/2-$(a).width()/2
			    });
		    }
		    
		    //-> setting up auto placement on window resize
		    if(options.onWindowResize=='true'){
				$(window).resize(function() {
				    $(a).css('top', $(window).height()/2-$(a).height()/2);
				    $(a).css('left', $(window).width()/2-$(a).width()/2);
				});
			}
		});
	};
})(jQuery);

/**
 *
 *	End
 *
**/
