var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"

var bouncelimit=8 //(must be divisible by 8)
var direction="up"

function initbox(){
if (!dom&&!ie&&!ns4)
return
crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossobj.top=scroll_top-200+calunits
crossobj.visibility=(dom||ie)? "visible" : "show"

dropstart=setInterval("dropin()",20)
}

function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossobj.top)<0+scroll_top)
crossobj.top=parseInt(crossobj.top)+20+calunits
else{
clearInterval(dropstart)
bouncestart=setInterval("bouncein()",10)
}
}

function bouncein(){
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1
if (bouncelimit==0){
clearInterval(bouncestart)
}
}

function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
crossobj.visibility="hidden"
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function dropornot(){

	//verifier l'existence du cookie de session.
	var sessioncookie = readCookie("mcsession")
		
	//s'il existe, on ne fait rien
	if(sessioncookie){
		return null
	} else {
		//sinon, on le cree et on cherche le cookie pour le compteur des annonces
		createCookie("mcsession", 1, false)
		
		var nbpopup = readCookie("mcnbpopup")
		var nbpopupINT = 0
		
		//s'il existe, on incremente le nombre d'affichage
		if (nbpopup){
			
			//convertir en integer (le cookie est stocké sous forme de chaine...)			
			nbpopupINT = parseInt(nbpopup, 10)  
			nbpopupINT = nbpopupINT + 1
			
			//convertir en chaine (ajouter une chaine vide...)			
			nbpopup = nbpopupINT + ''
			
			createCookie("mcnbpopup", nbpopup , 14)
		} else {		
			//sinon, on le cree
			createCookie("mcnbpopup", 1, 14)
			nbpopupINT = 1
		}

		//si le nombre d'affichage est inferieur au maximum d'Affichage
		//on affiche le popup		
		if(nbpopupINT <= 5){
					
			setTimeout("initbox()",20000)
			
		}
	}
	
}


//ajouté pour la gestion "correcte" pour les cookies
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


//fonction pour mettre en pause l'exécution JS...

function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
} 
