/*
posicion.js

###############################
Creado en 2008/06/19
NOVEMBRO S.l.
Todos los derechos reservados.
###############################
*/

$(document).ready(function () {
	
	BodyFull();
	
	jQuery.each($('.Center'),function(i,val){
		Center($(val));
	});
	
	$(window).resize(function(){
		BodyFull();
		jQuery.each($('.Center'),function(i,val){
			Center($(val));
		});
	});
	
	
	function Center(val) {
		var elemento = val;
		
		//var padre = $(elemento).parent();
		var padre = $(window);
		
		
		var h = elemento.attr('height');
		var w = elemento.attr('width'); 

		elemento.css({'width':w+'px'});
		elemento.css({'height':h+'px'});
		
		elemento.css({'position':'absolute'});
		
		var x = (padre.width()/2)-(w/2);
		var y = (padre.height()/2)-(h/2);
		
		if (y<0) y = 22;
		
		elemento.css({'top':y+'px'});
		elemento.css({'left':x+'px'});
	};
	
	function BodyFull(){
		
		if (document.body.scrollHeight>$(window).height()) {
			var hfull = document.body.scrollHeight;
		} else { var hfull = $(window).height();};
		
		$('body').height(hfull);
	}
});
