function favori(url, texteFavori)
{
	var ua=navigator.userAgent.toLowerCase();
	var konq=(ua.indexOf('konqueror')!=-1);
	var saf=(ua.indexOf('webkit')!=-1);
	var mac=(ua.indexOf('mac')!=-1);
	var ctrlKey=mac?'Command/Cmd':'CTRL';
	if (window.sidebar)
   	{
		alert('Veuillez appuyer sur' + ' Ctrl + D ' + 'pour ajouter ce site a vos favoris' + '.');
		// Sur FireFox dans le panneau de gauche
		// window.sidebar.addPanel(texteFavori, url,"");
   	}
   	else if( document.all )
   	{
   		window.external.AddFavorite(url, texteFavori);
   	}
   	else if (!window.print || mac) {
   		alert('Veuillez appuyer sur' + ' Command/Cmd + D ' + 'pour ajouter ce site a vos favoris' + '.');
   	} else if (window.home||saf) {
		alert('Veuillez appuyer sur' + ' ' + ctrlKey +' D ' + 'pour ajouter ce site a vos favoris' + '.');
	}
   	else
    {
   		alert('Désolé. Ajoutez manuellement ce lien à vos favoris !');
   	} 
	
	return true;
}

function gerefocus(id) {
	
	if ($(id).value == 'exemple: 3 suisses') {
		$(id).value = '';
	}
	
	$(id).focus();
	
}

function gereunfocus(id) {
	
	if ($(id).value == '') {
		$(id).value = 'exemple: 3 suisses';
	}
	
}

document.observe("dom:loaded", function() {

	new Ajax.Autocompleter(
		"nommarchand",
		"mots_propositions",
		"/suggest.php",
			{
			paramName: 'marchand',
			minChars: 1,
			afterUpdateElement: marchandchoisit
			}
	);
	
	$$('div.bonreduc').each(function(bonreduc) {
		 bonreduc.observe('click', function(event) {
			 if ($('lienbonreduc-' + this.id)) {
				 var lien = $('lienbonreduc-' + this.id).value;
				 window.location.href=lien;
			 }
		 });
	});
	
	

});

function marchandchoisit(inputfield,item) {
	document.forms['recherchebonsreducs'].submit();
}