jQuery.fn.extend
({	sizeToBody: function()
	{	return this.each(function()
		{	var width = jQuery('body').attr('offsetWidth') ;
			var height = jQuery('body').attr('offsetHeight') ;
			jQuery(this).css('width',width).css('height',height) ;
			
			if (this.initialized) ;
			else
			{	this.initialized = true ;
				var _this = this ;
				jQuery(window).bind('resize', function()
				{	jQuery(_this).sizeToBody() ;
					return true ;
				}) ;
			}
		})
	}
}) ;

function sizeToBody(e)
{	var width = jQuery('body').attr('offsetWidth') ;
	var height = jQuery('body').attr('offsetHeight') ;
	jQuery(e).css('width',width).css('height',height) ;

	if (e.initialized) ;
	else
	{	e.initialized = true ;
		var _e = e ;
		jQuery(window).bind('resize', function()
		{	sizeToBody(_e) ;
			return true ;
		}) ;
	}
}
/*
 * Permet l'affichage d'une popin en utilisant jQuery
 */

function closePopin()
{	jQuery("#PopinMain").fadeOut(500, function(){jQuery("#PopinBG").remove() ; jQuery("#PopinMain").remove()}) ;
}
function showPopin(url,width,height)
{	if (jQuery("#PopinBG").length)	
	{	jQuery("#PopinBG").remove() ;
		jQuery("#PopinMain").remove() ;
	}

	jQuery('body').append('<div id="PopinBG"></div>') ;
	sizeToBody(jQuery("#PopinBG")) ;

	jQuery.ajax(
	{	url: url, 
		success:function(html)
		{	
			jQuery('body').append('<div id="PopinMain" onclick="closePopin();"><div id="Popin" onclick="fctStopPropagation(event);"><div id="PopinIn"></div><div id="PopinCloseBox"><a onclick="closePopin();" class="close"></a></div></div></div>') ;
			sizeToBody(jQuery("#PopinMain")) ;
			jQuery("#Popin").css('width',width) ;
			jQuery("#Popin").show(400) ;
			if (height)
			{	jQuery("#Popin").css('height',height) ;
			}
				
			jQuery("#PopinIn").html(html) ;
		}
	});

}

