var closeFlash = ""; // ne pas changer
var timer = 20000; // delais de fermeture en milliseconde

function initPopin(){
    //closeFlash = setTimeout('closeAutoPopin',timer);

    // liens ouvrir et fermer
    var all_links=document.getElementsByTagName("a");
    for(var i=0; i<all_links.length;i++){
	var link=all_links[i];
	if(link.className && (" " + link.className + " " ).indexOf(" fermerLePopin ") != -1){
	    link.onclick = function() {
		this.parentNode.parentNode.style.display = "none";
		return false;
	    }
	}
	else if(link.className && (" " + link.className + " " ).indexOf(" popinButton ") != -1){
	    link.onclick = function() {
		document.getElementById(this.getAttribute("href").split("#")[1]).style.display = "block";
		return false;
	    }
	}
    }
    // masquage popin
    var all_divs=document.getElementsByTagName("div");
    for(var i=0; i<all_divs.length;i++){
      var div=all_divs[i];
      if(div.className && (" " + div.className + " " ).indexOf(" popinAdd ") != -1) {
	  //div.style.display = "none";
      }
      }
}

function fermer_popin(popinName) {
    document.getElementById("popin" + popinName).style.display = "none";
    if (closeFlash != "") clearTimeout(closeFlash);
}

function closeAutoPopin() {
	
	popin169 = document.getElementById("popin169");
	popinCarre = document.getElementById("popinCarre");
	popinInterstitiel = document.getElementById("popinInterstitiel");
	
	if (popinInterstitiel !== null) {
		document.getElementById("popinInterstitiel").style.display = "none";
	}
	
	if (popin169 !== null) {
		document.getElementById("popin169").style.display = "none";
	}
	
	if (popinCarre !== null) {
		document.getElementById("popinCarre").style.display = "none";
	}
	
    if (closeFlash != "") {
    	clearTimeout(closeFlash);
	}
}

//initialisation au chargement de la page
addLoadListener(initPopin);