/*
 * $Id: profile-organisation.js,v 1.3 2009/03/23 06:07:52 jgorba Exp $
 * 
 * This script looks for a particular field
 * in the Profile form and toggles the visibility
 * of the form field immediately below it
 * depending on the current value.
 * 
 * Requires Jquery v.1.1.2 from jquery.com
 * 
 */

$(document).ready(function(){
	
	var fName = $("select[@name=pio_instname]");
	var fOtherName = $("input[@name=pio_instname_other]");
	var dOtherName = $(fOtherName).parents("div.form-item")
	var sText = "Other"
	
	// Handle visibility on page load
	if ($("option:selected", fName).val()==sText) {
		$(dOtherName).show();
	}	else {
		$(dOtherName).hide();	
	}
	
	// Handle visibility if selection changes 
	$(fName).change(function(){
		if ($("option:selected", fName).val()==sText) {
			// Uses slide effect to make the change obvious
			$(dOtherName).slideDown("slow");
		}	else {
			$(dOtherName).hide();				
		}
	})
		
});