// JavaScript Document

	function calcula() {

		
		// Declaración de variables
		var nImporteServicio = parseInt(129 * 1.16)
		var nGastosdeGestion = parseInt(100 * 1.16)
		var nMiniBus = 30 + parseInt(270 * 1.07) // Minibus 20 plazas
		var nAutoBus = 60 + parseInt(330 * 1.07) // Bus de 55 plazas
		var nSuplementoFestivo = parseInt(34 * 1.20 * 1.16)
		var nSuplementoNocturno = parseInt(30 * 1.20 * 1.16)
		var nSuplementoIdioma = parseInt(30 * 1.20 * 1.16)
		var nPrecioEntrada = 10
		var cTipo = ""
		
		
		// Precio por nº de personas
		if (document.getElementById('adultos').value <= 19) {
			nImporteServicio = nImporteServicio + nGastosdeGestion + nMiniBus
		} else {
			nImporteServicio = nImporteServicio + nGastosdeGestion + nAutoBus
		}
		nImporteServicio = nImporteServicio + (document.getElementById('adultos').value * nPrecioEntrada)
		document.getElementById('importeservicio').value = nImporteServicio

		
		// Suplemento festivo para sábados y domingos
		try {
		   cDia = window.calendar.date.toString()
		   cDia = cDia.substring(0, 3)
		} catch(e) {
		   cDia = ""
		}
		if (cDia == "Sat" || cDia == "Sun") {
			nImporteServicio = nImporteServicio + nSuplementoFestivo
			document.getElementById('importefestivo').value = nSuplementoFestivo
			cTipo = cTipo + " Festivo, "
		} else if (cDia == "") {
			document.getElementById('fechainicial').value = ""
			document.getElementById('importefestivo').value = 0
		} else {
			document.getElementById('importefestivo').value = 0
		}


		// Suplemento por horario nocturno
		if (document.getElementById('hora').value == "20:00") {
			nImporteServicio = nImporteServicio + nSuplementoNocturno
			document.getElementById('importehorario').value = nSuplementoNocturno
			cTipo = cTipo + " Nocturno, "
		} else {
			document.getElementById('importehorario').value = 0
		}
	
	
		// Suplemento por idioma
//		if (document.getElementById('idioma').value != "Español") {
//			nImporteServicio = nImporteServicio + nSuplementoIdioma
//			document.getElementById('importeidioma').value = nSuplementoIdioma
//		} else {
//			document.getElementById('importeidioma').value = 0
//		}
		cTipo = cTipo + "en " + document.getElementById('idioma').value
		
		
		// Guarda tipo de servicio
		document.getElementById('tipo').value = cTipo
		

		// Guarda el importe total
		document.getElementById('importe').value = nImporteServicio

				
		// Guarda el total a pagar
		document.getElementById('apagar').value = nImporteServicio
		

	}

	
	function enviaform(fo,n) {

		calcula()
		
		// Pago mediante tarjeta
		if (document.getElementById('formadepago').value == 2) {
			if (checkfechareservavalida(fo.fechainicial.value,n) == true) {
				fo.fechainicial.disabled = false
				document.reservas.action = "https://www.prodins.com/tpv/sgtarjeta.asp"
				document.reservas.submit()
			}
		// Pago por transferencia
		} else {
			if (checkfechareservavalida(fo.fechainicial.value,7) == true) {
				fo.fechainicial.disabled = false
				document.reservas.action = "https://www.prodins.com/tpv/sgtransferencia.asp"
				document.reservas.submit()
			}
		}
		
	}
