// JavaScript Document
$(document).ready(load_jquery);
var restrict_lookup = new Array();
function load_jquery(){
	$('.restrict')
		.children()
			.each(function(){
				var content = $(this).text();
				var id = $(this).attr('class');
				var value = $(this).attr('value');				
				restrict_lookup[id] = new Array(content, value);  
			})
			.remove();
	$('.restrict_lookup')
		.change(function(){do_lookup(this);});
	$('.restrict').append(
		$('<option />').text('Please select an Impairment to see the related Skills').attr('value','')
	);	
}
function do_lookup(element){
	$(element)
		.children('option:selected')
		.each(function(){
			var value = $(this).attr('class');	
			values = value.split(",");
			$('.restrict').children().remove();
			if(values.length > 0 && values[0] != ''){
    			for (var i = 0; values.length > i; i++) {  
					var option_content = restrict_lookup[values[i]];				
					$('.restrict')
						.append(
							$('<option />')
								.text(option_content[0])
								.attr('value', option_content[1])
						);
				}
			}
			else
			{
				$('.restrict').append(
					$('<option />').text('Please select an Impairment to see the related Skills').attr('value','')
				);	
			}
		});
}
