
if(ReadCookie("sondagePopUp") != 1){

    // Inclusion de de d'autres fichier  	
    //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    //document.write('<script type="text/javascript" src="http://sondage.extractmarketing.com/popUp/dom-drag.js"></script>'); 
    document.write('<link rel="stylesheet" href="http://sondage.extractmarketing.com/popUp/popUp_AEE.css" type="text/css">'); 
    
   
    var content;
    
    content = "<div id='overlay' style='filter: alpha(opacity=77);-moz-opacity: 0.77;opacity: 0.77;top: 0pt; left: 0pt; width: 100%; display: block; height: 0px; position: absolute; z-index: 90;background-image:url(http://sondage.extractmarketing.com/popUp/images/overlay.png)'></div>"
    
    content += "<div id='popup_div' class='popup_div' name='popup_div' style='width:600px;display:none;z-index: 100; left: 344px; top: 48px; position: absolute;'>";
    
    content += "   <table class='popup_table'>";
    content += "           <td class='popup_content'>";
    content += "               <table cellpadding=\"0\" cellspacing=\"0\">";
    content += "                   <tr>";
    content += "                       <td id='popup_core' style='border:0px none'>";
    
    // CONTENU DU POP-UP ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    // voir ce site pour caractère spéciaux : http://www.yourhtmlsource.com/text/specialcharacters.html
    
    content += "<table border=\"0\" cellpadding=\"20\" cellspacing=\"0\">";
    content += "  <tr>";
    content += "    <td width=\"200\" valign=\"top\" style='border:0px none'>";
    content += "<div align=\"center\" ><img src=\"http://sondage.extractmarketing.com/popUp/images/logo_aee.gif\" alt=\"\" border=\"0\"></div>";
    content += "    </td>";
    content += "    <td width=\"400\" style='border:0px none'>";
    content += "       <div id='content_fr' style='display:none;'>";
    content += "           <div align=\"right\"><a href=\"javascript:switchLang('en')\">English</a></div><br><br>";
    content += "           <div class=\"titre1\">Votre opinion nous int&eacute;resse!</div>";
    content += "           <br><br>";
    content += "           Apr&egrave;s votre visite, seriez-vous pr&ecirc;t &agrave; r&eacute;pondre &agrave; un court sondage pour &eacute;valuer le site Internet de l'Agence de l'efficacit&eacute; &eacute;nerg&eacute;tique?";
    content += "           <br><br>";
    content += "           Au maximum, 3 minutes seront n&eacute;cessaires pour remplir l'&eacute;valuation.";
    content += "           <br><br>";
    content += "           <strong>Pour participer...</strong><br>";
    content += "           Rien de plus facile! Cliquez sur le bouton &laquo;Oui&raquo; ci-dessous et une nouvelle fen&ecirc;tre s'ouvrira sur votre bureau. Attendez d'avoir termin&eacute; votre visite du site de l'Agence avant de remplir le sondage.";
    content += "           <br><br>";
    content += "           <a href='javascript:answer(1)' class=\"bouton\">Oui</a>&nbsp;&nbsp;&nbsp;<a href='javascript:answer(2)' class=\"bouton\" style=\"color:#FFFFFF\">Non</a>";
    content += "           <br><br>";
    content += "           <strong>Merci de votre collaboration!</strong>";
    content += "           <br><br>";
    content += "           Soyez assur&eacute;s que toutes vos r&eacute;ponses demeureront strictement confidentielles.";
    content += "       </div>";
    content += "       <div id='content_en' style='display:none'>";
    content += "           <div align=\"right\"><a href=\"javascript:switchLang('fr')\">Fran&ccedil;ais</a></div><br><br>";
    content += "           <div class=\"titre1\">Your opinion matters to us.</div>";
    content += "           <br><br>";
    content += "           At the end of your visit, would you be willing to answer a short survey to evaluate the Agence de l'efficacit&eacute; &eacute;nerg&eacute;tique website?";
    content += "           <br><br>";
    content += "           It takes no more than 3 minutes to complete the evaluation.";
    content += "           <br><br>";
    content += "           <strong>To participate...</strong><br>";
    content += "           It's simple! Click on the \"Yes\" button below and a new window will pop up on your desktop. Please wait until you have finished visiting the AEE website before completing the survey.";
    content += "           <br><br>";
    content += "           <a href='javascript:answer(1)' class=\"bouton\">Yes</a>&nbsp;&nbsp;&nbsp;<a href='javascript:answer(2)' class=\"bouton\" style=\"color:#FFFFFF\">No</a>";
    content += "           <br><br>";
    content += "           <strong>Thank you for your collaboration!</strong>";
    content += "           <br><br>";
    content += "           Please be assured that your responses will remain strictly confidential.";
    content += "       </div>";
    content += "    </td>";
    content += "  </tr>";
    content += "</table>";
           
    //¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    content += "                       </td>";
    
    content += "                   </tr>";
    content += "               </table>";
    content += "           </td>";
    content += "       </tr>";
    content += "   </table>";
    content += "</div>";
    
    document.write(content);
}

addLoadEvent(function() {
  if(ReadCookie("sondagePopUp") != 1)
  {
     initPage();
     //drag();
  }
});

//*************************************************************************************
// Initialisation de la page
//*************************************************************************************

function initPage(){
  
 if( window.innerHeight && window.scrollMaxY ) // Firefox 
 {
    pageWidth = window.innerWidth + window.scrollMaxX;
    pageHeight = window.innerHeight + window.scrollMaxY;
 }
 else
 {
 	 if(document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
 	 {
       pageWidth = document.body.scrollWidth;
       pageHeight = document.body.scrollHeight;
    }
    else
    {
        pageWidth = document.body.offsetWidth + document.body.offsetLeft; pageHeight = document.body.offsetHeight + document.body.offsetTop;
    }
 }

 document.getElementById("overlay").style.height = pageHeight + "px";

 switchLang(lang);
 document.getElementById("popup_div").style.display = "";
 centerPopup("popup_div");


  //drag();
  
  
}


//*************************************************************************************
// L'usager a cliqué sur une réponse
//*************************************************************************************

function answer(ans){
   if(ans==1){
   	 var param = "";

   	 if(isset("sid"))  param += "&sid="  + sid;
   	 if(isset("lang")) param += "&lang=" + lang;

     openMax("http://sondage.extractmarketing.com/index.php?ref=pop" + param);
   }
   Set_Cookie("sondagePopUp",1,999);

// Compilation des statistiques
//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
    var newimg=document.createElement('img');
    newimg.src="http://sondage.extractmarketing.com/popUp/compileStats.php?sid=" + sid + "&ans=" + ans + "&lang=" + lang;

    document.getElementById('popup_div').appendChild(newimg);

// Masquer le pop-Up
//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
   document.getElementById("overlay").style.display = 'none';
   document.getElementById("popup_div").style.display = 'none';
}


//*************************************************************************************
// Ouverture d'une page en mode maximisée
//*************************************************************************************

function openMax(page) {
  var wihe = 'width='+screen.availWidth+',height='+screen.availHeight;
  window.open(page, "foo", "screenX=1,screenY=1,left=1,top=1,location=yes,toolbar=yes,directories=yes,menubar=yes,status=yes,scrollbars=yes," + wihe);
  window.focus();
} 


//*************************************************************************************
// Dépose un cookie
//*************************************************************************************

function Set_Cookie( name, value, expires, path, domain, secure )
{
  // set time, it's in milliseconds
  var today = new Date();
  today.setTime( today.getTime() );
  
  /*
  if the expires variable is set, make the correct
  expires time, the current script below will set
  it for x number of days, to make it for hours,
  delete * 24, for minutes, delete * 60 * 24
  */
  if ( expires )
  {
  expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );
  
  document.cookie = name + "=" +escape( value ) +
  ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
  ( ( path ) ? ";path=" + path : "" ) +
  ( ( domain ) ? ";domain=" + domain : "" ) +
  ( ( secure ) ? ";secure" : "" );
}


//*************************************************************************************
// Lire un cookie
//*************************************************************************************

function ReadCookie(cookieName) {

 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 
 if (ind==-1 || cookieName=="") return "" 
 
 var ind1=theCookie.indexOf(';',ind);
 
 if (ind1==-1) ind1=theCookie.length; 
 
return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
//return ""; //Activer cette ligne et désactiver la ligne supérieur pour ne pas utiliser les cookies
}


//*************************************************************************************
// Permet au popUp d'être déplacé avec la souris
//*************************************************************************************

function drag() { 
   var oRoot   = document.getElementById("popup_div");
   var oHandle = document.getElementById("popup_handle");
   
   if(oRoot && oHandle) 
   {
       Drag.init(oHandle, oRoot);
   }
} 

//*************************************************************************************
// Permet de centrer le popUp
//*************************************************************************************

function centerPopup(element) {
     if( window.innerHeight && window.scrollMaxY ) // Firefox 
     {
        pageWidth = window.innerWidth;// + window.scrollMaxX;
        pageHeight = window.innerHeight;// + window.scrollMaxY;
     }
     else
     {
     	 if(document.body.scrollHeight > document.body.offsetHeight ) // all but Explorer Mac
     	 {
           pageWidth = document.body.scrollWidth;
           pageHeight = document.body.scrollHeight;
        }
        else
        {
            pageWidth = document.body.offsetWidth;// + document.body.offsetLeft; 
            pageHeight = document.body.offsetHeight - document.body.offsetTop;
            pageHeight=-100;
        }
     }

	var height=document.getElementById(element).offsetHeight;//hauteur de l'élément à positionner
	var width=document.getElementById(element).offsetWidth;//largeur de l'élément à positionner
	myParent=document.getElementById(element).parentNode;
	var pHeight=myParent.offsetHeight;//Hauteur de l'élément parent
	var pWidth=myParent.offsetWidth;//Largeur de l'élément parent
	var sTop=myParent.scrollTop;//Hauteur de défilement de l'élément parent
	var sLeft=myParent.scrollLeft;//Longueur de défilement de l'élément parent
	var posY=(pHeight/2)-(height/2)+sTop;//Calcul de la position en Y
	var posX=(pWidth/2)-(width/2)+sLeft;//Calcul de la position en X


//pageHeight = window.innerHeight;
//pageWidth = window.innerWidth;
	
	sTop=0;//Hauteur de défilement de l'élément parent
	sLeft=0;//Longueur de défilement de l'élément parent
	posY=(pageHeight/2)-(height/2)+sTop;//Calcul de la position en Y
	posX=(pageWidth/2)-(width/2)+sLeft;//Calcul de la position en X

     //	alert("pageHeight :" + window.scrollMaxY);
     	//alert("pageWidth :" + pageWidth);
//     	alert("scrool :" + pageHeight);
//     	alert(document.body.scrollHeight);
     
     if(posY > sTop){
	    document.getElementById(element).style.top= (posY) +"px";
	}

	document.getElementById(element).style.left=posX+"px";
}

//*************************************************************************************
// Vérifie si une variable est initialisée
//*************************************************************************************

function isset(tVar)
{
	try
	{
		var tmp = eval(tVar);
	}
	catch (e)
	{
		return false;
	}
	return true;
}

function switchLang(lang_){
  
  if(lang_=="fr"){
     document.getElementById('content_en').style.display = "none";
     document.getElementById('content_fr').style.display = "";
  }

  if(lang_=="en"){
     document.getElementById('content_fr').style.display = "none";
     document.getElementById('content_en').style.display = "";
  }
  lang = lang_;
}




function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}