/******************************************
 * Fonctions pour afficher/masquer un DIV *
 ******************************************/

function showDiv(divId)
{
	if (document.getElementById(divId) != null) document.getElementById(divId).style.display = "block";
}

function hideDiv(divId)
{
	if (document.getElementById(divId) != null) document.getElementById(divId).style.display = "none";
}


/**********************************
 * Fonctions pour les formulaires *
 **********************************/
//Verifie si un champs est vide
function isEmpty(field){
	if(field==null) return true;
	if(field.length<1) return true;
	for(i=0;i<field.length;i++) {
		if(field.charAt(i)!=' ') return false;
	}
	return true;
}

//Verifie le format d'un integer pour une valeur
function checkInt(theint) {
	return checkInteger(theint);
}
function checkInteger(theint) {
	if(theint==null) return true;
	if(theint.length<1) return true;
	for(i=0;i<theint.length;i++) {
	   c =  theint.charAt(i);
	   if(c<'0' || '9'<c ) return false;
	}
	return true;
}

//Verifie si un champs email est valide : s'il est different de nul et s'il contient un @
function isMail(field)
{
	if ( field.indexOf( ' ' ) >= 0 ) 	return false ;
	if(field.length < 5 ) 		 	return false ;
	if(field.indexOf('@') < 2 ) 	 	return false;

	var i = field.indexOf('@');
	if( i <= 0 ) return false;

	field =  field.substring( i + 1 , field.length );
	var j = field.indexOf('@');
	if( j >= 0 ) return false ;

	if( field.length < 1 )  return false;

	var j = field.indexOf( '.' );
	if ( j <= 0 ) return false;
	if ( field.substring( 0 ,j ) <= 0 ) return false;
	if ( field.substring( j+1 , field.length ) <= 0 ) return false;

	return true;
}