var domready = false;

function init() {
	
	domready = true;
	var firstVal = 'recherche...';
	var targetInput = $('rightcol').getElement('.inputsearch');
	
	targetInput.set('value', firstVal);
	targetInput.addEvents({
								
		'focus': function(evt) {
			
			if(this.get('value') == firstVal) this.set('value', '');
			
		},
		'blur': function(evt) {
			
			if(this.get('value') == '') this.set('value', firstVal);
			
		}
		
	});
	
	if(Browser.Engine.trident && Browser.Engine.version == 4)  {
		
		var pthLogo = $('logo').get('src').split('/');
		pthLogo.pop()
		
		$('logo').set('src', pthLogo.join('/') + '/logo-DLX-Deluxe.gif');
		
	}
	
	$('logo').setStyle('visibility', 'visible');
	
	$$('.concours').addEvent('click', function(evt) {
											   
		var scrollSize = document.window.getScrollSize();
		
		var popSize = $('mailing_pop').measure(function(){
			return this.getSize();
		});
		
		var docSize = document.window.getSize();
		
		$('mailing_bg').setStyles({
			'display': 'block',
			'height': scrollSize.y
		});
		
		
		$('mailing_pop').setStyles({
			'display': 'block',
			'left': (docSize.x - popSize.x) / 2,					  
			'top': (docSize.y - popSize.y) / 2	+ document.window.getScroll().y				  
		});
	
	});
	
	$('mailing_bg').addEvent('click', function(evt) {
											   
		$('mailing_pop').setStyle('display', 'none');												   
		this.setStyle('display', 'none');												   
											   
	});
	
	initBg();

}


function initBg() {
	
	if(domready) {
			
		var sizeme = (function(){  
		
			var imageSize =	$('fullsize').getElement('img').getSize();
			var documentSize =	document.window.getSize();
			var imH = (imageSize.y * documentSize.x) / imageSize.x;
			var imW = documentSize.x;
						
			if(imageSize.x == documentSize.x || imageSize.y == documentSize.y) $clear(sizeme);			
						
			if (documentSize.x < documentSize.y || imH < documentSize.y) {
			
				imW = (imageSize.x * documentSize.y) / imageSize.y;
				imH = documentSize.y;
			
			}
			
			var imL = (documentSize.x - imW) / 2;
			var imT = 0;
			
			$('fullsize').getElement('img').setStyles({
				left: imL,
				top: imT,
				width: imW,
				height: imH 
			});
						
		}).periodical(50);
	
	}

}

window.addEvent('resize', initBg);