// JavaScript Document

/* CSS à attribuer à l'image de fond
img.ac_bgimage{
	position:fixed;
	left:0px;
	top:0px;
	width:100%;
	opacity:0.8;
}
*/

jQuery(function() { // fonctionne uniquement avec jquery
					   
					
					   
				
				var ac_background	= jQuery('#bgsite');// nom de la div comportant l'image de fond
				var ac_bgimage		= ac_background.find('.ac_bgimage'); // mettre la class ".ac_bgimage" sur l'image de fond
					   
					   init = function(){
							initWindowEvent();
							adjustImageSize(ac_bgimage);
							
					   },
					   
					   
					  adjustImageSize = function(imag) {
						
						var w_w	= jQuery(window).width(),
						w_h	= jQuery(window).height(),
						r_w	= w_h / w_w,
						i_w	= imag.width(),
						i_h	= imag.height(),
						r_i	= i_h / i_w,
						new_w,new_h,
						new_left,new_top;
							
						if(r_w > r_i){
							new_h	= w_h;
							new_w	= w_h / r_i;
						}
						else{
							new_h	= w_w * r_i;
							new_w	= w_w;
						}
							
						imag.css({
							width	: new_w + 'px',
							height	: new_h + 'px',
							left	: (w_w - new_w) / 2 + 'px',
							top		: (w_h - new_h) / 2 + 'px'
						});
					},
					 
					 
					
					initWindowEvent		= function() {
						/* on window resize set the width for the menu */
						jQuery(window).bind('resize.Menu' , function(e) {
							adjustImageSize(ac_bgimage);
						});
					};
					
					
			init();		
					
});


