////////////////////////////////////////////////////////////////////////////////
//                            FONCTIONS   image de fond                       //
////////////////////////////////////////////////////////////////////////////////

Event.observe(window, 'load', resizeBackground, false);

onresize = resizeBackground;

function resizeBackground(){ 
	if ($('background_pict')){
		if( typeof( window.innerWidth ) == 'number' ) {	//Non-IE
			window_h = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode'
			window_h = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {	//IE 4 compatible
			window_h = document.body.clientHeight;
		}
		window_w = document.getElementById("background").offsetWidth;
	
		/*
		$("content_container").show();
		if (window_h>600) $("content_container").style.top = px( window_h-400);
		else $("content_container").style.top = px(200);
		*/
		if ($('background_pict')){
			bg_img_w = $('background_pict').getWidth();
			bg_img_h = $('background_pict').getHeight();
			delta = bg_img_w/bg_img_h;
		

			if ( document.getElementById("background_pict").style.height!= null ){
				if ((window_w/window_h)>delta) Element.setStyle("background_pict", { 
																	width: px(window_w), 
																	height: px(window_w/delta)
																	} 
																);
				else                           Element.setStyle("background_pict", { 
																	width: px(window_h*delta), 
																	height: px(window_h)
																	} 
																);
				
				if ($('background_pict').getHeight()>window_h) Element.setStyle("background_pict", { top: px(-($('background_pict').getHeight()-window_h)/2) 	});
				if ($('background_pict').getWidth()>window_w) Element.setStyle("background_pict", { left: px(-($('background_pict').getWidth()-window_w)/2) 	});
								
			}
			
			 //new Effect.Appear('background_pict', {delay:0, duration: 1 } );
			Element.show('background_pict');  
		}    
	    if ($('content_links') && $('content_main')){
	    	if ($('content_main').getHeight()<(window_h)) $('content_main').setStyle({height: px(window_h-80) });
	    }
	}
}

function px(x){
	return ''.concat(Math.round(x), 'px');
}

function showMobalbox(url, title_close){
	Modalbox.show(url, {closeValue:title_close, width: 900, height: 570});
}
