var numuniv = 0;
var BoolIncitationVisible = 1 ;

var ladate=new Date()
var tab_mois=new Array("Janvier", "F&eacute;vrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Ao&ucirc;t", "Septembre", "Octobre", "Novembre", "D&eacute;cembre");

function recup_var() {
    var filename = "Referrer";
    var requete = window.location.search;
	
    if (requete) {
		requete=requete.substring(1);
		requete = unescape(requete);
	}
			
	else {
		requete="";
	}
			
	var parametre = requete;
		
	if(parametre) {
		urlconcat = "<img src='http://otto-php.cvf.fr/compteclic/ajout.php?"+parametre+"&urlprov="+document.referrer+"' width='1px' height='1px' style='visibility:hidden' />";
		urlconcat2 = "<img src='http://ns201015.ovh.net/rec_log/ajout.aspx?"+parametre+"&urlprov="+document.referrer+"' style='visibility:hidden' />";
		document.write(urlconcat);
		document.write(urlconcat2);					
	}
			
	else {
		urlconcat = "<img src='http://otto-php.cvf.fr/compteclic/ajout.php?Referrer=00000000&urlprov="+document.referrer+"' width='1px' height='1px' style='visibility:hidden' />";
		urlconcat2 = "<img src='http://ns201015.ovh.net/rec_log/ajout.aspx?Referrer=00000000&urlprov="+document.referrer+"' style='visibility:hidden' />";
		document.write(urlconcat);
		document.write(urlconcat2);		
	}
}    
		
function concoMenu(session) {
	var lienconco = "<a href='../conco/conco.cgi'><span>TROUVEZ VOS CONSOMMABLES</span></a>";
	document.write(lienconco);
}
	
function TestIdClientForMyOtto(idclient, session) {
	if((idclient).length <= 0 && document.getElementById('banMyOtto') != null){				
		document.getElementById('banMyOtto').style.visibility = "hidden";
		document.getElementById('banMyOtto').style.display = "none" ;
	}
	else {
		// AB testing home perso ==> xtabvalue==1
		if (getCook("WantHPP") == "" && idclient.length > 0 /*&& xtabvalue==1*/) {
			//Client  n'a jamais choisi d'aller sur my-otto ou de revenir à l'accueil classique
			//document.getElementById('cacheMyOtto').style.visibility = 'visible';
			//document.getElementById('cacheMyOtto').style.display = 'block';
			//document.getElementById('pubMyOtto').style.visibility = 'visible';
			//document.getElementById('pubMyOtto').style.display = 'block';
		}
		else
		{
			if (getCook("WantHPP") == 1 && idclient.length > 0)
			{
				GoToMyOtto(idclient, session);
				//window.location='http://my.otto-office.fr/~ID_CLIENT~_myotto.htm'
			}

		}
	}
}

function getCook(nom) {
	        deb = document.cookie.indexOf(nom + "=")
	        if (deb >= 0) {
	            deb += nom.length + 1
	            fin = document.cookie.indexOf(";",deb)
	            if (fin < 0) fin = document.cookie.length
	            return unescape(document.cookie.substring(deb,fin))
	            }
	        return ""
}

// Remplace toutes les occurences d'une chaine
function replaceAll(str, search, repl) {
    while (str.indexOf(search) != -1)
		str = str.replace(search, repl);
        return str;
    }
		
// encode l'id client pour l'accès à myotto
function ENCODE_ID(str) {
	var norm = new Array('0','1','2','3','4','5','6','7','8','9');
	var spec = new Array('A','Z','u','x','Q','M','n','W','Y','O');
	for (var i = 0; i < spec.length; i++) {
			str = replaceAll(str, norm[i], spec[norm[i]]);
		   
	} 
	return str;
} 
		
function GoToMyOtto(idClient,session) {
	var idCliEncode=ENCODE_ID(idClient);
	var url ='http://my.otto-office.fr/myotto_'+idCliEncode+'.htm?Session='+session;
	window.location=url;
	//window.location='http://my.otto-office.fr/~ID_CLIENT~_myotto.htm'
}

function ReponsePub(WantHPP,idclient,session)
{
	//PoseCookieChoixHPP(WantHPP);
	document.getElementById('cacheMyOtto').style.visibility = 'hidden';
	document.getElementById('cacheMyOtto').style.display = 'none';
	document.getElementById('pubMyOtto').style.visibility = 'hidden';
	document.getElementById('pubMyOtto').style.display = 'none';
	if (WantHPP)
	{
		GoToMyOtto(idclient,session);				
	}
	return true;
}
 function PoseCookieChoixHPP(WantHPP)
{
	if (!WantHPP)
	{
		var exdate = new Date();
		exdate.setDate(exdate.getDate()+60);
		
		document.cookie='WantHPP=0; expires='+exdate.toGMTString()+'; domain=otto-office.fr;path=/';  
	}
	else
	{
		var exdate = new Date();
		exdate.setDate(exdate.getDate()+60); 
		
		document.cookie='WantHPP=1; expires='+exdate.toGMTString()+'; domain=otto-office.fr;path=/';  
	}
	return true;            
}

function modifieTexte() {
	if (getCook("WantHPP") == 1) {
		document.getElementById("textChoixMyOtto").setAttribute("onclick", "PoseCookieChoixHPP(false);xt_med('C','1','HPP_OUT','N');");
		document.getElementById("textChoixMyOtto").innerHTML = "&lt;&lt; Retour &agrave; l'accueil classique ";
	}
	if (getCook("WantHPP") == 0) {
		document.getElementById("textChoixMyOtto").setAttribute("onclick", "PoseCookieChoixHPP(true);xt_med('C','1','HPP_IN','N');");
		document.getElementById("textChoixMyOtto").innerHTML = "&gt;&gt; D&eacute; finir comme accueil par d&eacute;faut";
	}
}