
<!--

function validDate(dt){
	if (!dt.value == "") {
	if (!validateUSDate(dt.value)){
		alert("Please enter a valid date.");
		dt.value="";
		}
	}
}

	function ToggleEditRow(){
   	 	for (var i = 0; i < 11; i++)
   	 	{
   	 	if (document.getElementById('editrow'+i) != null)
				{
	        		if (document.getElementById('editrow'+i).style.display=='none') 
	        		{
	        			document.getElementById('editrow'+i).style.display='';
	        		}
	        		else 
	        		{
	        			document.getElementById('editrow'+i).style.display='none';
	       	 		}
	    		}
	    	}
	    	return false;	    	
	   	}
	function ToggleEditRow2(){
   	 	for (var i = 20; i < 22; i++)
   	 	{
   	 	if (document.getElementById('editrow'+i) != null)
				{
	        		if (document.getElementById('editrow'+i).style.display=='none') 
	        		{
	        			document.getElementById('editrow'+i).style.display='';
	        		}
	        		else 
	        		{
	        			document.getElementById('editrow'+i).style.display='none';
	       	 		}
	    		}
	    	}
	    	return false;	    	
	   	}
	function ToggleEditRow3(){
   	 	for (var i = 30; i < 32; i++)
   	 	{
   	 	if (document.getElementById('editrow'+i) != null)
				{
	        		if (document.getElementById('editrow'+i).style.display=='none') 
	        		{
	        			document.getElementById('editrow'+i).style.display='';
	        		}
	        		else 
	        		{
	        			document.getElementById('editrow'+i).style.display='none';
	       	 		}
	    		}
	    	}
	    	return false;	    	
	   	}		   		
	function ReloadPage(strURL){
		//alert (strURL.value);
		window.location.href  = strURL.value;
		return true;
	}

function validateMoney(fld){
	if (!validateUSCurrency(fld.value)) {
		fld.value="";
		alert("Please enter a currency value without the dollar sign.");
		}
	else
		{
		fld.value = addCommasandDecimals(fld.value);
		}
}

function IsValidEmail(frm) {
	if (frm.fields_email.value == ""){
		alert("Please enter your email address.");
		return false;
		}
	else
		{
		   if (!IsEmail(frm.fields_email.value)) {
		    alert ("Please enter a valid email address.");
			return false;
		 	}
		return true;	
		}
} 	
function ValidNumber(fld){
	if (!validateNumeric(fld.value)){
		fld.value="";
		alert("Please enter a number.");
		return false;
	}
	else
		return true;
}
		

var Newsletter;
function OpenNewsletter() {
		 Newsletter = open("", "Welcome", "status=no,width=300,height=140;toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,titlebar=no");
 Newsletter.document.location= "/Newsletter_form.asp";
}
	
function ClearEmail(frm) {
	frm.fields_email.value = "";
	}	
	
//-----function isEmail(pStrVar)----------------
function IsEmail(pStrVar) 
{
var invalidChars = " /:,;";
result = true;
var loopIndex;
var badChar;

	if (pStrVar.length > 0) 
	{						
		for (loopIndex=0; loopIndex<invalidChars.length; loopIndex++) 
		{	
			badChar = invalidChars.charAt(loopIndex);
			
			if (pStrVar.indexOf(badChar,0) > -1) 
			{
				result = false;
			}
		}
		
		atPos = pStrVar.indexOf("@",1);			
		
		if (atPos == -1) 
		{
			result = false;
		}
		
		if (pStrVar.indexOf("@",atPos+1) != -1) 	
		{
			result = false;
		}
		var periodPos = pStrVar.indexOf(".",atPos);
		
		if (periodPos == -1)					
		{					
			result = false;
		}
		
		if (periodPos+3 > pStrVar.length)	
		{
			result = false;
		}
	}
	return result;
}// end IsEmail	



function validateUSDate( strValue ) {
/************************************************
DESCRIPTION: Validates that a string contains only 
    valid dates with 2 digit month, 2 digit day, 
    4 digit year. Date separator can be ., -, or /.
    Uses combination of regular expressions and 
    string parsing to validate date.
    Ex. mm/dd/yyyy or mm-dd-yyyy or mm.dd.yyyy
    
PARAMETERS:
   strValue - String to be tested for validity
   
RETURNS:
   True if valid, otherwise false.
   
REMARKS:
   Avoids some of the limitations of the Date.parse()
   method such as the date separator character.
*************************************************/
  var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/

  //check to see if in correct format
  if(!objRegExp.test(strValue))
    return false; //doesn't match pattern, bad date
  else{
    var arrayDate = strValue.split(RegExp.$1); //split date into month, day, year
	var intDay = parseInt(arrayDate[1],10); 
	var intYear = parseInt(arrayDate[2],10);
    var intMonth = parseInt(arrayDate[0],10);
	
	//check for valid month
	if(intMonth > 12 || intMonth < 1) {
		return false;
	}
	
    //create a lookup for months not equal to Feb.
    var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
                        '08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31}
  
    //check if month value and day value agree
    if(arrayLookup[arrayDate[0]] != null) {
      if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
        return true; //found in lookup table, good date
    }
		
    //check for February
	var booLeapYear = (intYear % 4 == 0 && (intYear % 100 != 0 || intYear % 400 == 0));
    if( ((booLeapYear && intDay <= 29) || (!booLeapYear && intDay <=28)) && intDay !=0)
      return true; //Feb. had valid number of days
  }
  return false; //any other values, bad date
}
	
function validateUSCurrency( strValue ) {
	//var objRegExp = /^\$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?$/;
	var objRegExp = /^([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9])?$/;
	return objRegExp.test(strValue);
}

function  validateNumeric_old( strValue ) {
/******************************************************************************
DESCRIPTION: Validates that a string contains only valid numbers.

PARAMETERS:
   strValue - String to be tested for validity
   
RETURNS:
   True if valid, otherwise false.
******************************************************************************/
  var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/; 
 
  //check for numeric characters 
  return objRegExp.test(strValue);
}	
	
function  validateNumeric( strValue ) {
	//var objRegExp = /[-+]?[0-9]*\.?[0-9]+/;
	var objRegExp = /^\-?\(?([0-9]{0,3}(\,?[0-9]{3})*(\.?[0-9]*))\)?$/ 
  //check for numeric characters
  return objRegExp.test(strValue);
}

function removeCommas( strValue ) {
/************************************************
DESCRIPTION: Removes commas from source string.

PARAMETERS:
  strValue - Source string from which commas will
    be removed;

RETURNS: Source string with commas removed.
*************************************************/
  var objRegExp = /,/g; //search for commas globally

  //replace all matches with empty strings
  return strValue.replace(objRegExp,'');
}

function addCommas( strValue ) {
/************************************************
DESCRIPTION: Inserts commas into numeric string.

PARAMETERS:
  strValue - source string containing commas.

RETURNS: String modified with comma grouping if
  source was all numeric, otherwise source is
  returned.

REMARKS: Used with integers or numbers with
  2 or less decimal places.
*************************************************/
  var objRegExp  = new RegExp('(-?[0-9]+)([0-9]{3})');

    //check for match to search criteria
    while(objRegExp.test(strValue)) {
       //replace original string with first group match,
       //a comma, then second group match
       strValue = strValue.replace(objRegExp, '$1,$2');
    }
  return strValue;
}

function addCommasandDecimals( strValue ) {
	var objRegExp = /^([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(\.[0-9][0-9]){1}$/
	strValue = addCommas(strValue);
	if (!objRegExp.test(strValue)) {
		return strValue + '.00';
	}
	return strValue;

}

function addCurrency( strValue ) {
/************************************************
DESCRIPTION: Formats a number as currency.

PARAMETERS:
  strValue - Source string to be formatted

REMARKS: Assumes number passed is a valid
  numeric value in the rounded to 2 decimal
  places.  If not, returns original value.
*************************************************/
  var objRegExp = /-?[0-9]+\.[0-9]{2}$/;

    if( objRegExp.test(strValue)) {
      objRegExp.compile('^-');
      strValue = addCommas(strValue);
      if (objRegExp.test(strValue)){
        strValue = '(' + strValue.replace(objRegExp,'') + ')';
      }
      //return '$' + strValue;
      return strValue;
    }
    else
      return strValue;
}
			
//-->
