/**********************************************************************************/
/*                                                                                */
/*  Netfirms JavaScript Form Validation Functions                                 */
/*                                                                                */
/*                                                                                */
/*                                                                                */
/*                                                                                */
/*                                                                                */
/**********************************************************************************/

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_empty()                                                    */
/*  Description:    Determines if the testexp zero length                         */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           29 June 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_empty(testexp) {

  if    (testexp.length == 0) { return true;  }
  else                        { return false; }

}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_domain()                                                   */
/*  Description:    Determines if the testexp is a valid domain-type string       */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           29 June 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_domain(testexp) {

  var re  = /^([a-zA-z\d]+)([\.-]?[a-zA-z\d]+)*(\.[a-zA-z\d]{2,3})+$/;

  if    (re.test(testexp))  { return true;  }
  else                      { return false; }

}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_ip()                                                       */
/*  Description:    Determines if the testexp is a valid ip address               */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           29 June 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_ip(testexp) {

  var re  = /^(((\d{1,3})(\.{1})){3})(\d{1,3})$/;

  if    (re.test(testexp))  { return true;  }
  else                      { return false; }

}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_arecord()                                                  */
/*  Description:    Determines if the testexp is a valid A record name entry      */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           29 June 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_arecord(testexp) {

  var re  = /^([A-Za-z\d]+)(\-?)([A-Za-z\d]+)$/;

  if    (re.test(testexp))                                { return true;  }
  else if ((testexp.length > 64) || (testexp.length < 1)) { return false; }
  else                                                    { return false; }

}


/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_companyname()                                              */
/*  Description:    Determines if the testexp is a valid company name             */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_companyname(testexp) {
  var re  = /^(.*)$/;

  if    (re.test(testexp))  { return true;  }
  else                      { return false; }
}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_name()                                                     */
/*  Description:    Determines if the testexp is a valid name                     */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_name(testexp) {
  var re  = /^([A-Za-z-]{2,})\s?([A-Za-z-]*)$/;

  if    (re.test(testexp))  { return true;  }
  else                      { return false; }
}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_email()                                                    */
/*  Description:    Determines if the testexp is a valid email address            */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_email(testexp) {

  var re  = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,5})+$/;

  if    (re.test(testexp))  { return true; }
  else                      { return false;}
}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_street()                                                   */
/*  Description:    Determines if the testexp is a valid street expression        */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_street(testexp) {

  if    (testexp.length > 5)  { return true;  }
  else                        { return false; }

}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  ()                                                            */
/*  Description:    Determines if the testexp is a valid                          */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_city(testexp) {
  var re  = /^([A-Za-z\s]{2,})$/;

  if    (re.test(testexp))  { return true;  }
  else                      { return false; }
}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_statecode()                                                */
/*  Description:    Determines if the testexp is a valid state or province code   */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_statecode(testexp) {

  var re  = /^([A-Za-z\-]{2,3})$/;

  if    (re.test(testexp))  { return true;  }
  else                      { return false; }

}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_countrycode()                                              */
/*  Description:    Determines if the testexp is a valid two-letter country code  */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_countrycode(testexp) {

  var re  = /^([A-Za-z]{2})$/;

  if    (re.test(testexp))  { return true;  }
  else                      { return false; }
}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_postalcode()                                               */
/*  Description:    Determines if the testexp is a valid Canadian postal code     */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_postalcode(testexp) {
  var re  = /^(([A-Za-z]\d){3})$/;

  if    (re.test(testexp))  { return true;  }
  else                      { return false; }
}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  is_phonenumber()                                              */
/*  Description:    Determines if the testexp is a valid phone number             */
/*                  (minimum 7 character length)                                  */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/

function is_phonenumber(testexp) {

  if    (testexp.length > 6)  { return true;  }
  else                        { return false; }

}

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  ()                                                            */
/*  Description:    Determines if the testexp is a valid                          */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  ()                                                            */
/*  Description:    Determines if the testexp is a valid                          */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/

/**********************************************************************************/
/*                                                                                */
/*  Function Name:  ()                                                            */
/*  Description:    Determines if the testexp is a valid                          */
/*  Parameters      testexp                                                       */
/*  Input:                                                                        */
/*  Output:         true or false                                                 */
/*                                                                                */
/*  Author:         Raymond Chow                                                  */
/*  Date:           08 July 2004                                                  */
/*                                                                                */
/**********************************************************************************/
