/* Class FullScreen
 * Copyright (c) 2010-2011, Jérôme Fath <http://www.jeromefath.com>
 * Adapté par Philippe Blanc <http://www.crea64.net> (centrage de l'image dans la page)
 * This source file is subject to the MIT license.
*/
FullScreen=Class.create({initialize:function(a){this.element=$(a);if(this.element==null){throw new Error("Unable to create object FullScreen, the element not exist")}this.element.setStyle(this.getStyleElement());this.imageX=this.element.getWidth();this.imageY=this.element.getHeight();this.ratio=this.imageX/this.imageY;Event.observe(window,"resize",this.window_resizeHandler.bind(this));Event.observe("img_fond","load",this.window_resizeHandler.bind(this))},update_image:function(){this.imageX=this.element.getWidth();this.imageY=this.element.getHeight();this.ratio=this.imageX/this.imageY},getStyleElement:function(){this.image_style={position:"fixed",top:0,left:0};return this.image_style},getRatioWindow:function(){this.windowsX=document.viewport.getWidth();this.windowsY=document.viewport.getHeight();return this.windowsX/this.windowsY},resize:function(){this.update_image();if(this.getRatioWindow()<this.ratio){this.element.setStyle({width:"auto",height:"100%"})}else{this.element.setStyle({width:"100%",height:"auto"})}this.update_image();this.decalY=-(this.imageY-this.windowsY)/2;this.decalX=-(this.imageX-this.windowsX)/2;this.element.setStyle({left:this.decalX+"px",top:this.decalY+"px"})},window_resizeHandler:function(a){this.resize()}});
