	var do_it = true;
	function tally( destination ) {
			if ( navigator.appName == 'Netscape')
				{
                                fieldname = 'window.document.forms[0].' + destination;
				//alert('navigator fieldname is' + fieldname);
				}
			else{
				fieldname = 'document.forms[0].' + destination;
				//alert('other fieldname is' + fieldname);
				}
			true_dest = eval( fieldname );
			///alert(true_dest);
			the_sum = 0;
			for ( i = 1; i <= 5; i++ ) {
				the_field = eval( fieldname + '_' + i );
				if (the_field && the_field.value.length && the_field.value != '' && (isNaN(the_field.value) || the_field.value < 1)) {
					window.alert('Please only enter positive integer values in this '  + ( i < 5 ? 'LEVEL ' + i : 'the BASEMENT level' ) + ' field.');
					do_it = false;
					the_field.value = '';
					the_field.focus();
					return;
				}
				else { // Sum 'em up!
					if (the_field && the_field.value.length && the_field.value != '')
						the_sum += Math.floor(the_field.value);
				}
			}
			if (the_sum) true_dest.value = the_sum;
				else true_dest.value = '';

	}

	function tallychk( destination ) {

			if ( navigator.appName == 'Netscape')
				fieldname = 'window.document.forms[0].' + destination;
			else
				fieldname = 'document.forms[0].' + destination;
			true_dest = eval( fieldname );
			the_sum = 0;
			for ( i = 1; i <= 5; i++ ) {
				the_field = eval( fieldname + '_' + i );
				if (the_field && the_field.checked) the_sum++;
				}
				if (the_sum) true_dest.value = the_sum;
				else true_dest.value = '';

	}

function validateElement(elementRef, elementDesc, limit, charSet)
{
   var validCharDesc = "";
   var MyString = elementRef.value;  
   var dateChars = "/";
   var emailChars = ".@_-";
   var letterChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var numChars = ".1234567890";
   var ssnChars = "-";
   var addressChars = '\'-., ';
   var nameChars = '\'-., ';
   var phoneChars = "()- x";
   var intlZipChars = "- ";
   var textChars = ".,?;:!$()_+-=@ \'\""
   var allValidCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.,?;:!$()_+-=@";
   if (charSet == 1)
   {
      allValidCharacters = numChars + dateChars;
	  validCharDesc = "are numbers and " + dateChars;
   }
   if (charSet == 2)
   {
      allValidCharacters = letterChars + numChars + emailChars;
  	  validCharDesc = "are numbers, letters and " + emailChars;
   }
   if (charSet == 3)
   {
      allValidCharacters = numChars;
	  validCharDesc = "are numbers";
   }
   if (charSet == 4)
   {
      allValidCharacters = numChars + ssnChars;
	  validCharDesc = "are numbers and " + ssnChars;
   }
   if(charSet == 5)
   {
   	  allValidCharacters = letterChars + numChars + addressChars;
	  validCharDesc = "are letters, numbers and " + addressChars;
   }
   if(charSet == 6)
   {
      allValidCharacters = letterChars + nameChars;
	  validCharDesc = "are letters and " + nameChars;
   }
   if(charSet == 7)
   {
   	  allValidCharacters = numChars + phoneChars;
	  validCharDesc = "are numbers and " + phoneChars;
   }
   if(charSet == 8)
   {
   	  allValidCharacters = numChars + intlZipChars;
	  validCharDesc = "are numbers and " + intlZipChars;
   }
   if(charSet == 9)
   {
      allValidCharacters = numChars + letterChars + textChars;
	  validCharDesc = "are numbers, letters and " + textChars;
   }
   var isCharValid; 
   var lastchar;
   var charIndex;
   isCharValid = true;

   if (MyString.length > limit) 
   {
      MyString = MyString.substring(0, limit);
      elementRef.value = MyString;
      elementRef.blur() ;
      alert("You have reached the " + limit + " character limit of this field");
   } 
   lastchar = MyString.charAt(MyString.length - 1); 

   charIndex = allValidCharacters.indexOf(lastchar);

   if(charIndex < 0)
   {
      alert("The character " + lastchar + " is an invalid character in the " + elementDesc + " field. \n The only valid characters for this field " + validCharDesc);
      MyString =  MyString.substring(0, (MyString.length - 1));
      elementRef.value = MyString;
   }
   /*if((charSet == 4) && (!((MyString.length == 4) || (MyString.length == 7))) && (charIndex == 0))
   {
      MyString =  MyString.substring(0, (MyString.length - 1));
      elementRef.value = MyString;
	  //alert(MyString.length);
   }    */
}

function ValidateRequire(sForm, sAction){
    	var sMsg = "";
    	var error = 0;
    	for (var i=0; i < sForm.elements.length; i++){
    		var sField = sForm.elements[i];
    		if ((sField.getAttribute("class") == "required" || sField.getAttribute("className") == "required") && !sField.value) {
    			error += 1;
    			if (error == 1) {
    				sField.focus();
    			}
    			sMsg += sField.getAttribute("label") + " is required\n";
    		} 
    	}
    	if (error) {
    		alert(sMsg);
    	} else {
	    	if (sAction) {
	    		sForm.action = sAction;
	    	}
    		sForm.submit();
    	}
    }
    
function ValidEmail(el)
{
	var email=el.value.toLowerCase();
	var pattern=/^[-\._a-z0-9]+@((([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/;
	if(!pattern.test(email))
	{
		el.focus();
                alert("Please enter a valid e-mail address!!!");
		return false;
	}
	return true;
}
