// rollOvers pour les images
// Application : class="roll"
window.addEvent('domready', function() {
	//preload images
	var aPreLoad = new Array();
	var aPreLoadi = 0;
	
	//do rollover
	$$('img.roll', 'input.roll').each(function(el){
		//let's preload
		aPreLoad[aPreLoadi] = new Image();
		aPreLoad[aPreLoadi].src = el.src.replace(el.src.replace('_off.', '_on.'));
		aPreLoadi++;
	
		el.addEvent('mouseover',function(){
			this.setAttribute('src',this.src.replace('_off.', '_on.'));
		});
	
		el.addEvent('mouseout',function(){
			this.setAttribute('src',this.src.replace('_on.','_off.'));
		});
	});

	// resize the background please
	resize_background_image_now();
});

// un background toujours visible, dependant la largeur et hauteur de la page
window.addEvent('resize', resize_background_image_now);

function resize_background_image_now()
{	
	var bg = $('background').getElement('img');
	
	var ratio = 1.3;
	
	bg.set('width', window.getWidth());
	bg.set('height', window.getWidth() / ratio);
	
	if (bg.getStyle('height').toInt() < window.getHeight()) {
		bg.set('height', window.getHeight());
		bg.set('width', window.getHeight() * ratio);
	}
}

function loadContent(file)
{
	var head = document.getElementsByTagName('head').item(0);
	var scriptTag = document.getElementById('loadScript');
	if (scriptTag) head.removeChild(scriptTag);
	var script = document.createElement('script');
	script.type = 'text/javascript';
	script.id = 'loadScript';
	script.src = file+'&r='+Math.random(); // prevent caching
	head.appendChild(script);
}

function handleLoadResponse()
{
	var container = $('sign-in-error');
	container.className = api_load_content_class;
	container.innerHTML = api_load_content_html;
}