// FUNCTION TO HANDLE CASE WHEN MIPS SCAN PARAMS ARE INVALID:

function MIPS_scan_input_error( theform, radio_index)
{
   alert("Bad input of MIPS Scan Map parameters. Nrepeat must be a NON-NEGATIVE INTEGER.");

   clear_report(theform);

   theform.selected_radio.value += "\nMIPS: " + theform.MIPS_mode[radio_index].value + " mode\n  Number of scan passes = \"" + theform.MIPS_scan_Nrepeat.value + "\"\n\nERROR: MIPS Scan Nrepeat must be a non-negative integer.";   
}

// FUNCTION TO HANDLE CASE WHEN MIPS PHOTO INPUT PARAMS ARE INVALID:

function MIPS_photo_input_error(theform, radio_index)
{
   alert("Bad input of MIPS Photometry/Super Res. parameters. Nrepeat must be a NON-NEGATIVE INTEGER.");

   clear_report(theform);

   theform.selected_radio.value += "\nMIPS: " + theform.MIPS_mode[radio_index].value + " mode\n  24 microns: Nrepeat = \"" + theform.MIPS_photo_24Nrepeat.value + "\"";

   theform.selected_radio.value += "\n  70 microns: Nrepeat = \"" + theform.MIPS_photo_70Nrepeat.value + "\"";

   theform.selected_radio.value += "\n 160 microns: Nrepeat = \"" + theform.MIPS_photo_160Nrepeat.value + "\"";

   theform.selected_radio.value += "\nERROR: MIPS Photo Nrepeats must be NON-NEGATIVE INTEGERS.";
}

// FUNCTION TO CHECK MIPS PHOTO Nrepeats ARE POSITIVE INTEGERS:

function check_MIPS_photo_N( N24, N70, N160 )
{
   var check_Nrepeat24 = its_integer( N24 );
   var check_Nrepeat70 = its_integer( N70 );
   var check_Nrepeat160 = its_integer( N160 );

   // IF any Nrepeat != INTEGER, OR IS NON-PHYSICAL (neg), WARN:
   if ( !check_Nrepeat24 || !check_Nrepeat70  || !check_Nrepeat160 || 
           N24 <= 0.0 || N70 <= 0.0 || N160 <= 0.0 )
   {
      return false;
   }
   else
   {
      return true;
   } 
}


// FUNCTION TO VERIFY IRAC INPUT PARAMETERS

function check_IRAC_input( Nrepeat )
{

    var check_Nrepeat = its_integer( Nrepeat );

    // IF Nrepeat != INTEGER OR IS NON-PHYSICAL (neg), WARN:

    if( !check_Nrepeat || Nrepeat <= 0.0) 
    {   
       return false;
    } 
    else
    {
       return true;
    }
}

// FUNCTION TO HANDLE CASE WHEN IRAC PARAMS ARE INVALID:

function irac_input_error( theform, mode, frametime, Nrepeat )
{
   alert("Bad input of IRAC parameters.");

   clear_report(theform);

   theform.selected_radio.value += "\nIRAC: " + mode + " mode ; Frame Time = " + frametime + " sec ; Nrepeat = \"" + Nrepeat + "\"\n\nERROR: IRAC Nrepeat input must be a positive integer.";

}

// FUNCTION TO HANDLE CASE WHEN IRAC PARAMS ARE INVALID:

function warm_irac_input_error( theform, mode, frametime, Nrepeat )
{
   alert("Bad input of Warm IRAC parameters.");

   clear_report(theform);

   theform.selected_radio.value += "\nIRAC: " + mode + " mode ; Frame Time = " + frametime + " sec ; Nrepeat = \"" + Nrepeat + "\"\n\nERROR: IRAC Nrepeat input must be a positive integer.";

}


// FUNCTION TO VERIFY IRS INPUT PARAMETERS

function check_IRS_input( Nrepeat_IRS )
{

    var check_Nrepeat = its_integer( Nrepeat_IRS );

    // IF Nrepeat != INTEGER OR IS NON-PHYSICAL (neg), WARN:

    if( !check_Nrepeat || Nrepeat_IRS <= 0.0) 
    {   
       return false;
    } 
    else
    {
       return true;
    }
}

// FUNCTION TO HANDLE CASE WHEN IRS PARAMS ARE INVALID:

function irs_input_error( theform, mode, frametime, Nrepeat )
{
   alert("Bad input of IRS parameters.");

   clear_report(theform);

   theform.selected_radio.value += "\nIRS: " + mode + " mode ; Frame Time = " + frametime + " sec ; Nrepeat = \"" + Nrepeat + "\"\n\nERROR: IRS PUI Nrepeat input must be a positive integer.";

}



