function emailvalidation(entered, alertbox)
{
// E-mail Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
	with (entered)
	{
		var accSymbol = "-.@_abcdefghijklmnopqrstuvwxyz0123456789";
		sEmail = value.toLowerCase();
		for(i=0;i<sEmail.length;i++){
			if(accSymbol.indexOf(sEmail.charAt(i))<0){
				alert(alertbox);
				return false;
			}
		}
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		lastpos=value.length-1;
		if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
		{
			if (alertbox) {
				alert(alertbox);
				//document.getElementById(mydiv).innerHTML = alertbox;
				}
			return false;
		}else {
			if (alertbox) {
				//alert(alertbox);
				//document.getElementById(mydiv).innerHTML = "";
				}
			return true;
		}
	}
} 

function pwValidation(pw1, pw2, alertbox){
	var p1;
	var p2;
	with (pw1){p1 =value;}
	with (pw2){p2 =value;}
	
	if(p1 == "" || p2 == ""){
		alert(alertbox);		
		return false;
	} else if(p1 == p2) return true;
	else {
		alert(alertbox);
		return false;
	}
}

function isEmpty(entered, alertbox){
		with (entered)		
		{
			str = value.split(" ");
			conStr = "";
			for(i=0;i<str.length;i++){
				conStr = conStr+str[i];
			}
				
			if (value==null || value=="" || conStr=="")
			{
				if (alertbox!="") {
					alert(alertbox);
					//document.getElementById(mydiv).innerHTML = "Required";
				}
				return false;
			}else {
				if (alertbox!="") {
					//document.getElementById(mydiv).innerHTML = "";
				}

				return true;
				}
		}
}

function isPhone(entered, alertbox, mydiv){
		with (entered)
		{
			if (isNaN(value))
			{
				if (alertbox!="") {
					//alert("Le téléphone doit être toutes les données numériques\n\nPhone must be all numeric data");
					alert("Le téléphone doit être toutes les données numériques.");
					document.getElementById(mydiv).innerHTML = alertbox;
				}
				return false;
			}else {
				if (alertbox!="") {
					document.getElementById(mydiv).innerHTML = "";
				}

				return true;
				}
		}
}

function IsNumeric(strString){
   //  check for valid numeric strings	   
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}

function trim(value){
	var str="";
	texts = value.split(" ");	
	for(i=0;i<texts.length;i++){
		str = str + texts[i];
	}
	return str;
}

function isUser(entered, alertbox){
	with (entered)
	{
		var accSymbol = "-.@_abcdefghijklmnopqrstuvwxyz0123456789";
		sUser = value.toLowerCase();
		for(i=0;i<sUser.length;i++){
			if(accSymbol.indexOf(sUser.charAt(i))<0){
				alert(alertbox);
				return false;
			}
		}
		
		var total = value.length;
		if (total<3 || total>10 ){ alert(alertbox); return false;}
		
		return true;
	}
}
