//tab=new Array();

function CreerListe(nom, hauteur, largeur)
{
	//alert("creation liste");
	this.nom=nom; this.hauteur=hauteur; this.largeur=largeur;
	this.search="";
	this.search2="";
	this.nb=0;
	this.tab=new Array();
	this.Add=AjouterItem;
	this.Afficher=AfficherListe;
	this.MAJ=MAJListe;
}

function AjouterItem(item,id)
{
	//alert("ajout item "+id);
	this.tab[this.nb]=new Array();
	this.tab[this.nb]["item"]=item;
	this.tab[this.nb]["id"]=id;
	this.nb++;
}

function AfficherListe() {
	//alert("affich liste");
	if (document.layers) { 
		var Z="<SELECT name=\""+this.nom+"\" id=\""+this.nom+"\" size=\""+this.hauteur+"\" class='cs' multiple='true'>";
	} else {
		var Z="<SELECT name=\""+this.nom+"\" id=\""+this.nom+"\" size=\""+this.hauteur+"\" style='width:"+this.largeur+"' class='cs' multiple='true'>";
	}
	for (var i=0; i<this.nb; i++)
	{
		Z+="<OPTION value=\""+this.tab[i]["id"]+"\">"+this.tab[i]["item"]+"</OPTION>";
	}
	Z+="</SELECT>";
	document.write(Z);
}

function MAJListe(txt,txt2)
{
	//alert(this.nom);
	if (txt!=this.search || txt2!=this.search2)
	{
		this.search=txt;
		this.search2=txt2;
		var select = document.getElementById('code_naf12008');
		var NB = 7;
		select.options.length = 0;
		for (var i=0; i<this.nb; i++)
		{
			if(txt2.length==0 && txt.length==0)
			{
				if ( this.tab[i]["item"].substring(0,txt.length).toUpperCase()==txt.toUpperCase() )
				{
					var o=new Option(this.tab[i]["item"], this.tab[i]["id"]);
					select.options[select.options.length]=o;
				}
			}
			
			if(txt2.length==0 && txt.length!=0)
			{
				if ( this.tab[i]["item"].substring(0,txt.length).toUpperCase()==txt.toUpperCase() )
				{
					var o=new Option(this.tab[i]["item"], this.tab[i]["id"]);
					select.options[select.options.length]=o;
				}
			}
			if(txt.length==0 && txt2.length!=0)
			{
				nbsup=NB+txt2.length; 
			//alert(this.tab[i]["item"].substring(nbsup,NB).toUpperCase());
				if ( this.tab[i]["item"].substring(nbsup,NB).toUpperCase()==txt2.toUpperCase() )
				{
					var o=new Option(this.tab[i]["item"], this.tab[i]["id"]);
					select.options[select.options.length]=o;
				}
			}
			if(txt2.length!=0 && txt.length!=0)
			{
				nbsup=NB+txt2.length;
				if ( (this.tab[i]["item"].substring(0,txt.length).toUpperCase()==txt.toUpperCase()) && (this.tab[i]["item"].substring(nbsup,NB).toUpperCase()==txt2.toUpperCase()) )
				{
					var o=new Option(this.tab[i]["item"], this.tab[i]["id"]);
					select.options[select.options.length]=o;
				}
			}
		}
		if (select.options.length==1)
		{
			select.selectedIndex=0;
		}
	}
}



function ListeCheck()
{
	//alert("liste check");
	
		Liste2.MAJ(document.forms["coface"].search.value,document.forms["coface"].search2.value);
	

	if (document.layers) {
		setTimeout("ListeCheck()", 1001)
	} else {
		setTimeout("ListeCheck()", 100)
	}
}