
var formDateLabels = {date1:"The beginning date",date2:"The ending date"};

function isaPosNum( s ) 
{
    return ( parseInt( s ) > 0 );
}

function dateCheck( item, min, max )
{
    var pluginDate = item.name;
        
    if ( ! isaPosNum( item.value ) )
    { 
        alert( formDateLabels[pluginDate] + 
               " must be a positive number between" + 
               min + " and " + max );
        return false;
    }
    
    if ( parseInt( item.value ) < min )
    { 
        alert( formDateLabels[pluginDate] + 
               " must be greater than " + 
               min + " and less than " + 
               max + "\n\nPlease re-enter it" );
        return false;
    }
    
    if ( parseInt( item.value ) > max )
    { 
        alert( formDateLabels[pluginDate] + 
               " must be greater than " + 
               min + " and less than " + 
               max + "\n\nPlease re-enter it" );
        return false;
    }
    
    return true;
}

function validateAndSubmit( theform, min, max )
{
    if ( dateCheck( theform.date2, min, max ) )
    {
        if ( dateCheck( theform.date1, min, max ) )
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}

// uncheckAllRecords.
// take a FORM object as an argument, and set all the checkbox objects
// in that form to not "checked", return false

function uncheckAllRecords( theform )
{
  var ele = "";

  for ( var i = 0; i < theform.elements.length; i++)
  {
      ele = theform.elements[i];
      
      if (ele.type == "checkbox")
      {
          ele.checked = false;
      }
  }

  return false;
}

