function lookup(inputString,actionmethod,url) {
	if(inputString.length == 0) {
		// Hide the suggestion box.
		$j('#suggestions').hide();
	} else {
		
		$j.post(url, {queryString: ""+inputString+"",actionmethod: ""+actionmethod+""}, function(data){
			if(data.length >0) {
				$j('#suggestions').show();
				$j('#autoSuggestionsList').html(data);
			}
		});
	}
} // lookup

function fill(thisValue) {
	
	$j('#inputString').val(thisValue);
	setTimeout("$j('#suggestions').hide();", 200);
}
function fill2(thisValue) {
	
	$j('#idville').val(thisValue);
}

function date_fr(el)
{
	if (!el.value.test(/^([0-3][0-9])(\/)([0-1][0-9])(\/)([0-9]{4})/))
	{
		el.errors.push("Veuillez saisir une date de naissance valide au format suivant:<br /><span>Ex. 01/01/1970</span>");
		return false;
	}
	else
	{
		return true;
	}
}

// function de chagement de style au focus des champs
$j(document).ready(function() {
	// gestion du focus des champs pour changer la bordure
	$j('#textContent').find('input.focusField').each(function(){
		$j(this).bind('focus',function(){
			$j(this).addClass('focused');
		});
		$j(this).bind('blur',function(){
			$j(this).removeClass('focused');
		});
	});
	// gestion des boutons radios sous forme d'image
	$j('.radioGroup').find('.radioSubstitute').each(function(){
		$j(this).bind('click',function(){
			if( $j(this).hasClass('radioSubstituteChecked') ){
				// on ne fait rien, le bouton reste sélectionné
			} else {
				// on réinitalise l'état de tous les radios
					$j(this).parent().find('.radioButton').each(function(){
						$j(this).attr('checked','false');
					});
					$j(this).parent().find('.radioSubstitute').each(function(){
						$j(this).removeClass('radioSubstituteChecked');
					});
				// on ajoute la classe
					$j(this).addClass('radioSubstituteChecked');
				// on coche le radio
					$j(this).next('input').attr('checked','true');
			}
			return false;
		});
	});

});
