function validForm(vsForm)
{

	
	/*
	Types
	0 = Aucun
	1 = Numeric
	2 = Emails
	*/
	
	var oForm = document.all(vsForm);
	var oElement;
	var sValue = new String();
	var sFirstError;
	
	var iNbrElements = oForm.elements.length;
	var i = 0;
	
	var bValid = true;
	
	while(i < iNbrElements)
	{
		oElement = oForm.elements(i);
	
		if(oElement.type == "text" || oElement.type == "textarea" || oElement.type == "password" || oElement.type == "select-one")
		{
			if(oElement.type == "select-one")
			{	
				if(oElement.mandatory == 1)
				{	
					if(oElement.selectedIndex == 0)
					{
					
						if (bValid)
						{
							
							oElement.focus();
						}

						bValid = false;
						oElement.className = oElement.errClass;
					
					}
					else
					{
						oElement.className = oElement.validClass;
					}
				}
			}
			else
			{
				sValue = oElement.value;
			
				if(oElement.mandatory == 1)
				{	
					if(oElement.validType == 1)
					{
						if(isNaN(oElement.value) || sValue.length == 0)
						{
							if (bValid)
							{
								
								oElement.focus();
							}

							bValid = false;
							oElement.className = oElement.errClass;
						}
						else
						{
							oElement.className = oElement.validClass;
						}
					}
					else if(oElement.validType == 2)
					{

						bValid = bValidEmail(oElement.value)
						if (bValid == false)
						{
							oElement.className = oElement.errClass;
							oElement.focus();
						}
						else
						{
							oElement.className = oElement.validClass;
						}
					}
					
					else
					{
						if(sValue.length == 0)
						{
							if (bValid)
							{
								
								oElement.focus();
							}

							bValid = false;
							oElement.className = oElement.errClass;
						}
						else
						{
							oElement.className = oElement.validClass;
						}
					}
				}
				else
				{
					if(oElement.validType == 1)
					{
						if(isNaN(oElement.value) && sValue.length != 0)
						{
							if (bValid)
							{
								
								oElement.focus();
							}

							bValid = false;
							oElement.className = oElement.errClass;
						}
						else
						{
							oElement.className = oElement.validClass;
						}
					}
				}
			}
		}
		
		i = i + 1;
	}
	
	
	return bValid;
	
}

function bValidEmail(vsEmail)
{

	var sEmail = vsEmail
	var iA = 0;
	var iDot = 0;
	var i = 0;
	var bValid = true;

	
	while(i < sEmail.length && bValid)
	{
		
		if(sEmail.charAt(i) == "@")
		{
			if(iA == 0 && i != 0)
			{
				iA = i;
			}
			else
			{
				bValid = false;
			}
		}
	
		if(sEmail.charAt(i) == "." && iA != 0)
		{
			if(i > (iA + 1) && i != sEmail.length - 1)
			{
				iDot = i;
			}
			else
			{
				bValid = false;
			}
		}
		
		i = i + 1;
		
	}

	if(iA == 0 || iDot == 0)
	{
		bValid = false;
	}
	
	return bValid;

}