function infos(field, contenu, cible){
	if(contenu){
	document.getElementById(cible).innerHTML = contenu;
	}else{
	document.getElementById(cible).innerHTML = '';
	}
}


function reinit(field){
	
	var img = 'img_'+field.id;
	document.getElementById(img).src = '/theme/default/image/pict_form/spacer.gif';
	document.getElementById('info_'+field.id).innerHTML = '';
	
}


function testfieldvalue(field, type, required)
{
	
	var urlimageok='/theme/default/image/pict_form/form-field-ok.gif';

	var urlimageko='/theme/default/image/pict_form/form-field-ko.gif';
	
	var urlimagenull='/theme/default/image/pict_form/form-field-ok.gif';
	var tabpatternjs=new Array();
	tabpatternjs['alphanumeric_'] = /^[a-zA-Z0-9_\-\.]*$/;
	tabpatternjs['alphanumeric'] = /^[a-zA-Z0-9\-\.]*$/;
	tabpatternjs['domain'] = /^[a-zA-Z0-9\-]{3,}$/;
	tabpatternjs['numeric'] = /^[0-9]+$/;
	tabpatternjs['directory'] = /^[a-zA-Z0-9\-\.\/]*$/;
	tabpatternjs['url'] = /^(http|https|ftp)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?\,\'\/\\+&%$#\=~])*$/;
	tabpatternjs['email'] = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	tabpatternjs['heure'] = /^([0-1]?[0-9]|[2][0-3]):([0-5][0-9])$/;
	tabpatternjs['ip'] = /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/;
	tabpatternjs['date'] = /^(((0[1-9]|[12][0-9]|3[01])([\/])(0[13578]|10|12)([\/])([1-2][0-9][0-9][0-9]))|((0[1-9]|[12][0-9]|30)([\/])(0[469]|11)([\/])([1-2][0-9][0-9][0-9]))|((0[1-9]|[12][0-9])([\/])(02)([\/])([1-2][0-9][0-9][0-9])))$/;
	tabpatternjs['phone'] = /^[ 0-9\-\.\+\(\)]+$/;
	tabpatternjs['cp'] = /^([0-9]{5})$/;
	//'
	//Récupere le nom du champ concerné
	var img = 'img_'+field.id;
	var imagetochange=document.getElementById(img);
	var restest=false;
	
	//si le champ ne doit pas etre vide
	if (type=="notempty")
	{
		
		if (field.value.length>0)
		{
			restest=true;
		}
		else
		{
			restest=false;
		}
	}
	//autre cas (utilisation des pattern)
	else
	{
		//Si le champ n'est pas vide alors vérification du pattern
		if (field.value.length>0)
		{
			pattern=tabpatternjs[type];

			if (pattern.test(field.value))
			{
				restest=true;
			}
			else
			{
				restest=false;
			}
		}
		else
		{
			if (required=='1')
			{
				restest=false;
			}
			else
			{
				restest=null;
			}
		}

	}
	if (restest==true)
	{
		if (urlimageok!="")
		{
			imagetochange.src=urlimageok;
		}
		field.setAttribute("class","");
		imagetochange.alt="";
		imagetochange.title="";
	}
	if (restest==false)
	{
		if (urlimageko!="")
		{
			imagetochange.src=urlimageko;
		}
		field.setAttribute("class","form_input_error");
		imagetochange.alt="Valeur invalide";
		imagetochange.title="Valeur invalide";
		
	}
	if (restest==null)
	{
		if (urlimagenull!="")
		{
			imagetochange.alt="";
			imagetochange.title="";
			imagetochange.src=urlimagenull;
			
		}
	}
}

function activ_bouton(){
	document.getElementById('valider').disabled = true;
}
