$(function() {
	var aData = [];
	$('div.encadre_recherche form')
	.find('label').each(function() {
		var tLabel = $(this).hide().text(), tInput;
		var input = document.getElementById($(this).attr('for'));
		switch (input.nodeName.toUpperCase())
		{
			case 'INPUT':
				aData.push({'input': input, 'label': tLabel});
				$(input).val(tLabel)
				.focus(function() {
					tInput = $.trim(this.value);
					if (tLabel == tInput)
					{
						this.value = '';
					}
				})
				.blur(function() {
					tInput = $.trim(this.value);
					if (0 === tInput.length)
					{
						this.value = tLabel;
					}
				});
				break;
			case 'SELECT':
			    var $cloned = $('option:first', input).clone();
				$('option:first', input).html(tLabel).attr('disabled', 'disabled')
				.after($cloned);
				break;
			default:
				break;
		}
	})
	.end().submit(function() {
		for (var i = aData.length - 1; 0 <= i; --i)
		{
			if (aData[i].input.value == aData[i].label)
			{
				aData[i].input.value = '';
			}
		}
		return true;
	});
});
