var Info =
{
	functionChange: function()
	{
		var functionSelect = document.getElementById('functions');
		var specialtySelect = document.getElementById('specialties');
		
		var selectedSpecialties = new Array();
		for (var i = 0; i < specialtySelect.options.length; i++)
		{
			if (specialtySelect.options[i].selected)
			{
				id = $(specialtySelect.options[i]).attr('value');
				selectedSpecialties[id] = 1;
			}
		}
		
		$(specialtySelect).html('<option value="0">- Select -</option>');
		var optionCounter = 1;
		
		for (var i = 0; i < functionSelect.options.length; i++)
		{
			id = $(functionSelect.options[i]).attr('value');
			if (functionSelect.options[i].selected && undefined != specialtyOptions[id])
			{
				for (var j = 0; j < specialtyOptions[id].length; j++)
				{
					specialtySelect.options[optionCounter] = new Option(specialtyOptions[id][j][1], specialtyOptions[id][j][0], false, false);
					if (undefined != selectedSpecialties[specialtyOptions[id][j][0]])
						specialtySelect.options[optionCounter].selected = true;
		
					optionCounter++;
				}
			}
		}
		
		if ('<option value="0">- Select -</option>' == $(specialtySelect).html())
			$(specialtySelect).html('<option value="0">- Select a function -</option>');
	},

	degreeChange: function()
	{
		var degree = $(this).val();
		var institution = $('select#institutions');
		var options = '<option value="0">- Select -</option>'
		$(institution).val('');
		
		for (var i = 0; i < institutions[degree].length; i++)
			options+='<option value="'+institutions[degree][i][0]+'">'+institutions[degree][i][1]+'</option>';
	
		$(institution).html(options);
	},
	
	multiDegreeChange: function()
	{
		var degree = $(this).val();
		var institution = $(this).parent().parent().find('select.institution');
		$(institution).val('');
		var options='<option value="0">- Select -</option>'
		for (var i = 0; i < institutions[degree].length; i++)
			options+='<option value="'+institutions[degree][i][0]+'">'+institutions[degree][i][1]+'</option>';
		
		$(institution).html(options);
	},
	
	checkMaxSelected: function(obj, maximum)
	{
		var counter = 0;
		var options = $(obj).children('option');
		for (i = 0; i < options.length; i++) {
			if ($(options[i]).attr('selected'))
				counter++;
			
			if (counter > maximum)
				$(options[i]).attr('selected', '')
		}
	}
	
}