var totocaca = new Array();

function CreerListe(nom, hauteur, largeur) {
	this.nom=nom; this.hauteur=hauteur; this.largeur=largeur;
	this.search="";
	this.nb=0; 
	this.Add=AjouterItem;
	this.Afficher=AfficherListe;
	this.MAJ=MAJListe;
}

function AjouterItem(item) {
	totocaca[this.nb]=item
	this.nb++;
}

affich_semi_resultats = false;

function AfficherListe() {
	
	var Z='<select name="'+this.nom+'" size="'+this.hauteur+'" onclick="document.monform.submit()" id="semi_resultats">';
	
	for (var i=0; i<this.nb; i++) {
		Z+='<option value="'+totocaca[i]+'">'+totocaca[i]+'<\/option>'		
	}
	Z+="<\/select>"
	document.write(Z);
}
var lockanim = 0;
var liste_moteurs_id = new Array;
liste_moteurs_id['gg:'] = 'googl';
liste_moteurs_id[''] = 'kacc';
liste_moteurs_id['wp:'] = 'wikip';
liste_moteurs_id['el:'] = 'exal';

function MAJListe(txt,f) {
	if (txt!=this.search) {
		this.search=txt
		f.nom.options.length=0; 
		test_moteur_auto = txt.substring(0,3).toLowerCase();
		if ( 
		
		test_moteur_auto == 'wp:' ||
		test_moteur_auto == 'gg:' ||
		test_moteur_auto == 'el:' ||
		test_moteur_auto == 'av:' ||
		test_moteur_auto == 'vl:' ||
		test_moteur_auto == 'yt:' ||
		test_moteur_auto == 'dm:' ||
		test_moteur_auto == 'sn:' ||
		test_moteur_auto == 'az:' ||
		test_moteur_auto == 'fb:' ||
		test_moteur_auto == 'yh:' ||
		test_moteur_auto == 'jm:' ||
		test_moteur_auto == 'vm:' ||
		test_moteur_auto == 'wd:' ||
		test_moteur_auto == 'wt:' ||
		test_moteur_auto == 'fk:' ||
		test_moteur_auto == 'wc:' ||
		test_moteur_auto == 'cj:' ||
		test_moteur_auto == 'sy:' ||
		test_moteur_auto == 'ed:' ||
		test_moteur_auto == 'wh:' ||
		test_moteur_auto == 'mf:'
		
		
		) {
			var o=new Option('Recherche spéciale', '');
			f.nom.options[f.nom.options.length]=o;
			document.getElementById("semi_resultats").style.color='#777777';
			document.getElementById("input_search").style.fontWeight='bold';
			//Effect.Scale('semi_resultats', 20);
			if ( test_moteur_auto == 'wp:' || test_moteur_auto == 'gg:' || test_moteur_auto == 'el:' ) {
				surbri(liste_moteurs_id[test_moteur_auto]);
			}
			//lockanim++;
		} else {
			var po=0;
			for (var i=0; i<this.nb; i++) {
				if ( totocaca[i].substring(0,txt.length).toUpperCase() == txt.toUpperCase() ) {
					var o=new Option(totocaca[i], totocaca[i]);
					f.nom.options[f.nom.options.length]=o;
					po++;
				}
			}
			document.getElementById("semi_resultats").style.color='#000000';
			document.getElementById("input_search").style.fontWeight='normal';
			f.nom.selectedIndex=0;
			
			
			if (po == 0) {
				var o=new Option('Recherche Google', '');
				f.nom.options[f.nom.options.length]=o;
				document.getElementById("semi_resultats").style.color='#777777';
				document.getElementById("input_search").style.fontWeight='bold';
				surbri('googl');
			} else {
				surbri('kacc');
			}
			//visualEffect('blind_down',{duration:1.5});
			//surbri('kacc');
			//Effect.Scale('semi_resultats', 100);
			//lockanim++;
		}
	}
}

function ListeCheck() {
	Liste.MAJ(document.forms["monform"].search.value,document.forms["monform"]);
	/*if (document.layers) {
		setTimeout("ListeCheck()", 1001);
		document.forms["monform"].search.value = 'toto';
	} else {*/
		setTimeout("ListeCheck()", 100);
		//document.forms["monform"].search.value = 'caca';
	//}
}

function affich(type)
		{
		if (type == "image") {
			if (document.aj_site.adresse_logo.value == "http://")
				{
				document.aj_site.adresse_logo.value = "";
				return false;
				}
			if (document.aj_site.adresse_logo.value == "Adresse de l'image")
				{
				document.aj_site.adresse_logo.value = "http://";
				return false;
				}
		
		} else {
			if (document.aj_site.adresse.value == "http://")
				{
				document.aj_site.adresse.value = "";
				return false;
				}
			if (document.aj_site.adresse.value == "Adresse du site")
				{
				document.aj_site.adresse.value = "http://";
				return false;
				}
			}
		}

function affich_form_logo() {
	if (document.aj_site.qlogo[1].checked) {
		document.getElementById("form_logo1").style.display = "block";
		document.getElementById("form_logo2").style.display = "none";
	} else if (document.aj_site.qlogo[2].checked) {
		document.getElementById("form_logo1").style.display = "none";
		document.getElementById("form_logo2").style.display = "block";
	} else {
		document.getElementById("form_logo1").style.display = "none";
		document.getElementById("form_logo2").style.display = "none";
	}

}
		
function moteur_change(moteur) {
	if (moteur == 'kacc') {
		if ( document.monform.search.value.substring(0,3) == 'wp:' || document.monform.search.value.substring(0,3) == 'gg:' || document.monform.search.value.substring(0,3) == 'el:' ) {
			document.monform.search.value = document.monform.search.value.substring(3);
		}
	}
	if (moteur == 'wikip') {
		if ( document.monform.search.value.substring(0,3) != 'wp:' && document.monform.search.value.substring(0,3) != 'gg:' && document.monform.search.value.substring(0,3) != 'el:' ) {
			document.monform.search.value = 'wp:'+ document.monform.search.value;
		} else {
			document.monform.search.value = 'wp:'+ document.monform.search.value.substring(3,document.monform.search.value.length);
		}
	}
	if (moteur == 'exal') {
		if ( document.monform.search.value.substring(0,3).toLowerCase() != 'wp:' && document.monform.search.value.substring(0,3).toLowerCase() != 'gg:' && document.monform.search.value.substring(0,3).toLowerCase() != 'el:' ) {
			document.monform.search.value = 'el:'+ document.monform.search.value;
		} else {
			document.monform.search.value = 'el:'+ document.monform.search.value.substring(3,document.monform.search.value.length);
		}
	}
	if (moteur == 'googl') {
		if ( document.monform.search.value.substring(0,3).toLowerCase() != 'wp:' && document.monform.search.value.substring(0,3).toLowerCase() != 'gg:' && document.monform.search.value.substring(0,3).toLowerCase() != 'el:' ) {
			document.monform.search.value = 'gg:'+ document.monform.search.value;
		} else {
			document.monform.search.value = 'gg:'+ document.monform.search.value.substring(3,document.monform.search.value.length);
		}
	}
	
	surbri(moteur);
}

function surbri(cible) {
var liste_moteurs = new Array('googl', 'kacc', 'wikip', 'exal');
	for (i=0 ; i<liste_moteurs.length ; i++) {
		if (liste_moteurs[i] == cible) {
			document.getElementById("mrech_"+ liste_moteurs[i]).style.fontWeight='bold';
			
		} else {
			document.getElementById("mrech_"+ liste_moteurs[i]).style.fontWeight='normal';
		}
	}
	if (cible == 'kacc' && affich_semi_resultats) {
		Effect.SlideDown('semi_resultats',{queue:{scope:'myscope', position:'end', limit: 0.3}});
		affich_semi_resultats = false;
	} else if (cible != 'kacc' && !affich_semi_resultats) {
		Effect.SlideUp('semi_resultats',{queue:{scope:'myscope', position:'end', limit: 0.3}});
		affich_semi_resultats = true;
	}
	
	if (affich_semi_resultats) {
		document.getElementById("input_search").style.borderColor='#00FF00';
	} else {
		document.getElementById("input_search").style.borderColor='#FF0000';
	}
	document.monform.search.focus();
}
