function position(obj)
{
	var coordonnees = new Array();
	
	if (obj.offsetParent)
	{
		coordonnees['x'] = obj.offsetLeft;
		coordonnees['y'] = obj.offsetTop;
		
		while (obj = obj.offsetParent)
		{
			coordonnees['x'] += obj.offsetLeft;
			coordonnees['y'] += obj.offsetTop;
		}
	}
	
	return coordonnees;
}

window.onload = function()
{
	var ancreRecherche = document.getElementById('recherche');
	var positionAncre = position(ancreRecherche);
	
	var formulaire = document.createElement('form');
		formulaire.id = 'formulaire_recherche';
		formulaire.action = 'recherche.php';
		formulaire.method = 'get';
		formulaire.style.position = 'absolute';
		formulaire.style.display = 'none';
		formulaire.style.top = positionAncre['y'] + 25 + 'px';
		formulaire.style.left = positionAncre['x'] + 'px';
	
	var champ = document.createElement('input');
		champ.type = 'text';
		champ.name = 'q';
	
	var bouton = document.createElement('input');
		bouton.type = 'submit';
		bouton.value = 'Rechercher';
	
	formulaire.appendChild(champ);
	formulaire.appendChild(document.createTextNode(' '));
	formulaire.appendChild(bouton);
	
	formulaire.onsubmit = function()
	{
		if(this.elements['q'].value == '')
		{
			alert('Merci d\'entrer une recherche');
			this.elements['q'].focus();
			return false;
		}
		
		return true;
	};
	
	document.documentElement.appendChild(formulaire);
	
	ancreRecherche.onclick = function()
	{
		Effect.toggle('formulaire_recherche', 'appear', { duration:0.5 });
		return false;
	};
};
