//**************************************************************************
// validate.js
//
// Purpose: contains client side validation scripts used by various library 
//          requestline applications
//
// Revision History
// Date       Author       Description
// XX-XX-199X  ???        >Initial Creation
// 06-05-2000  AMK        >added function "CheckEmailFormat"
// 04-29-2002  thaniya	  >added function "frmReset"
//**************************************************************************


var defaultEmptyOK = false;
var decimalPointDelimiter = "."
var objWindow 

/// Constants for Active/Inactive 	(03/1/01)
var gIntActive 		= -1
var gIntInActive 	= 0 

//********************************************************************************
// Name: frmReset
// Parameters: form object
// Returns: nothing
// Description: clear all fields in given form
//
// 
// Modification History: 
// Person   Date          Activity
// 04-29-2002  Thaniya        >Initial Creation
//********************************************************************************
function frmReset(frm) {
	for (var i = 0; i < frm.length; i++) {
		var e = frm.elements[i];
		e.value = "";
	}
}




//********************************************************************************
// Name: isEmpty
// Parameters: strText 
// Returns: boolean
// Description: Checks that a value is empty/Blank
// Modification History: 
// Person		Date          Activity
// Rupesh		08-24-2000    Initial Creation
//********************************************************************************
function isEmpty(strText) {
		
		if ((strText == null) || (strText.length == 0)) return true

		//Check for Whitespace
		return (isWhitespace(strText))  
	}

//********************************************************************************
// Name: isWhitespace
// Parameters: strText 
// Returns: boolean
// Description: Checks whether the String value contains any white spaces 
// Modification History: 
// Person		Date          Activity
// Rupesh		08-24-2000    Initial Creation
//********************************************************************************
function isWhitespace(strText) {
		var intCount;
	    // Is s empty?
		//if (isEmpty(strText)) return true;
			
		// Search through string's characters one by one
		// until we find a non-whitespace character.
		// When we do, return false; if we don't, return true.
	    var whitespace = ' '; 
	    for (intCount = 0; intCount < strText.length; intCount++) {
			// Check that current character isn't whitespace.
			var strChar = strText.charAt(intCount);
			//if (whitespace.indexOf(strChar) == -1) return false;
			if (whitespace.indexOf(strChar) == -1 && strChar != '\n' && strChar != '\r' && strChar != "\t") return false;
		}
		// All characters are whitespace.
		return true;
	}


//********************************************************************************
// Name: isEmail
// Parameters: strText 
// Returns: boolean = (True)- Valid Email Address
// Description: Checks Valid Email Address
// Modification History: 
// Person		Date          Activity
// Rupesh		08-24-2000    Initial Creation
//********************************************************************************
function isEmail(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}






//  End -->

