Alpha=new String(" abcdefghijklmnopqrstuvwxyz");
Compt=new Array();
if(document.images)
{
	LettresOver=new Array();
	LettresOut=new Array();
	for(N=1; N<27;N++)
	{
			var L=Alpha.charAt(N);
			LettresOut["\""+L+"\""]=new Image(); LettresOut["\""+L+"\""].src="images/"+L+".gif";
			LettresOver["\""+L+"\""]=new Image(); LettresOver["\""+L+"\""].src="images/"+L+"c.gif";		
			Compt[N]=0;
	}
	
}

////////////////////////////////////////////////////////
function ChangeIma(Ou,Quoi)
{
	var Lieu="Touche_"+Ou;
	L=Ou;
	if(Quoi=="Over")document.images[Lieu].src=LettresOver["\""+L+"\""].src;
	if(Quoi=="Out")document.images[Lieu].src=LettresOut["\""+L+"\""].src;
}

////////////////////////////////////////////////////////
function Affiche_Lettres()
{
	document.write("<table cellpadding=0 cellspacing=0 border=0><tr>");
	for(N=1; N<=26;N++)
	{
			var L=Alpha.charAt(N);
			document.write("<td><a href='javascript:void(0)' onClick='AfficheIntitule(\""+L+"\")'><img src='images/"+L+".gif' alt='"+Compt[N]+" Commune"+(Compt[N]>1 ? "s" : "")+"' "
			+" onMouseOver='ChangeIma(\""+L+"\",\"Over\")'; onMouseOut='ChangeIma(\""+L+"\",\"Out\")' name='Touche_"+L+"' border=0></a></td>");
			if(N%13==0)document.write("</tr><tr>");
	}
	document.write("</table>");



//Nbre_Numeros=396
//document.write("<span class='titre'>Afficher les réponses par N° Commune</span><select name='Numeros' //onChange='AfficheNumero(this.selectedIndex+0)' class='colonnec2'>");
//document.write("<option>N°</option>");
//	for(i=1; i<Nbre_Numeros; i++)
//	{
//			document.write("<option>"+i+"</options>");
//	}
//	document.write("<option selected>"+Nbre_Numeros+"</options>");
//	document.write("</select><p>");
//	
}//

////////////////////////////////////////////////////////

for(M=1;M<Int.length;M++)
{
	Lettre=Int[M][0].charAt(0);
	Rang=Alpha.indexOf(Lettre.toLowerCase());
	Compt[Rang]++;
}

////////////////////////////////////////////////////////
Int.sort();

////////////////////////////////////////////////////////
Num=new Array();
for(N=0;N<Int.length-1;N++)
{
	Num[N]=new Array();
	Num[N][0]=Int[N][3];
	Num[N][1]=Int[N][0];
	Num[N][2]=Int[N][1];
	Num[N][3]=Int[N][2];
}

////////////////////////////////////////////////////////
Num.sort();

////////////////////////////////////////////////////////
Compteur=0;
var Deb;

function AfficheIntitule(L)
{
	Compteur=0;
	//Int[0]=new Array("Communes","Cantons","Arrondissement","N° INSEE");
	Tri.innerText=" obtenue par ordre alphabétique";
	Deb=true;
	L=L.toUpperCase();
	var ListeC="<table cellpadding=0 cellspacing=2 border=0><tr class='titre'><td>Lieux dits</td>"
	+"<td>Cantons</td>"
	+"<td>Communes</td><td>N° de Commune</td></tr>";
	for(M=0;M<Int.length-1;M++)
	{
			//alert(Int[M][0]+" "+Int[M][0].charAt(0));
		var Tmp=Int[M][0].charAt(0);
		if(Tmp!=L && Deb==true)continue;
		else if(Tmp==L)
		{
				Compteur++;
				if(Compteur==1)var ListeC="<table cellpadding=0 cellspacing=2 border=0>"
				+"<tr class='titre'><td>Communes</td><td>Cantons</td><td>Arrondissements</td><td>N° INSEE</td></tr>";

				ListeC+="<tr><td class='colonneg'>"+Int[M][0]+"</td><td class='colonnec'>"+Int[M][1]+"</td><td class='colonned'>"+Int[M][2]+"</td><td class='colonnec'>"+(Int[M][3]!="*" ? (Int[M][3]!="**" ? ("<a href='javascript:void(0)' onClick='AfficheNumero("+Int[M][3]+")'>"+Int[M][3]+"</a>") : Int[M][3]) : Int[M][3])+"</td></tr>"
				+"<tr><td colspan=3 class='sous'>&nbsp;</td></tr>";
				Deb=false;
				
		}
		else if(Tmp!=L && Deb==false)break;
	}
	if(Compteur>0)ListeC="<span class='titre' valign='middle'>"+Compteur+" Commune"+(Compteur>1 ? "s" : "")+" pour la lettre "+L+"</span><br><br>"+ListeC+"</table>";
	else ListeC="<span class='titre'>Pas de réponse commençant par "+L+"</span><br>";
	resultat.innerHTML=ListeC;
}

function AfficheNumero(num)
{
Tri.innerText=" obtenue par numéro de commune";
	//Int[0]=new Array("Communes","Cantons","Arrondissements","N° INSEE");
	Deb=true;
	Compteur=0;

		for(M=0;M<Num.length-1;M++)
		{
			var Tmp=Num[M][0]
			if(Tmp!=num && Deb==true)continue;
			else if(Tmp==num)
			{
				Compteur++;
				if(Compteur==1)var ListeLDx="<table cellpadding=0 cellspacing=2 border=0>"
				+"<tr class='titre'><td>N° INSEE</td><td>Commune</td><td>Canton</td><td>Arrondissement</td></tr>";

				ListeLDx+="<tr><td class='colonnec'>"+Num[M][0]+"&nbsp;&nbsp;&nbsp;&nbsp;</td><td class='colonneg'>"+Num[M][1]+"</td><td class='colonnec'>"+Num[M][2]+"</td><td class='colonned'>"+Num[M][3]+"</td></tr>"
				+"<tr><td colspan=3 class='sous'>&nbsp;</td></tr>";
				Deb=false;
			}
			else if(Tmp!=num && Deb==false)break;
		}
		if(Compteur>0)ListeLDx="<span class='titre' valign='middle'>"+Compteur+" réponse"+(Compteur>1 ? "s" : "")+" dans la commune N°"+num+"<br><br>"+ListeLDx+"</table>";
		else ListeLDx="<span class='titre'>Pas de réponse la commune  "+num+"  ne fait pas partie de cet arrondissement</span><br>";
	
	resultat.innerHTML=ListeLDx;
}

