/* Javascript Helpers */


/* 
 * Generic
 *
 * Used to print_r javascript objects
 */

var MAX_DUMP_DEPTH = 10;

function dumpObj(obj, name, indent, depth) 
{
	if (depth > MAX_DUMP_DEPTH) 
		return indent + name + ": <Maximum Depth Reached>\n";
	
	if (typeof obj == "object") 
	{
		var child = null;
		var output = indent + name + "\n";

		indent += "\t";
		
		for (var item in obj)
		{
			try {
				child = obj[item];
			} catch (e) {
				child = "<Unable to Evaluate>";
			}

			if (typeof child == "object") 
				output += dumpObj(child, item, indent, depth + 1);
			else 
				output += indent + item + ": " + child + "\n";
		}
		return output;
	} 
	else 
	{
		return obj;
	}
}

/* 
 * 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';
		}
	}
}
