/*Event.observe(window, 'load', function() { 
	var fullscreen = new FullScreen('bg');
	fullscreen.resize();
	
});*/


/*
 * Class FullScreen
 *
 * Copyright (c) 2010-2011, Jérôme Fath <http://www.jeromefath.com>
 *
 * This source file is subject to the MIT license.
 *
 *--------------------------------------------------------------------------*/
 
FullScreen = Class.create(
{
    initialize: function(idElement)
    {
        this.element = $(idElement);
 
        if(this.element == null)
        {
            throw new Error("Unable to create object FullScreen, the element not exist");
        }
 
        this.element.setStyle(this.getStyleElement());
			
        this.ratio = this.element.getWidth() / this.element.getHeight();
 
        Event.observe(window, "resize", this.window_resizeHandler.bind(this));
    },
 
    getStyleElement: function()
    {
        return {
                 position: 'fixed',
                 top: 0,
                 left: 0
               };
    },
 
    getRatioWindow: function()
    {
        return document.viewport.getWidth()/ document.viewport.getHeight();
    },
 
    resize: function()
    {
       /* if ( this.getRatioWindow() < this.ratio )
            this.element.setStyle( {width:'auto', height:'100%'} );
        else this.element.setStyle({width:'100%', height:'auto'});
		  
			var height = $('bg').getHeight();
			var width = $('bg').getWidth();
			var heightBody = document.viewport.getHeight();
			var widthBody = document.viewport.getWidth();
			var posY=(heightBody/2)-(height/2);
			var posX=(widthBody/2)-(width/2);
			this.element.setStyle({top: posY+'px', left: posX+'px'});*/
			if ( this.getRatioWindow() < this.ratio )
        {
            this.element.setStyle({width:'auto', height:'100%'});
        }
        else
        {
            this.element.setStyle({width:'100%', height:'auto'});
        }
    },
 
    window_resizeHandler: function(event)
    {
        this.resize();
    }
 
});

Event.observe(window, 'load', function() { 
	var fullscreen = new FullScreen('bg');
	fullscreen.resize();
});
