function inicia_datepicker(idioma_id, selector_datepicker, obj_datepicker_inid)
{
	//idioma_id se deja de usar porque idioma_jq es el que indica el idioma de trabajo
	var selector_inid = typeof selector_datepicker != "undefined" ? selector_datepicker : "";
	leyendas_idioma("calendario_jq", "", "", function()
	{
		var nombre_idioma = tag_idioma_jq();
		if( $.browser.mozilla && parseFloat($.browser.version) < 4.0 )
		{
			setTimeout(function()
			{
				leyendas_datepicker(nombre_idioma, 1);
				crea_datepicker(selector_inid, obj_datepicker_inid);
			}, 500);
		}
		else
		{
			leyendas_datepicker(nombre_idioma, 1);
			crea_datepicker(selector_inid, obj_datepicker_inid);
		}
	}, true);
}
var jq_cont_global_dp = 0;
function crea_datepicker(selector_cd, obj_datepicker_cd)
{
	var selector_class = (typeof selector_cd == 'undefined' || selector_cd == "") ? "datepicker_qn" : selector_cd;
	var id_nuevo = "";
	var id_campo_texto = "";
	var clase = "";
	var src_img_calendario = '/principal/img/cal.gif';
	var id_actual = "";
	var nombre_actual = "";
	var valor_oculto = "";
	$("." + selector_class).each(function()
	{
		jq_cont_global_dp++;
		id_actual = $(this).attr('id');
		nombre_actual = $(this).attr('name');
		id_nuevo = id_actual + "-dp-" + jq_cont_global_dp;
		id_campo_texto = "fecha-dp-" + jq_cont_global_dp;
		$(this).attr("id", id_nuevo);
		$(this).removeClass(selector_class);
		clase = $(this).attr('class');
		$(this).removeClass("required").removeClass("ui-corner-all");
		valor_oculto = $(this).val();

		$(this).before('<input type="text" id="' + id_campo_texto + '" class="' + clase + '" name="hum_' + nombre_actual + '" readonly="yes" />');

		var obj_datepicker_ = $.extend({
			showAnim: '',
			showButtonPanel: true,
			dateFormat:'DD, d MM, yy',
			buttonText: leyenda['buttonText'],
			altField: "#" + nombre_campo_jq(id_nuevo),
			altFormat: "yy-mm-dd",//"dd/mm/yy"
			changeMonth: true,
			changeYear: true,
			showOn: 'both',
			buttonImage: src_img_calendario,
			onSelect: function(dateText, inst)
			{
				// para que conviva con el validate, mandarlo validar al elegir una fecha:
				if ($(this).hasClass("required"))
				{
					$(this).valid();
				}
			}
			// parche para FF cuando hay un "yearRange" muy grande flashea la pagina al mostrar el Datepicker
			// La otra parte del parche es una clase css
//			beforeShow: $.browser.mozilla? function() {setTimeout('$(".ui-datepicker-year").show();',100);} : function() {},
//			onChangeMonthYear: $.browser.mozilla? function() {setTimeout('$(".ui-datepicker-year").show();',100);} : function() {},
//			onClose: $.browser.mozilla? function() {$(".ui-datepicker-year").hide();} : function() {}
		}, obj_datepicker_cd);
		var nvo_input_datepicker = $("#" + id_campo_texto);
		if( nvo_input_datepicker.length > 0 )
		{
			$(this).hide();
			nvo_input_datepicker.datepicker(obj_datepicker_);
			if (valor_oculto != "")
			{
				var arr_fecha = valor_oculto.split(/[-./]/gi);
				var anio_ = parseInt(arr_fecha[0]);
				var mes_ = parseInt(arr_fecha[1], 10) - 1;
				var dia_ = parseInt(arr_fecha[2], 10);

				if (anio_ > 0 && mes_ >= 0 && dia_ > 0)
				{
					nvo_input_datepicker.val($.datepicker.formatDate(obj_datepicker_.dateFormat, new Date(anio_, mes_, dia_)));
				}
			}
			refresca_datepicker(nvo_input_datepicker);
		}
	});
}
function refresca_datepicker(ref_elemento)
{
	ref_elemento
		.next("button.ui-datepicker-trigger")
		.html(leyenda['buttonText'])
		.css({marginLeft:3, height:22, width:22})
		.button({
			icons:{primary:"ui-icon-calendar"},
			text:false
		});
}
function leyendas_datepicker(nombre_idioma, debug)
{
	if( typeof(nombre_idioma) != "undefined" && typeof(jQuery.datepicker.regional[nombre_idioma]) == "undefined" )
	{
		var leyendas_datepicker = {
			closeText: leyenda['cerrar'],
			prevText: leyenda['prevText'],
			nextText: leyenda['nextText'],
			currentText: leyenda['currentText'],
			monthNames: [leyenda['monthNames_1'],leyenda['monthNames_2'],leyenda['monthNames_3'],leyenda['monthNames_4'],leyenda['monthNames_5'],
				leyenda['monthNames_6'],leyenda['monthNames_7'],leyenda['monthNames_8'],leyenda['monthNames_9'],leyenda['monthNames_10'],leyenda['monthNames_11'],leyenda['monthNames_12']],
			monthNamesShort:[leyenda['monthNamesShort_1'],leyenda['monthNamesShort_2'],leyenda['monthNamesShort_3'],leyenda['monthNamesShort_4'],leyenda['monthNamesShort_5'],
				leyenda['monthNamesShort_6'],leyenda['monthNamesShort_7'],leyenda['monthNamesShort_8'],leyenda['monthNamesShort_9'],leyenda['monthNamesShort_10'],leyenda['monthNamesShort_11'],leyenda['monthNamesShort_12']],
			dayNames: [leyenda['dayNames_1'],leyenda['dayNames_2'],leyenda['dayNames_3'],leyenda['dayNames_4'],leyenda['dayNames_5'],leyenda['dayNames_6'],leyenda['dayNames_7']],
			dayNamesShort: [leyenda['dayNamesShort_1'],leyenda['dayNamesShort_2'],leyenda['dayNamesShort_3'],leyenda['dayNamesShort_4'],leyenda['dayNamesShort_5'],leyenda['dayNamesShort_6'],leyenda['dayNamesShort_7']],
			dayNamesMin: [leyenda['dayNamesMin_1'],leyenda['dayNamesMin_2'],leyenda['dayNamesMin_3'],leyenda['dayNamesMin_4'],leyenda['dayNamesMin_5'],leyenda['dayNamesMin_6'],leyenda['dayNamesMin_7']],
			dateFormat: 'dd/mm/yy',
			firstDay: 0,
			isRTL: false
		};
		var continuar = true;
		for( var i in leyendas_datepicker )
		{
			if( typeof(leyendas_datepicker[i]) == "undefined" )
			{
				continuar = false;
				if( debug )
				{
					console.log(["leyendas_datepicker: leyenda['", i , "'] == undefined"].join(""));
				}
				else
				{
					break;
				}
			}
			else if( typeof(leyendas_datepicker[i]) == "object" )
			{
				for( var j in leyendas_datepicker[i] )
				{
					if( typeof(leyendas_datepicker[i][j]) == "undefined" )
					{
						continuar = false;
						if( debug )
						{
							console.log(["leyendas_datepicker: leyenda['", i , "']['", j , "'] == undefined"].join(""));
						}
						else
						{
							break;
						}
					}
				}
			}
		}
		if( continuar )
		{
			jQuery.datepicker.regional[nombre_idioma] = $.extend(true, {}, leyendas_datepicker);
			jQuery.datepicker.setDefaults(jQuery.datepicker.regional[nombre_idioma]);
		}
	}
}
/*

 /***********************************
leyendas_idioma("calendario_jq", "", "", function()
{

	var nombre_idioma = tag_idioma_jq(idioma_jq);
	$.datepicker.regional[nombre_idioma] = {
		closeText: leyenda['cerrar'],
		prevText: leyenda['prevText'],
		nextText: leyenda['nextText'],
		currentText: leyenda['currentText'],
		monthNames: [leyenda['monthNames_1'],leyenda['monthNames_2'],leyenda['monthNames_3'],leyenda['monthNames_4'],leyenda['monthNames_5'],
			leyenda['monthNames_6'],leyenda['monthNames_7'],leyenda['monthNames_8'],leyenda['monthNames_9'],leyenda['monthNames_10'],leyenda['monthNames_11'],leyenda['monthNames_12']],
		monthNamesShort:[leyenda['monthNamesShort_1'],leyenda['monthNamesShort_2'],leyenda['monthNamesShort_3'],leyenda['monthNamesShort_4'],leyenda['monthNamesShort_5'],
			leyenda['monthNamesShort_6'],leyenda['monthNamesShort_7'],leyenda['monthNamesShort_8'],leyenda['monthNamesShort_9'],leyenda['monthNamesShort_10'],leyenda['monthNamesShort_11'],leyenda['monthNamesShort_12']],
		dayNames: [leyenda['dayNames_1'],leyenda['dayNames_2'],leyenda['dayNames_3'],leyenda['dayNames_4'],leyenda['dayNames_5'],leyenda['dayNames_6'],leyenda['dayNames_7']],
		dayNamesShort: [leyenda['dayNamesShort_1'],leyenda['dayNamesShort_2'],leyenda['dayNamesShort_3'],leyenda['dayNamesShort_4'],leyenda['dayNamesShort_5'],leyenda['dayNamesShort_6'],leyenda['dayNamesShort_7']],
		dayNamesMin: [leyenda['dayNamesMin_1'],leyenda['dayNamesMin_2'],leyenda['dayNamesMin_3'],leyenda['dayNamesMin_4'],leyenda['dayNamesMin_5'],leyenda['dayNamesMin_6'],leyenda['dayNamesMin_7']],
		dateFormat: 'dd/mm/yy',
		firstDay: 0,
		isRTL: false
	};
	$.datepicker.setDefaults($.datepicker.regional[nombre_idioma]);
	alert("listo")
});

var jq_cont_global_dp = 0;
function crea_datepicker(selector_cd, obj_datepicker_cd)
{
	alert("crea_datepicker")
	var selector_class = (typeof selector_cd == 'undefined' || selector_cd == "") ? "datepicker_qn" : selector_cd;
	var id_nuevo = "";
	var id_campo_texto = "";
	var clase = "";
	var src_img_calendario = '/principal/img/cal.gif';
	var id_actual = "";
	var valor_oculto = "";
	$("." + selector_class).each(function()
	{
		jq_cont_global_dp++;
		id_actual = $(this).attr('id');
		id_nuevo = id_actual + "-dp-" + jq_cont_global_dp;
		id_campo_texto = "fecha-dp-" + jq_cont_global_dp;
		$(this).attr("id", id_nuevo);
		$(this).removeClass(selector_class);
		clase = $(this).attr('class');
		$(this).removeClass("required");
		valor_oculto = $(this).val();

		$(this).before('<input type="text" id="' + id_campo_texto + '" class="' + clase + '" readonly="yes" />');

		var obj_datepicker_ = $.extend({
			showButtonPanel: true,
			dateFormat:'DD, d MM, yy',
			buttonText: leyenda['buttonText'],
			altField: "#" + nombre_campo_jq(id_nuevo),
			altFormat: "yy-mm-dd",//"dd/mm/yy"
			changeMonth: true,
			changeYear: true,
			showOn: 'both',
			buttonImage: src_img_calendario
		}, obj_datepicker_cd);
		var nvo_input_datepicker = $("#" + id_campo_texto);
		if( !!nvo_input_datepicker.length )
		{
			$(this).hide();
			nvo_input_datepicker.datepicker(obj_datepicker_);
			if (valor_oculto != "")
			{
				var arr_fecha = valor_oculto.split(/[-./]/gi);
				var anio_ = parseInt(arr_fecha[0]);
				var mes_ = parseInt(arr_fecha[1], 10) - 1;
				var dia_ = parseInt(arr_fecha[2], 10);

				if (anio_ > 0 && mes_ >= 0 && dia_ > 0)
				{
					nvo_input_datepicker.val($.datepicker.formatDate('DD, d MM, yy', new Date(anio_, mes_, dia_)));
				}
			}
			nvo_input_datepicker
				.next("button.ui-datepicker-trigger")
				.html(leyenda['buttonText'])
				.css({
					marginLeft:3,
					height:22,
					width:22
				})
				.button({
					icons:{
						primary:"ui-icon-calendar"
					},
					text:false
				});
		}
	});
}
*/

