// 	             _           
// 	 ___ ___ ___| |_ _ _____ 
// 	| . | -_| . | | | |     |
// 	|  _|___|  _|_|___|_|_|_|
// 	|_|     |_|              
//
// POWERED BY PEPLUM
// http://www.mypeplum.com
// 2008-06-20

Position.GetWindowSize = function(w) 
{
	var theWidth, theHeight;
    w = w ? w : window;
    this.theWidth = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
    this.theHeight = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
    return this;
}



function change()
{
	var win = Position.GetWindowSize() ;
	var ratioImage = (Math.round(1920000/1047))/1000;
	var ratioPage = (Math.round((win.theWidth)/(win.theHeight)*1000))/1000;		
	if (ratioPage<ratioImage)
	{
		var theOffset = ((win.theHeight*ratioImage)-win.theWidth)/2 ;	
		if($('img'))
		{
			$('img').style.height = win.theHeight+'px' ;
			$('img').style.width = (Math.round(win.theHeight*ratioImage))+'px' ;
			$('img').style.left = '-'+theOffset+'px' ;
			$('img').style.posLeft = theOffset*(-1) ;
		}
		if($('previous'))
		{
			$('previous').style.height = win.theHeight+'px' ;
			$('previous').style.width = (Math.round(win.theHeight*ratioImage))+'px' ;
			$('previous').style.left = '-'+theOffset+'px' ;
			$('previous').style.posLeft = theOffset*(-1) ;
		}
	}
	else
	{
		if($('img'))
		{
			$('img').style.width = win.theWidth+'px' ;
			$('img').style.height = win.theWidth/ratioImage+'px' ;
			$('img').style.left = '0px' ;
			$('img').style.posLeft = 0 ;
		}
		if($('previous'))
		{
			$('previous').style.width = win.theWidth+'px' ;
			$('previous').style.height = win.theWidth/ratioImage+'px' ;
			$('previous').style.left = '0px' ;
			$('previous').style.posLeft = 0 ;
		}
	}		
}

function checkAndFade()
{
	document.body.style.cursor = 'wait';
	if(actual.complete)
	{
		document.body.style.cursor = 'default';
		$('new').innerHTML = '<img id="img" class="large" alt="fond" onmouseover="menuOUT();" onmouseout="menuIN();" />';
		$('img').src = actual.src ;
		if($('previous'))
		{
			$('previous').fade({ fps:100 });
		}
		else if (!unchanged)
		{
			$('img').hide();
			$('img').appear();
		}
		change();	
	}
	else
	{
		setTimeout('checkAndFade()', 1)	;
	}	
}

function start()
{ 
	if($('previous'))
	{
		$('previous').style.visibility = 'visible';
	}
	if(urlPhoto)
	{
		urlActual = 'images/'+urlPhoto ;
		actual = new Image();
		actual.src = urlActual ;	
		checkAndFade();
	}
	else if($('previous'))
	{
		$('previous').fade({ fps:100 });
	}
	change();		
}

Event.observe(window, 'load', start);
window.onresize = change;
