Event.observe(window, 'load', function() {
	var res = 0;
	new Ajax.Request('ajax.firstvisit.php?u='+(new Date()).getTime(), 	{
		asynchronous:false,
		onComplete: function(t) { 
			res = (t.responseText == "TRUE");
			if(res){
				var arrayPageSize = getPageSize();
				$('overlay2').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1]+10 + 'px', top:'-10px' }).setOpacity(.6).show();

				$('overlay2').onclick=null;

				$('boxMajeur').setStyle({ position:'absolute', top:'-600px', display:'block', zIndex:'10000'});
				new Effect.Move($('boxMajeur'), { x: ((arrayPageSize[0] - 654) / 2), y: 100, mode: 'absolute', duration:2});

				$('confirm').update('<a href="#" id="oui" onclick="_18_true(); return false">Oui</a><a href="#" id="non" onclick="_18_false(); return false">Non</a>');

			}
		},
		onFailure: function() { res = 0;	}
	});
});
function _18_true(){
	new Ajax.Request('ajax.firstvisit.php?valid=true&u='+(new Date()).getTime());
	$('overlay2').setOpacity(0).hide();
	new Effect.Move($('boxMajeur'), { x: 0, y: -600, mode: 'absolute', afterFinish:function(){$('confirm').hide();}});
}
function _18_false(){
	new Ajax.Request('ajax.firstvisit.php?init=true&u='+(new Date()).getTime());
	location.href='http://www.2340.fr/';
}

function getPageSize(){
    var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth;
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = xScroll;
	} else {
		pageWidth = windowWidth;
	}
	return [pageWidth,pageHeight];
}