// JavaScript Document

function validaEmail( strValor) {
/************************************************
DESCRIPTION: Validates that a string contains a
  valid email pattern.

 PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.

REMARKS: Accounts for email with country appended
  does not validate that email contains valid URL
  type (.com, .gov, etc.) or valid country suffix.
*************************************************/
  var patron = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/
  //se checa si es valido el email
  return patron.test(strValor);
}
function validaTelefono( strValor) {
/************************************************
DESCRIPTION: Validates that a string contains a
  valid email pattern.

 PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.

REMARKS: Accounts for email with country appended
  does not validate that email contains valid URL
  type (.com, .gov, etc.) or valid country suffix.
*************************************************/
  var patron = /[0-9]{5,13}/
  //se checa si es valido el email
  return patron.test(strValor);
}
function validaNoVacios( strValor ) {
/************************************************
DESCRIPTION: Validates that a string is not all
  blank (whitespace) characters.

PARAMETERS:
   strValue - String to be tested for validity

RETURNS:
   True if valid, otherwise false.
*************************************************/
   var strTemp = strValor;
   strTemp = trim(strTemp);
   if(strTemp.length > 0){
     return true;
   }
   return false;
}
function trim( strValor ) {
/************************************************
DESCRIPTION: Removes leading and trailing spaces.

PARAMETERS: Source string from which spaces will
  be removed;

RETURNS: Source string with whitespaces removed.
*************************************************/
 var patron = /^(\s*)$/;

    //check for all spaces
    if(patron.test(strValor)) {
       strValor = strValor.replace(patron, '');
       if( strValor.length == 0)
          return strValor;
    }

   //check for leading & trailing spaces
   patron = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(patron.test(strValor)) {
       //remove leading and trailing whitespace characters
       strValor = strValor.replace(patron, '$2');
    }
  return strValor;
}
