
var txtAsterisque = "<font color=red> *</font>";
var txtRecherche = "<font";


function changebg(e,a) { 

      if (a == 0) { 
         e.style.backgroundColor=''; 
      } 
      else { 
         e.style.backgroundColor='#B1D0B1'; 
      } 

   } 

function diagAnnee(formulaire) 
{ 
	var date = new Date();
	var anneeEnCours = date.getFullYear();
	
	if (isNaN(formulaire.annee_construction.value)){
		alert("Veuillez saisir une année correcte");
		return ;
	}
	if (formulaire.annee_construction.value.length != 4){
		alert("Veuillez saisir une année sur 4 chiffres");
		return ;
	}
	var annee = parseInt(formulaire.annee_construction.value);
	if(annee < 1997){	// Amiante = 0
		if((document.getElementById("divIdDiag0").innerHTML.indexOf("color=\"red\"") == -1)&&(document.getElementById("divIdDiag0").innerHTML.indexOf("color=red") == -1)){
		document.getElementById("divIdDiag0").innerHTML += txtAsterisque;}
	} else {
		document.getElementById("divIdDiag0").innerHTML = diagSansAsterisque(document.getElementById("divIdDiag0").innerHTML);
	}

	if(annee < 1949){	// Plomb = 7
		if((document.getElementById("divIdDiag7").innerHTML.indexOf("color=\"red\"") == -1)&&(document.getElementById("divIdDiag7").innerHTML.indexOf("color=red") == -1)){
		document.getElementById("divIdDiag7").innerHTML += txtAsterisque;}
	} else {
		document.getElementById("divIdDiag7").innerHTML = diagSansAsterisque(document.getElementById("divIdDiag7").innerHTML);
	}
}

function diagCopro(formulaire)
{ 
	if(formulaire.copropriete.checked == true){   // Carrez = 2     SRU = 8
		if((document.getElementById("divIdDiag2").innerHTML.indexOf("color=\"red\"") == -1)&&(document.getElementById("divIdDiag2").innerHTML.indexOf("color=red") == -1)){
		document.getElementById("divIdDiag2").innerHTML += txtAsterisque;
		}
		if((document.getElementById("divIdDiag8").innerHTML.indexOf("color=\"red\"") == -1)&&(document.getElementById("divIdDiag8").innerHTML.indexOf("color=red") == -1)){
		document.getElementById("divIdDiag8").innerHTML += txtAsterisque;
		}
	} else {	
		document.getElementById("divIdDiag2").innerHTML = diagSansAsterisque(document.getElementById("divIdDiag2").innerHTML);
		document.getElementById("divIdDiag8").innerHTML = diagSansAsterisque(document.getElementById("divIdDiag8").innerHTML);
	}
}

function diaggaz(formulaire) 	// Gaz = 4
{ 
	if(formulaire.gaz[0].checked){
		document.getElementById("divIdDiag4").innerHTML += txtAsterisque;
	} else {
		document.getElementById("divIdDiag4").innerHTML = diagSansAsterisque(document.getElementById("divIdDiag4").innerHTML);
	}
}

function diagelec(formulaire)  // Gaz = 5
{ 
	if(formulaire.elec[0].checked){
		document.getElementById("divIdDiag5").innerHTML += txtAsterisque;
	} else {
		document.getElementById("divIdDiag5").innerHTML = diagSansAsterisque(document.getElementById("divIdDiag5").innerHTML);
	}
}

function diagSansAsterisque(strDiag)
{
	var diag = strDiag.split(txtRecherche);
	if((diag[0].charAt(diag[0].length-1) == ">") && (diag.length == 1)){
		diag = strDiag.split(txtRecherche.toUpperCase());
	}
	return (diag[0]);
}
