// JQuery dependent select lists. Thanks to Anis Ahmad @ http://www.ajaxray.com/blog/2007/11/08/jquery-controlled-dependent-or-cascading-select-list-2/

function makeSublist(parent,child,isSubselectOptional,childVal)
{
	jQuery("body").append("<select style='display:none' id='"+parent+child+"'></select>");
	jQuery('#'+parent+child).html(jQuery("#"+child+" option"));
	
		var parentValue = jQuery('#'+parent).attr('value');
		jQuery('#'+child).html(jQuery("#"+parent+child+" .sub_"+parentValue).clone());
	
	childVal = (typeof childVal == "undefined")? "" : childVal ;
	jQuery("#"+child).val(["'+ childVal +'"]).attr("selected","selected");
	
	jQuery('#'+parent).change( 
		function()
		{
			var parentValue = jQuery('#'+parent).attr('value');
			jQuery('#'+child).html(jQuery("#"+parent+child+" .sub_"+parentValue).clone());
			if(isSubselectOptional) jQuery('#'+child).prepend("<option value='none'> -- Select -- </option>");
			jQuery('#'+child).trigger("change");
                        jQuery('#'+child).focus();
		}
	);
}



