var toutlayer=true;
var zindex='1000';
var maj_delai=20;

var flag_stop=false;
var stoper_ajout_evenement_sur_lien=false;
var effacer_calque=true;

var ref_finder=0;

function CreeCookie()
	{
	  expiration = new Date();
	  expiration.setTime(expiration.getTime() + (24*60*60*1000));
	
	  document.cookie="disclaimerok=oui; expires=" + expiration.toGMTString() + "; path=/;";	
	}

	if(document.referrer.indexOf("finder-x",0)!=-1)
	{
	  ref_finder=1;
	  CreeCookie();
	}

function ScanCookie(variable)
	{
	 cook=document.cookie;
	 variable+="=";
	 place=cook.indexOf(variable,0);
	 if(place<=-1) return("0");
	 else
	 {
	  end=cook.indexOf(";",place)
	  if(end<=-1) return(unescape(cook.substring(place+variable.length,cook.length)));
	  else return(unescape(cook.substring(place+variable.length,end)));
	 }
	}

function get_dim()
{
	var dim = new Array();
	
	if(typeof(window.innerWidth)=='number')
	{ //Non-IE
		dim['width']=window.innerWidth-16;
		dim['height']=window.innerHeight;
	}
	else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
	{ //IE 6+ in 'standards compliant mode'
		dim['width']=document.documentElement.clientWidth;
		dim['height']=document.documentElement.clientHeight;
	}
	else if(document.body && (document.body.clientWidth || document.body.clientHeight))
	{ //IE 4 compatible
		dim['width']=document.body.clientWidth;
		dim['height']=document.body.clientHeight;
	}
	else if(document.layers)
	{ //NS4.X seul
		dim['width']=window.innerWidth-16;
		dim['height']=window.innerHeight;
	}
	
	return dim;
}

function get_xy()
{
	var dim = new Array();
	dim['y']=0;
	dim['x']=0;
	
	if(typeof(window.pageYOffset)=='number')
	{ //Netscape compliant
		dim['y']=window.pageYOffset;
		dim['x']=window.pageXOffset;
	}
	else if(document.body && (document.body.scrollLeft || document.body.scrollTop))
	{ //DOM compliant
		dim['y']=document.body.scrollTop;
		dim['x']=document.body.scrollLeft;
	}
	else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
	{ //IE6 standards compliant mode
		dim['y']=document.documentElement.scrollTop;
		dim['x']=document.documentElement.scrollLeft;
	}
	else if(document.layers)
	{ //NS4.X
		dim['y']=window.pageXOffset;
		dim['x']=window.pageYOffset;
	}

	return dim;
}

function ajustement()
{
	var dim = get_dim();
	var xy = get_xy();
	
	if (document.getElementById)
	{ //IE5 & NS6
		document.getElementById('couverture').style.top=xy['y']+"px";
		document.getElementById('couverture').style.width=dim['width']+"px";
		document.getElementById('couverture').style.height=dim['height']+"px";
	}
	else if (document.all)
	{ //IE4
		document.all['couverture'].style.top=xy['y']+"px";
		document.all['couverture'].style.width=dim['width']+"px";
		document.all['couverture'].style.height=dim['height']+"px";
	}
	else if (document.layers)
	{ //NS4.X
		document.layers['couverture'].top=xy['y']+"px";
		document.layers['couverture'].width=dim['width']+"px";
		document.layers['couverture'].height=dim['height']+"px";
	}
	
	repeat_ajustement = setTimeout('ajustement()',maj_delai);
}

function affiche_calque()
{
	var dim = get_dim();
	
	if ((document.all)||(document.getElementById))
	{
		var contenu_over='<table id="couverture" name="couverture" onClick="open_under();" style="background:transparent; z-index:'+zindex+'; position:absolute; left:0px; top:0px; width:'+dim['width']+'px; height:'+dim['height']+'px"><tr><td>&nbsp;</td></tr></table>';
	}
	else
	{
		var contenu_over='<layer id="couverture" name="couverture" onClick="open_under();" z-index="'+zindex+'" left="0" top="0" width="'+dim['width']+'" height="'+dim['height']+'" style="background:transparent;"></layer>';
	}

	document.write(contenu_over);
	ajustement();
}

function efface_calque()
{
	clearTimeout(repeat_ajustement);
	
	if (document.getElementById)
	{
		document.getElementById('couverture').style.visibility='hidden';
		document.getElementById('couverture').style.width="0px";
		document.getElementById('couverture').style.height="0px";
	}
	else if (document.all)
	{
		document.all['couverture'].style.visibility='hidden';
		document.all['couverture'].style.width="0px";
		document.all['couverture'].style.height="0px";
	}
	else if (document.layers&&document.layers['couverture'])
	{
		document.layers['couverture'].visibility='hide';
		document.layers['couverture'].width="0px";
		document.layers['couverture'].height="0px";
	}
}

function open_under()
{
	CreeCookie();

	if(flag_stop)
	{
		return true;
	}
	
	flag_stop=true;
	
	under = window.open('http://gateway.eravage.com/rotation_pdv.php?ida=1674&id_product=1&main_id_cat=12&offer=cb302m90&rebill=1&d=0&e=0&tracker=vspopup','underfinder8683','top=20,left=20,width='+(screen.width-60)+',height='+(screen.height-60)+',location=1,menubar=1,fullscreen=0,scrollbars=1,status=1,toolbar=1,directories=1,resizable=1');
	under.blur();
	window.focus();
	
	if(effacer_calque)
	{
		efface_calque();
	}
}

function ajout_evenement_sur_lien()
{
	effacer_calque=false;
	
	for (var i=0;i<document.links.length;i++)
	{
		if (!document.links[i].onclick)
		{
			document.links[i].onclick=open_under;
		}
	}
	
	if(!stoper_ajout_evenement_sur_lien)
	{
		repeat_ajout_evenement_sur_lien = setTimeout('ajout_evenement_sur_lien()',maj_delai);
	}
}

function stop_ajout_evenement_sur_lien()
{
	stoper_ajout_evenement_sur_lien=true;
}


if(!ref_finder && ScanCookie("disclaimerok")==0 && !toutlayer && (window.navigator.userAgent.indexOf('Firefox')!=-1 || window.navigator.userAgent.indexOf('Safari')!=-1))
{
	ajout_evenement_sur_lien();
	addLoadEvent(stop_ajout_evenement_sur_lien);
}
else if(!ref_finder && ScanCookie("disclaimerok")==0)
{
	affiche_calque();
}
