// JavaScript Document
function makeSublist(parent,child,isSubselectOptional,childVal)
{
	$("body").append("<select style='display:none' id='"+parent+child+"'></select>");
	$('#'+parent+child).html($("#"+child+" option"));
	
		var parentValue = $('#'+parent).attr('value');
		$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());

	childVal = (typeof childVal == "undefined")? "" : childVal ;
	$("#"+child+' option[@value="'+ childVal +'"]').attr('selected','selected');

	$('#'+parent).change( 
		function()
		{
			var parentValue = $('#'+parent).attr('value');
			$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
			//if(isSubselectOptional) $('#'+child).prepend("<option value='none'> -- Select -- </option>");
			$('#'+child).trigger("change");
            $('#'+child).focus();
		}
	);
}

	$(document).ready(function()
	{
		// Poste souhaité
		makeSublist('child','grandsun', true, '');	
		makeSublist('parent','child', false, '1');	
		makeSublist('child1','grandsun1', true, '');	
		makeSublist('parent1','child1', false, '1');	
		makeSublist('child2','grandsun2', true, '');	
		makeSublist('parent2','child2', false, '1');	
		makeSublist('child3','grandsun3', true, '');	
		makeSublist('parent3','child3', false, '1');
		
		// Recherche rapide d'offre
		makeSublist('ro_child','ro_grandsun', true, '');	
		makeSublist('ro_parent','ro_child', false, '1');	
		makeSublist('ro_child1','ro_grandsun1', true, '');	
		makeSublist('ro_parent1','ro_child1', false, '1');	
		makeSublist('ro_child2','ro_grandsun2', true, '');	
		makeSublist('ro_parent2','ro_child2', false, '1');	
		makeSublist('ro_child3','ro_grandsun3', true, '');	
		makeSublist('ro_parent3','ro_child3', false, '1');
		
		// Recherche rapide de candidat
		makeSublist('rc_child','rc_grandsun', true, '');	
		makeSublist('rc_parent','rc_child', false, '1');	
		makeSublist('rc_child1','rc_grandsun1', true, '');	
		makeSublist('rc_parent1','rc_child1', false, '1');	
		makeSublist('rc_child2','rc_grandsun2', true, '');	
		makeSublist('rc_parent2','rc_child2', false, '1');	
		makeSublist('rc_child3','rc_grandsun3', true, '');	
		makeSublist('rc_parent3','rc_child3', false, '1');	
	});