if (iIdioma == 2){
 sTextoInicio = "Select";
 sTextoInicioVacio = "Select";
 sTextoTransitorio = "Loading data...";
} else{
 sTextoInicioVacio = "Selecciona un tren";
 sTextoInicio = "Selecciona una fecha";
 sTextoTransitorio = "Cargando datos...";
}

var plazas = new Array();

function cargarFechas(idtren){

	var i;
	var iOptionSelect = "";
	var optGroup;
	var item;


	var oElemento = document.getElementById('fDesde');
	var ajax=nuevoAjax();

	// Envio al servidor el valor seleccionado y el combo al cual se le deben poner los datos
	ajax.open("GET", "/inc/aplicacionesPerso/trenesturisticosTpv/fechas.asp?idtren=" + idtren, true);

	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 1)
		{
			// Mientras carga elimino la opcion "Seleccione" y pongo una que dice "Cargando..."
			cargando(oElemento);
		}
		if (ajax.readyState == 4)
		{
			var selectedArray = ajax.responseText.split("##");

			oElemento.options.length = 0;
			if (idtren !=0){
		  	oElemento.options[0] = new Option(sTextoInicio, 0);
		  }else{
		  	oElemento.options[0] = new Option(sTextoInicioVacio, 0);
		  }

			for (i = 1; i < selectedArray.length; i++)
			{
				if (selectedArray[i-1].split("||")[0] == "optgroup"){
					optGroup = document.createElement('optgroup')
					optGroup.label = selectedArray[i-1].split("||")[1]
					oElemento.appendChild(optGroup)
				}else{
					item = new Option();
					optGroup.appendChild(item);
					aux=selectedArray[i-1].split("||")[0]
					plazas[aux.split("_")[0]] = aux.split("_")[1];
					item.value = aux.split("_")[0];
	  				item.text = selectedArray[i-1].split("||")[1];

				}
			}

			if (oElemento.options.length > 0){
				oElemento.options[0].selected = true;
			}

			oElemento.disabled = false;
		}
	}
	ajax.send(null);

	}

	function cargando(oCampo) {
		// Vaciamos el combo
		var elemento = oCampo;
		while (elemento.lastChild && elemento.options.length > 1 ) {
			elemento.removeChild(elemento.lastChild);
		}
		elemento[0].innerHTML=sTextoTransitorio;
		elemento.disabled = true;
	}

	function nuevoAjax()
	{
		/* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
		lo que se puede copiar tal como esta aqui */
		var xmlhttp=false;
		try
		{
			// Creacion del objeto AJAX para navegadores no IE
			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				// Creacion del objet AJAX para IE
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(E) { xmlhttp=false; }
		}
		if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); }

		return xmlhttp;
	}

function cargarPlazasDisponibles(fecha){
	var input
	input=document.forms['noticiaForm'].plazasMaximas;
	input.value=plazas[fecha];
}