function VerifierDate(oDate_p)
{
    if(oDate_p.value != '')
    {
	    var exp=new RegExp("^[0-9]{1,2}\/[01]?[0-9]\/[0-9]{4}$","g");
	    if(!exp.test(oDate_p.value))
	    {
			if(oDate_p.getAttribute('ControleErreur') != '')
				alert(oDate_p.getAttribute('ControleErreur'));
			else
				alert('Format horraire incorrect !');
			alert('Format de date incorrect !');
			oDate_p.value = '';
			return false;
	    }
    }
    return true;
}

function VerifierHeure(oHeure_p)
{
    if(oHeure_p.value != '')
    {
	    var exp=new RegExp("^[0-9]{1,2}:[0-9]{1,2}$","g");
	    if(!exp.test(oHeure_p.value))
	    {
			if(oHeure_p.getAttribute('ControleErreur') != '')
				alert(oHeure_p.getAttribute('ControleErreur'));
			else
				alert('Format horraire incorrect !');
			oHeure_p.value = '';
			return false;
	    }
    }
    return true;
}

function VerifierNumerique(oNumerique_p)
{
	if(oNumerique_p.value != '')
    {
	    var exp=new RegExp("^[0-9]+$","g");
	    if(!exp.test(oNumerique_p.value))
	    {
		    var exp=new RegExp("^[0-9]+.[0-9]+$","g");
		    if(!exp.test(oNumerique_p.value))
		    {
				if(oNumerique_p.getAttribute('ControleErreur') != '')
					alert(oNumerique_p.getAttribute('ControleErreur'));
				else
					alert('Format numérique incorrect !');
				oNumerique_p.value = '';
				return false;
		    }
	    }
    }
     return true;
} 

function VerifierEntier(oNumerique_p)
{
	if(oNumerique_p.value != '')
    {
	    var exp=new RegExp("^[0-9]+$","g");
	    if(!exp.test(oNumerique_p.value))
	    {
			if(oNumerique_p.getAttribute('ControleErreur') != '')
				alert(oNumerique_p.getAttribute('ControleErreur'));
			else
				alert('Format entier incorrect !');
			oNumerique_p.value = '';
			return false;
	    }
    }
    return true;
} 

function VerifierMail(oMail_p)
{
	if(oMail_p.value != '')
    {
	    var exp=new RegExp(/^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/);
	    if(!exp.test(oMail_p.value))
	    {
			if(oMail_p.getAttribute('ControleErreur') != '')
				alert(oMail_p.getAttribute('ControleErreur'));
			else
				alert('Format Mail incorrect !');
			oMail_p.value = '';
			return false;
	    }
    }
    return true;
}

function VerifierUrl(oUrl_p)
{
	if(oUrl_p.value != '')
    {
	    var exp=new RegExp(/^[abcdefghijklmnopqrstuvwxyz.]+$/);
	    if(!exp.test(oUrl_p.value))
	    {
			if(oUrl_p.getAttribute('ControleErreur') != '')
				alert(oUrl_p.getAttribute('ControleErreur'));
			else
				alert('La valeur du champ est incorrecte !\r\nAucune caractère spécial n\'est autorisé.');
			oUrl_p.value = '';
			return false;
	    }
    }
    return true;
}

function VerifierSousDomaine(oUrl_p)
{
	if(oUrl_p.value != '')
    {
	    var exp=new RegExp(/^[abcdefghijklmnopqrstuvwxyz]+$/);
	    if(!exp.test(oUrl_p.value))
	    {
			if(oUrl_p.getAttribute('ControleErreur') != '')
				alert(oUrl_p.getAttribute('ControleErreur'));
			else
				alert('La valeur du champ est incorrecte !\r\nAucune caractère spécial n\'est autorisé.');
			oUrl_p.value = '';
			return false;
	    }
    }
    return true;
}

function VerifierFichier(oFichier_p)
{
	sExtention_l = getextension(oFichier_p.value);
	switch(oFichier_p.getAttribute('parametre'))
	{
		case 'IMAGE':
			if(sExtention_l != 'jpg' && sExtention_l != 'jpeg' && sExtention_l != 'png' && sExtention_l != 'gif')
			{
				if(oFichier_p.getAttribute('ControleErreur') != '')
					alert(oFichier_p.getAttribute('ControleErreur'));
				else
					alert('Format de fichier incorrect !');
				oFichier_p.value = '';
				return false;
			}
		break;
	}
    return true;
}

function VerifierPassword(oMdp_p)
{
	if(document.getElementById(oMdp_p.getAttribute('parametre')).value != oMdp_p.value)
	{
		if(oMdp_p.getAttribute('ControleErreur') != '')
			alert(oMdp_p.getAttribute('ControleErreur'));
		else
			alert('Confirmation de mot de passe invalide !');
		oMdp_p.value = '';
		return false;
	}
    return true;
}

function ControlerFormulaire()
{
	bChampsObligatoireOk_l = true;
	bChampsValideOk_l = true;
	bFormulaireOk_l = true;
	sErreur_l = '';
	
	if(tbChampsObligatoire_l != 'undefined')
	{
		for(sChampsObligatoire_l in tbChampsObligatoire_l)
		{
			if((document.getElementById(sChampsObligatoire_l).type == 'checkbox' && !document.getElementById(sChampsObligatoire_l).checked) 
				|| (document.getElementById(sChampsObligatoire_l).type != 'checkbox' && document.getElementById(sChampsObligatoire_l).value == ''))
			{
				bChampsObligatoireOk_l = false;
				if(document.getElementById(sChampsObligatoire_l).getAttribute('ObligatoireErreur') != '')
					alert(document.getElementById(sChampsObligatoire_l).getAttribute('ObligatoireErreur'));
			}
		}
	}
	if(tbControleChamps_l != 'undefined')
	{
		for(sControleChamps_l in tbControleChamps_l)
		{
			bTest_l = window[tbControleChamps_l[sControleChamps_l]](document.getElementById(sControleChamps_l));
			if(!bTest_l)
			{
				bChampsValideOk_l = false;
			}
		}
	}
	if(!bChampsObligatoireOk_l){alert('Merci de remplir tous les champs obligatoires');bFormulaireOk_l = false;};
	if(!bChampsValideOk_l){/*if(sErreur_l!='')sErreur_l+= '\r\n';sErreur_l+= 'Les valeurs de certains champs ne sont pas correctes';*/bFormulaireOk_l = false;};
	
    return(bFormulaireOk_l);
}
