// DEFINE VARIABLES

// whitespace characters
var whitespace = " \t\n\r";

/*****************************************************************/

//Purpose: uses <a href="javascript:setRadio[but#]">text</a> to select a radio button

function setRadio(whichBut) {
    document.forms[0].Nature[whichBut].checked = 1;
}
function setRadioIA(whichBut) {
    document.forms[0].rdoConstr[whichBut].checked = 1;
}

/****************************************************************/

// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

/****************************************************************/

// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) 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.

    for (i = 0; i < s.length; i++)
    {   
	// Check that current character isn't whitespace.
	var c = s.charAt(i);

	if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}
/****************************************************************/

// Checks to see if a required field is blank.  If it is, a warning
// message is displayed...

 function ForceEntry(val, str) {
           var strInput = new String(val.value);

           if (isWhitespace(strInput)) {
                alert(str);
                val.focus();
                return false;
           } else
                return true;

      }
/****************************************************************/

// Returns true if the string passed in is a valid number
//  (no alpha characters), else it displays an error message

function ForceNumber(objField, FieldName)
{
	var strField = new String(objField.value);
	
	if (isWhitespace(strField)) {
	alert(FieldName);
                objField.focus();
                return false;
	}

	var i = 0;

	for (i = 0; i < strField.length; i++)
		if (strField.charAt(i) < '0' || strField.charAt(i) > '9') {
			if (strField.charAt(i) != '.'){
				alert(FieldName + " It must be a valid numeric entry.");
				objField.focus();
				return false;
			}
		}

	return true;
}
/****************************************************************/
	  /*ugly but works.*/
	  
      function Force2RadioEntry(val, str) {
          

           if (val[0].checked)
                return true;
		 else
		 
           

         if (val[1].checked) 
                return true;
		 
		 else
		 
           

           
           {
                alert(str);
                val[0].focus();
                return false;
           
           }
      }
  /****************************************************************/

function Force3RadioEntry(val, str) {
          

           if (val[0].checked)
                return true;
		 else
		 
           

         if (val[1].checked) 
                return true;
		 
		 else
		 
           if (val[2].checked) 
                return true;
		 
		 else

           
           {
                alert(str);
                val[0].focus();
                return false;
           
           }
      }

/****************************************************************/

function Force4RadioEntry(val, str) {
          

           if (val[0].checked)
                return true;
		 else
		 
           

         if (val[1].checked) 
                return true;
		 
		 else
		 
           if (val[2].checked) 
                return true;
		 
		 else

             if (val[3].checked) 
                return true;
		 
		 else
           {
                alert(str);
                val[0].focus();
                return false;
           
           }
      }
/***************************************************************************/

function ForceSelect(val, str) {
      if (val.selectedIndex !=0)
      return true;
      
      else
      {
      alert(str);
      val.focus();
      return false;
      }
      
      
      }
/***************************************************************************/

function ForceAUnits(val, str) {
      if (val.selectedIndex !=0)
      return true;
      
      else
      {
      val.focus();
      return false;
      }
      
      
      }
/****************************************************************/

// Checks to see if a required field is blank.  If it is, NO warning
// message is displayed, this is just used for some if/then things

 function CheckEntry(val) {
           var strInput = new String(val.value);

           if (isWhitespace(strInput)) {
                return false;
           } else
                return true;

      }