// JavaScript Document
/**
*
* @param {Object} selParent => ID del combo padre
* @param {Object} selChild => ID del combo hijo
* @param {Object} isSubselectOptional => si es TRUE: muestra un "-- seleccione --" en el combo hijo
										 si es FALSE: muestra directamente el primer elemento del combo hijo
* @param {Object} selChildVal => Valor del elemento seleccionado por defecto
* @param {Object} sLabelChild => Label para el combo hijo, en primera instancia
*/


function JS_hacerSublista(selParent, selChild, isSubselectOptional, selChildVal, sLabelChild)
{
	$("body").append('<select style="display:none;" id="' + selParent + selChild + '"></select>');
	$('#' + selParent + selChild).html($("#" + selChild + " option"));
	var selParentValue = $('#' + selParent).attr('value');
	$('#'+selChild).html($("#" + selParent + selChild + " .sub_" + selParentValue).clone());
	selChildVal = (typeof selChildVal == "undefined") ? "" : selChildVal;
	$("#"+selChild+' option[value="'+ selChildVal +'"]').attr('selected', 'selected');

	if (typeof sLabelChild != "undefined")
	{
		$('#' + selChild).prepend("<option value='0'>" + sLabelChild + "</option>");
	}
	$('#'+selParent).change(function()
	{
		var selParentValue = $('#'+selParent).attr('value');
		$('#'+selChild).html($("#"+selParent+selChild+" .sub_"+selParentValue).clone());
		if (isSubselectOptional)
		{
			$('#' + selChild).prepend("<option value='0'> -- Seleccione -- </option>");
			$("#" + selChild + ' option[value="' + selChildVal + '"]').attr('selected', 'selected');
		}
		$('#'+selChild).trigger("change");
		$('#'+selChild).focus();
	});
}
