<!--

//################################################
function trim(str, chars) {
var aftertr=ltrim(rtrim(str, chars), chars);

    return aftertr;
}
function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


//#################################################
function CheckEmail(regMail)
{
 if (regMail.length > 0) { 
 if (regMail.length < 6) { return false;}
 var RegE=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,86})\.([a-z]{2,4}(?:\.[a-z]{2})?)$/i  ;
 if (RegE.test(regMail))
 return true;
 else
 return false;}else return true;
}


//#################################################
function CheckForm(fv)
{
  result = false ;
   result = CheckFields(fv) ;
  if (result)
   {
     return true ;
   }
   else
   return false;
}

//#################################################
function SetMess(IdToS,MeS)
{
var a = document.getElementById(IdToS);
a.innerHTML = MeS;
}  

//#################################################
function CheckNum(regNum)
{
 var RegN=/(\D+)/g ;
 if (RegN.test(regNum))
 return false;
 else{
 if( (regNum.length < 9 ) ||   (regNum.length > 10) )  return false;
 return true;
  }
}
//#################################################
function CheckFields(fv)
{

  var Errors = false;

  USFN = trim(fv.fiName.value);
 
  USFEM = trim(fv.EmailAddress.value);

  UST = trim(fv.usTel.value);

 

  var UserFN = USFN.length > 1;
var  UserFNm = "נע לבדוק שם פרטי"; 
 
 var  UserEMV = CheckEmail(USFEM) ;
  var  UserEMVm = "נע לבדוק דא''ל ";
 
 var  UserTL =  CheckNum(UST);
 var  UserTLm = "נע לבדוק מס' טל'";
 



if(UserFN)  {
   SetMess("FN","&nbsp;");
   			}
	else{
   SetMess("FN",UserFNm); Errors = true;
   		}
 

if(UserEMV)  {
   SetMess("EMV","");
   			}
	else{
   SetMess("EMV",UserEMVm); Errors = true;
   		}
  

if(UserTL)  {
   SetMess("TL","&nbsp;");
   			}
	else{
   SetMess("TL",UserTLm); Errors = true;
   		}

	//################################



 if (Errors){
 		SetMess("ForErr","נע לבדוק שדות מסומנים באדום");
  		return false;
  			   }
   		else {
 		SetMess("ForErr","");
  		return true;
  			 }



}


