function inicio ()
{
		oInf=new Info()
		oInf.obtDims()
		
		//cSelDestino = new Capa ("selDestino")
		cTxtOrigen2 = new Capa ("txtOrigen2")

		ponerOrigen(document.forms[0].origen[document.forms[0].origen.selectedIndex].text)

		// Si se da un paso atrás y hay origen ponemos los destino
		if (document.forms[0].origen.selectedIndex != 0)
		{
			pon_destino()
			// Marcamos la opcion que tenía antes
			marcarSelect (document.forms[0].destino, sDestinoCod)
			//sDestinoCod
		}
}


function mostrarTxtCabecera()
{
	var sTitulo = "Avisos"
	var sMensaje = ""

	if (sLinea1 != "")
		sMensaje = addLnAyuda(sLinea1)

	if (sLinea2 != "")
		sMensaje = sMensaje + addLnAyuda(sLinea2)

	if (sLinea3 != "")
		sMensaje = sMensaje + sLinea3

	loadPopTxtCabeceraA ('vibasa/txtCabecera.jsp?sTitulo='+escape(sTitulo)+'&sMensaje='+escape(sMensaje))
}

function centrar()
{
	oInf.obtDims() ;

	var TamWidth = cTodo.an
	var TamHeight = cTodo.al

	alturaTotal = (oInf.al - TamHeight)/2
	anchuraTotal = (oInf.an - TamWidth)/2

	if (oInf.al > TamHeight)
	{
		cSelDestino.pnY (alturaTotal+164)
		cTodo.pnY (alturaTotal+0)
		cTabla.pnY (alturaTotal+92)		
		cMnuFondo.pnY (alturaTotal+TamHeight+2)
	}
	else
	{
		cSelDestino.pnY (164)
		cTodo.pnY (0)
		cTabla.pnY (92)
		cMnuFondo.pnY (TamHeight+2)
	}


	if (oInf.an > TamWidth)
	{
		cSelDestino.pnX (anchuraTotal+219)
		cTodo.pnX (anchuraTotal+0)
		cTabla.pnX (anchuraTotal+7)
		cMnuFondo.pnX (anchuraTotal+0)
	}
	else
	{
		cSelDestino.pnX (219)
		cTodo.pnX (0)
		cTabla.pnX (7)
		cMnuFondo.pnX (0)
	}

}

function pon_destino()
{
	//cSelDestino.mostrar ()
	setDestino (document.forms[0].origen[document.forms[0].origen.selectedIndex].value)

	// Si es ida y vuelta ponemos el texto de vuelta
	//ponerOrigen(document.forms[0].origen[document.forms[0].origen.selectedIndex].text)
}


function ponerOrigen(txt)
{
		var origen = document.forms[0].origen
		var destino = document.forms[0].destino

	  // Ponemos el texto del regreso
		if (document.forms[0].rTipo[1].checked)
		{
			//origen2.innerText='Vuelta:      '+ txt
			cTxtOrigen2.escTxt ('eCBTxt', 'Vuelta:      '+ txt)
		}
		else
		{
			//origen2.innerText=''
			cTxtOrigen2.escTxt ('eCBTxt', '')
		}			
}


function confirmar()
{
	var origen = document.forms[0].origen
	var destino = document.forms[0].destino
	var rTipo = document.forms[0].rTipo

	if (origen.selectedIndex == 0)
		alert ("Es necesario especificar un origen")
	else if (destino.selectedIndex == 0)
		alert ("Es necesario especificar un destino")
	else if (!rTipo[0].checked && !rTipo[1].checked)
		alert ("Es necesario especificar un tipo de billete")
	else
	{
		document.forms[0].btnConfirmar.disabled = true

		document.location.href='/vibasa/Usuarios/Compra/compra2.jsp'+
													 '?sOrigen='+escape(origen[origen.selectedIndex].text)+
													 '&sOrigenCod='+escape(origen[origen.selectedIndex].value)+
													 '&sDestino='+escape(destino[destino.selectedIndex].text)+
													 '&sDestinoCod='+escape(destino[destino.selectedIndex].value)+
													 '&bIdaYVuelta='+rTipo[1].checked
	}

}

function ayuda()
{
	var sTitulo = "Compra de billetes (1/8)"
	var sMensaje = addLnAyuda("No se permite dejar la vuelta abierta.") +
								 "Para descuentos de ida y vuelta descuento en 2º trayecto."

	loadPopUpAyuda ('vibasa/Usuarios/Ayuda.jsp?sTitulo='+escape(sTitulo)+'&sMensaje='+escape(sMensaje))
}


///////////////////////////////////////////////////////////////////

function marcarSelect (s , txt)
{
	//document.forms[0].destino.options[2].selected = true
	for (i=0; i<document.forms[0].destino.length; i++)
	{
		if (document.forms[0].destino.options[i].value == txt)
			document.forms[0].destino.options[i].selected = true
	}
}

function addElemento (etiqueta, valor, elemento)
{
	var optionNuevo = new Option(etiqueta, valor)
	elemento.options[elemento.length] = optionNuevo
}

