function ecrireCookie(nom, valeur){
  var argv=ecrireCookie.arguments;
  var expdate = new Date () ; // crée un objet date indispensable 
  expdate.setTime (expdate.getTime() + ( 24 * 60 * 60 * 1000)) ; // on rajoute dix jours en millisecondes 
  var argc=ecrireCookie.arguments.length;
  var expires=(argc > 2) ? argv[2] : null;
  var path=(argc > 3) ? argv[3] : null;
  var domain=(argc > 4) ? argv[4] : null;
  var secure=(argc > 5) ? argv[5] : false;
  document.cookie=nom+"="+escape(valeur)+
  ((expires==null) ? "; expires="+expdate.toGMTString()  : ("; expires="+expdate.toGMTString()))+
  ((path==null) ? "" : ("; path="+path))+
  ((domain==null) ? "" : ("; domain="+domain))+
  ((secure==true) ? "; secure" : "");
}

function getCookieVal(offset){
  var endstr=document.cookie.indexOf (";", offset);
  if (endstr==-1) endstr=document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr)); 
}

function lireCookie(nom){
  var arg=nom+"=";
  var alen=arg.length;
  var clen=document.cookie.length;
  var i=0;
  while (i<clen) {
    var j=i+alen;
    if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
    i=document.cookie.indexOf(" ",i)+1;
    if (i==0) break;
  }
  return null; 
}


// affichage du calque
function afficheBrm(){
//  document.all.blocQuest.style.display='block';

// Comment by David L.:
// The object "document.all" is proprietary to IE and should be replaced with 
// the standard "document.getElementById" method (supported by IE 5 and above):
  var larg=document.body.clientWidth;

 	document.getElementById('blocRideau').style.width=larg;
	document.getElementById('blocRideau').style.display='block';
	document.getElementById('pubGeneral').style.display='block';
	document.getElementById('blocQuest').style.display='block';
	document.getElementById('blocIntro1').style.display='block';
	document.getElementById('blocIntro2').style.display='block';
	document.getElementById('blocFermer1').style.display='block';
	document.getElementById('blocFermer2').style.display='block';
}

function cacheBrm(){
//  document.all.blocQuest.style.display='none';
	document.getElementById('blocRideau').style.display='none';
	document.getElementById('pubGeneral').style.display='none';
	document.getElementById('blocQuest').style.display='none';
	document.getElementById('blocIntro1').style.display='none';
  document.getElementById('blocIntro2').style.display='none';
	document.getElementById('blocFermer1').style.display='none';
	document.getElementById('blocFermer2').style.display='none';
}

// fonction javascript pour générer un nombre aléatoire :
function alea(valMax) {
  x = Math.ceil(Math.random()*valMax);
  return x;
}

// Insertion du cookie questionnaire puis affichage du calque
function validQuest(numPub) {
  date=new Date;
  date.setDate(date.getDate()+90);

  ecrireCookie("layer2", 1, date);
  afficheBrm();
}


// traitement et vérification du cookie
function openpp() {
  var blocker=0; // blocage du popup si variable à 1
  
  if (blocker==1) return; // Si le blocker est à 1 on ne fait rien
  if (lireCookie("layer2")!=null) return; // Si le calque s'est déjà ouvert on ne fait rien

  validQuest();
}

var itemmetapopunder;
if(itemmetapopunder == null){
var itemmetapopunder = 1;

function ouvremetapopunder(url,args){
	var w = window.open(url,"_blank",args);
	window.focus();
	if( w != null ) w.blur();
	return false;
}
}

function pubUnder4() {

ouvremetapopunder("http://www.sedecouvrir.fr/img/mariavoyance.php","status=no,menubar=no,resizable=no,titlebar=no,toolbar=no,width=500,height=610");
}

function pubUnder5() {
document.write ('<script type="text/javascript" src="http://action.metaffiliation.com/script.php?maff=D42A614515D117"></script>');
}

function pubUnder6() {
document.write ('<script type="text/javascript" src="http://action.metaffiliation.com/script.php?maff=D4176E4515D118"></script>');
}

function pub4() {
document.write ('<div id="blocRideau" style="left: 0px; top:0px; width:100%; height:2227px; position:absolute; z-index:20; display:none; background-color:#000000; filter:alpha(opacity=60); -moz-opacity:.60; opacity:.60"></div>'+
'<div style="top:20px; position:absolute; width:100%; z-index:21;">'+
  '<div id="pubGeneral" style="margin:auto; width:520px;height:630px;z-index:21;background-color:white;display:none;">'+
    '<div id="blocIntro1" style="float:left;width:430px;text-align:justify; padding-top:3px;padding-bottom:10px;padding-left:10px;padding-right:10px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;display:none;color:#4369C7;">'+
    'A nouveau, nous vous offrons en complément de notre site, une voyance <b>GRATUITE</b> avec notre partenaire !<br/>'+
    'Alors, n\'hésitez plus et profitez !<br/>'+
    '</div>'+   
    '<div id="blocFermer1" style="float:left;text-align:right; padding-top:3px;padding-bottom:3px;padding-right:10px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;display:none;">'+
    '<a style="color:#4369C7;text-decoration:none;" href="javascript:cacheBrm()"><img src="./img/fermer.gif"/>&nbsp;Fermer</a>'+
    '</div>'+
    '<div id="blocQuest" style="margin:auto;width:500px; display:none;">'+
    '<a onclick="javascript:cacheBrm()" href="http://www.sedecouvrir.fr/goto.php?redirect=http://action.metaffiliation.com/suivi.php?mclic=S42EC74515D167&idpub=edarling500x510&urlpage='+document.location.href.split("http://www.sedecouvrir.fr")[1]+'" target="_blank"><img src="./img/edarling.jpg" border="0"></a>'+
    '</div>'+
    '<div id="blocIntro2" style="width:430px;text-align:center; padding-top:7px;padding-bottom:10px;padding-left:40px;padding-right:40px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;color:#4369C7;display:none;">'+
    'Vous pouvez accèder à d\'autres offres de voyance <b>GRATUITE</b> <br/> en <a style="color:#4369C7;font-weight:bold;" style="text-decoration:none;" onclick="javascript:cacheBrm()" href="http://www.sedecouvrir.fr/voyance.php">>>> cliquant ici <<<</a><br/>'+
    '</div>'+  
    '<div id="blocFermer2" style="text-align:center; padding-top:1px;padding-right:0px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;display:none;">'+
    '<a style="color:#4369C7;font-weight:bold;" href="javascript:cacheBrm()">Accès direct à SeDecouvrir.fr</a>'+
    '</div>'+
  '</div>'+
'</div>');
if (lireCookie("layer2")!=null) return;
pubUnder5();

/*
if (lireCookie("layer")!=null) return;
var varFreq=100;
var nbreAlea2=alea(varFreq);
if (nbreAlea2>0 && nbreAlea2<=50)
{pubUnder2();}

if (nbreAlea2>50 && nbreAlea2<=100)
{pubUnder3();}
*/
}

function pub5() {
document.write ('<div id="blocRideau" style="left: 0px; top:0px; width:100%; height:2227px; position:absolute; z-index:20; display:none; background-color:#000000; filter:alpha(opacity=60); -moz-opacity:.60; opacity:.60"></div>'+
'<div style="top:20px; position:fixed; width:100%; z-index:21;">'+
  '<div id="pubGeneral" style="margin:auto; width:668px;height:590px;z-index:21;background-color:white;display:none;">'+
    '<div id="blocIntro1" style="float:left;width:583px;text-align:justify; padding-top:3px;padding-bottom:10px;padding-left:10px;padding-right:10px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;display:none;color:#4369C7;">'+
    'Nous vous offrons en complément de notre site, un test de personnalité <b>GRATUIT</b> avec notre partenaire pour découvrir l\'amour de votre vie !' + 
    '</div>'+   
    '<div id="blocFermer1" style="float:left;text-align:right; padding-top:3px;padding-bottom:3px;padding-right:10px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;display:none;">'+
    '<a style="color:#4369C7;text-decoration:none;" href="javascript:cacheBrm()"><img src="./img/fermer.gif"/>&nbsp;Fermer</a>'+
    '</div>'+
    '<div id="blocQuest" style="margin:auto;width:640px; display:none;">'+
    '<a onclick="javascript:cacheBrm()" href="http://www.sedecouvrir.fr/goto.php?redirect=http://action.metaffiliation.com/suivi.php?mclic=S42EC74515D167&idpub=Edarling640x480&urlpage='+document.location.href.split("http://www.sedecouvrir.fr")[1]+'" target="_blank"><img src="http://action.metaffiliation.com/suivi.php?maff=S42EC74515D167" border="0"></a>'+
    '</div>'+
    '<div id="blocIntro2" style="width:583px;text-align:center; padding-top:7px;padding-bottom:10px;padding-left:40px;padding-right:40px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;color:#4369C7;display:none;">'+
    'Vous pouvez accèder à des offres de voyance <b>GRATUITE</b> <br/> en <a style="color:#4369C7;font-weight:bold;" style="text-decoration:none;" onclick="javascript:cacheBrm()" href="http://www.sedecouvrir.fr/voyance.php">>>> cliquant ici <<<</a><br/>'+
    '</div>'+  
    '<div id="blocFermer2" style="text-align:center; padding-top:1px;padding-right:0px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;display:none;">'+
    '<a style="color:#4369C7;font-weight:bold;" href="javascript:cacheBrm()">Accès direct à SeDecouvrir.fr</a>'+
    '</div>'+
  '</div>'+
'</div>');
if (lireCookie("layer2")!=null) return;
pubUnder4();
}

function pub6() {
document.write ('<div id="blocRideau" style="left: 0px; top:0px; width:100%; height:2227px; position:absolute; z-index:20; display:none; background-color:#000000; filter:alpha(opacity=60); -moz-opacity:.60; opacity:.60"></div>'+
'<div style="top:20px; position:fixed; width:100%; z-index:21;">'+
  '<div id="pubGeneral" style="margin:auto; width:525px;height:610px;z-index:21;background-color:white;display:none;">'+
    '<div id="blocIntro1" style="float:left;width:442px;text-align:justify; padding-top:3px;padding-bottom:10px;padding-left:10px;padding-right:10px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;display:none;color:#4369C7;">'+
    'Nous vous offrons en complément de notre site, un test de personnalité <b>GRATUIT</b> avec notre partenaire pour découvrir l\'amour de votre vie !' + 
    '</div>'+   
    '<div id="blocFermer1" style="float:left;text-align:right; padding-top:3px;padding-bottom:3px;padding-right:10px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;display:none;">'+
    '<a style="color:#4369C7;text-decoration:none;" href="javascript:cacheBrm()"><img src="./img/fermer.gif"/>&nbsp;Fermer</a>'+
    '</div>'+
    '<div id="blocQuest" style="margin:auto auto auto 13px;width:512px; display:none;">'+
    '<a onclick="javascript:cacheBrm();_gaq.push([\'_trackEvent\', \'Aimee500x500\', \'clicked\']);" href="http://action.metaffiliation.com/suivi.php?mclic=S42A614515D117" target="_blank"><img src="http://action.metaffiliation.com/suivi.php?maff=S42A614515D117" border="0"></a>'+
    '</div>'+
    '<div id="blocIntro2" style="width:445px;text-align:center; padding-top:7px;padding-bottom:10px;padding-left:40px;padding-right:40px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;color:#4369C7;display:none;">'+
    'Vous pouvez accèder à des offres de voyance <b>GRATUITE</b> <br/> en <a style="color:#4369C7;font-weight:bold;" style="text-decoration:none;" onclick="javascript:cacheBrm()" href="http://www.sedecouvrir.fr/voyance.php">>>> cliquant ici <<<</a><br/>'+
    '</div>'+  
    '<div id="blocFermer2" style="text-align:center; padding-top:1px;padding-right:0px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;display:none;">'+
    '<a style="color:#4369C7;font-weight:bold;" href="javascript:cacheBrm()">Accès direct à SeDecouvrir.fr</a>'+
    '</div>'+
  '</div>'+
'</div>');
if (lireCookie("layer2")!=null) return;
pubUnder4();
}

/*
if (nbreAlea2>0 && nbreAlea2<=50)
{pubUnder1();}

if (nbreAlea2>50 && nbreAlea2<=100)
{pubUnder2();}
}

var varFreq=100;
var nbreAlea2=alea(varFreq);
*/

//if (lireCookie("layer")!=null) {return;}
/*
var varFreq=100;
var nbreAlea2=alea(varFreq);
if (nbreAlea2<=33)
{pub1();}

if (nbreAlea2>33 && nbreAlea2<=66)
{pub2();}

if (nbreAlea2>66 && nbreAlea2<=100)
{pub3();}
*/
if (navigator.userAgent.search("Googlebot|bingbot|slurp|MSNBot|VoilaBot") == -1)
{
pub6();
setTimeout('openpp()', 1);
}
