/* :: Author Bruno Rodrigues >> plugin from the brro suite >> adjust image to his first container >> FORCA PORTUGAL !!! :: */
$(document).ready(function(e) {
	(function( $ ){
	
		$.fn.brroSizeMe = function(pluginOptions) {
			
			counter = 0;
			
			this.each(function()
			{
				O_brroSizeMe = function(obj, object_index)
				{
					
					this.obj = obj;
					this.original_image_width 	= this.obj.width();
					this.original_image_height 	= this.obj.height();
					
					
					/* this.parentContainer; */
					this.resizer = function()
					{
						
						
						this.container_width 	= this.obj.parent().width();
						this.container_height 	= this.obj.parent().height();
						this.obj_parent 		= this.obj.parent();
						
						var w = this.container_width / this.original_image_width;
						var h = this.container_height / this.original_image_height;
						
						if(w > h)
						{
							this.obj.width( this.container_width + 1 );
							this.obj.height( Math.round( this.original_image_height * w ) + 1 );
							// this.obj.css("left",0).css("top",( this.container_height - this.obj.height() ) / 2 );
						}
						else
						{
							this.obj.height( this.container_height );
							this.obj.width( Math.round( this.original_image_width * h ));
							// this.obj.css("top",0).css("left",(this.container_width - this.obj.width())/2);
						 }
	
					}
					
					this.Constructor = function()
					{
						this.obj.css({"position":"absolute", "z-index":"0"});
						this.resizer();
						<!-- alert( object_index ); -->
						$(window).resize(
							function()
							{
								window["O_brroSizeMe_" + object_index].resizer();
							}
						);
						
					} // Constructor end
				} // end object
				
				counter += 1;
				/* alert( counter ); */
				
				window["O_brroSizeMe_" + counter] = new O_brroSizeMe($(this), counter);
				window["O_brroSizeMe_" + counter].Constructor();
				
			}); // end each loop
			
		};
	})( jQuery );
});
