/**********************************************************************************
* phpComasy, Open Source Web Content Management System                            *
* http://www.phpcomasy.org                                                        *
*                                                                                 *
* Copyright (c) 2005 - 2011 indual	 gmbh (http://www.indual.ch)	              *
*                                                                                 *
* phpComasy is released under his own licence (http://www.phpcomasy.com/licence)  *
**********************************************************************************/

Event.observe(window, 'resize', function() {	
	resize_background();	
});

document.observe("dom:loaded", function() {
	resize_background();
});

function resize_background() {
	// init, get heights
    var windowHeight = document.viewport.getHeight();
    var windowWidth = document.viewport.getWidth();	
    var ratio = 1.6; //1920x1200
    
    // calculate image width    
    var imgWidth = windowHeight * ratio;
    
    // resize background
    if (imgWidth <= windowWidth) {
    	$$('#background_image img').first().width = windowWidth;
    	$$('#background_image img').first().height = (windowWidth / ratio);
    }
    else {
    	$$('#background_image img').first().width = imgWidth;
    	$$('#background_image img').first().height = windowHeight;    	
    }
}
