/*
  Paul Carpenter - PC Services December 2008

  Aid functions for search forms, and interim search results lists.

  Short form list functions

  checkform( thisid, min ) - checks at least min items selected before submitting form
  			thisid is the array of HTML/Javascript ids for the checkboxes
  			min is minimum selections required
  				(created when form generated by PHP )

  NOTE for PHP to process all checkboxes as an array they must be named '<name>[]'
       however for Javascript to access them I do this by giving the checkboxes
       ids of HTML/Javascript 'id=<othername>' hopefully giving a Javascript array to access!
*/
function checkform( thisid, min )
{
var loop, i = 0;
for( loop = 0; loop < thisid.length; loop++ )
   if( thisid[ loop ].checked == true )
     i++;
if( i < min)
  {
  alert( "At least "+min+" item(s) must be selected\n (tick in Select column)\n  In order to proceed" );
  return false;
  }
return true;
}


/*
  selectall( thisid, val ) - select/clear all checkboxes in thisid[] named array on form
  			thisid is the array of HTML/Javascript ids for the checkboxes
  			val sets all boxes when true, clears all when false

  NOTE for PHP to process all checkboxes as an array they must be named '<name>[]'
       however for Javascript to access them I do this by giving the checkboxes
       ids of HTML/Javascript 'id=<othername>' hopefully giving a Javascript array to access!
*/
function select_all( thisid, val )
{
var loop;
for( loop = 0; loop < thisid.length; loop++ )
   thisid[ loop ].checked = val;
return true;
}


