
// See: http://www.ajaxray.com/blog/2007/11/08/jquery-controlled-dependent-or-cascading-select-list-2/


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').replace(/ /, "_"); // modified
	$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());

	childVal = (typeof childVal == "undefined")? "" : childVal ;
	$("#"+child).val(childVal).attr('selected','selected');


	$('#'+parent).change(
		function()
		{
			var parentValue = $('#'+parent).attr('value').replace(/ /, "_"); // modified
			$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());

			if(isSubselectOptional)
				$('#'+child).prepend("<option value='none'> -- Select -- </option>");

			$('#'+child).trigger("change");
      $('#'+child).focus();
		}
	);
}
