/* Javascript Helpers */

/* 
 * Generic
 *
 * Used to freeze a submit button once submitted
 */
function freezeSubmitButton(submittedForm,displayMessage)
{
	submittedForm.submit_button.value=displayMessage;
	submittedForm.submit_button.disabled=true;
	return true;
}

/* 
 * Users::signup.thtml
 *
 * Used to hide/show student id field depending on the users status
 */
function checkForManualOrganisation(categoryObject)
{
	var i = categoryObject.selectedIndex;

	if(i >= 0) {

		//alert(document.getElementById('organisation_other_field').style.display);
		if(categoryObject.options[i].value == "other") {
			document.getElementById('organisation_other_field').style.display='';
		}
		else {
			document.getElementById('organisation_other_field').style.display='none';
		}
	}
}

//This prototype is provided by the Mozilla foundation and
//is distributed under the MIT license.
//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license

if (!Array.prototype.filter)
{
  Array.prototype.filter = function(fun /*, thisp*/)
  {
    var len = this.length;
    if (typeof fun != "function")
      throw new TypeError();

    var res = new Array();
    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
      {
        var val = this[i]; // in case fun mutates this
        if (fun.call(thisp, val, i, this))
          res.push(val);
      }
    }

    return res;
  };
}

