/**
* Nolink helper.
* When you need an <a> that doesn't do anything at all,
* make its href = "javascript:nolink()"
*/
function nolink(){}

/**
* Check Argument Count
* If you need a function to raise an error when passed an
* incorrect amount of argumets call checkArgumentCount(arguments)
* arguments being the property of the function you are checking
*/
function checkArgumentCount( args ) {
  var actual = args.length;           // The actual number of arguments
  var expected = args.callee.length;  // The expected number of arguments
  if (actual != expected)             // Throw an exception if they don't match
    throw new Error("Wrong number of arguments: expected: " + expected + "; actually passed " + actual);
}

/**
* Used to toggle all checkboxes of class className
* on or off. The current toggle setting is remembered
* in a static variable, so you can only use it for toggling
* one set of checkboxes per page.
*/
function toggleCheckboxes( className ) {
  jQuery(className).attr('checked', !this.chkTog); 
  this.chkTog = !this.chkTog;
} toggleCheckboxes.chkTog = false;

/**
* A convenient extension
*/
Array.max = function( array ){
  return Math.max.apply(Math, array);
}