
function containsSpacesOnly(arg)
 {
   var argSize = arg.length;
   var spaceIndex = arg.lastIndexOf(" ");

   //spaces only if input is null
   if(arg == "")
     return true;
   if(spaceIndex == -1 || spaceIndex != argSize-1)
     return false;
   else if(spaceIndex == 0)
     return true;
   else
     return containsSpacesOnly(arg.substring(0,spaceIndex));
 }

function isEmpty(fieldStr) {
   if (containsSpacesOnly(fieldStr)) return true;
   if (fieldStr == "") return true;
   return false;
}


function retainSelection(form, elementName, selectedValue) {
   selectOptions = form.elements[elementName].options;
   for (i = 1; i < selectOptions.length; i++) {
      if (selectOptions[i].value == selectedValue) {
         selectOptions[i].selected = true;
         i = selectOptions.length;
      }
   }
}


function checkBoxToBoolean(checkBoxStr) {
   if (checkBoxStr == "True" || 
       checkBoxStr == "true" || 
       checkBoxStr == "on" || 
       checkBoxStr == "On" ||
       checkBoxStr == "yes" || 
       checkBoxStr == "Yes") {
       return true;
   } else {
       return false;
   }       
}