//*** ventana centrada ***
function ventanaCentrada(doc,nombre,anchura,altura, noScroll){
	noScroll = noScroll ? "no" : "yes";
	xpos = ((screen.width)/2)-(anchura/2);
	ypos = ((screen.height)/2)-(altura/2);
	ventanaFlotante = window.open(doc,nombre,'width='+anchura+',height='+altura+',left='+xpos+',top='+ypos+'directories=0,resizable=0,location=0,status=0,scrollbars='+noScroll+',toolbar=0,menubar=0,titlebar=1');
}


//*** Menú lateral izquierdo ***
function rescatalink(src) {
	if(event.srcElement.tagName=='TD'){
	src.children.tags('A')[0].click();
	}
}


//*** preload imagenes para roollover ***
function preload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}


var r={
  'special':/[^A-Z a-z 0-9 áóúñéíªº@_,&.-]/gi,
  'quotes':/['\''&'\"']/g,
  'notnumbers':/[^\d]/g
}

function valid(o,w){
  o.value = o.value.replace(r[w],'')
}

$().ready(function() {
	$('input').keyup( function(){
		valid(this,'special')
	})
	$('input').blur( function(){
		valid(this,'special')
	})
	$('textarea').keyup( function(){
		valid(this,'special')
	})
	$('textarea').blur( function(){
		valid(this,'special')
	})
})

//*** css formularios ***
function cambiaCSS(obj, nombreCSS)	{
	obj.className = nombreCSS;
}

function cuotAcompanante (alfa){
	if (document.getElementById("ciruacomp").checked == true){
		document.getElementById("ciruacomp_fake").value = alfa
		document.getElementById("acompaTr").style.display='inline';		
		resultadototal()
	} else {
		document.getElementById("ciruacomp_fake").value = 0
		document.getElementById("acompaTr").style.display='none';		
		resultadototal()
	}
};


//*** chekea campo mail ***
function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++) {
		if(ok.indexOf(e.charAt(i))<0) {
			return (false);
		}	
	}
	
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}




//*** chekea vencimiento tarjeta credito ***
function vencetarjeta (m, a, asd) {
	asd.value = ""
	fecha = new Date(); 
	mes = fecha.getMonth()+1
	anio = fecha.getYear()
	if (a == anio) { 
		if (m > mes) {
			asd.value = 1
		} else {
			asd.value = ""
		}
	}
	if (a > anio) {
		asd.value = 1
	} 
}




function compruebaEmail(obj) 	{
	msg = "Your e-mail is not valid. Please, try again.";
	if (obj.value!="")
		if (!check_email(obj.value)) 	{
			alert (msg);
			obj.focus();
			return false
		}
}
	
	
function testForm()	{
	msg = "You must fill in all the mandatory fields.\n\nThe following data are missing:\n\n";
	camposNoRellenados = new Array();
	cont = 0;
	primero = "";
	
	if (document.getElementById("aceptoLegal").checked == true) {
		
			for (i=0;i<camposObligatorios.length;i++) {
				if (camposObligatorios[i].indexOf(";") != -1) {
					chbox = new Array();
					chbox = camposObligatorios[i].split(";");
					valor = "";
					
					for (p=0;p<chbox.length;p++) {
						if (chbox[p].length > 1 && document.getElementById(chbox[p]).checked == true) {
							valor = "ok";
						}
					}
					if (primero == "") {
						primero = chbox[0];
					}
				} else {
					elemento = document.getElementById(camposObligatorios[i]);
					valor = elemento.value;
					if (primero == "") {
						primero = camposObligatorios[i];
					}
				}
				if (valor == undefined || valor == "" || valor == null) {
					camposNoRellenados[cont++] = textoCamposObligatorios[i];
				}
			}
			
			if (cont > 0) {
		
				for (i=0;i<cont;i++) { msg += " · "+camposNoRellenados[i]+".\n";}
				alert (msg);
				//document.getElementById(primero).focus();
			} else {
				document.formulario1.submit()
			}
			
	} else {
		
		alert ("You must accept the legal clause");
	}
}




function testForm1()	{
	camposObligatorios = new Array ("nombre", "email", "comentarios");
	textoCamposObligatorios = new Array ("First and Last Name", "E-mail", "Comments");
	msg = "You must fill in all the mandatory fields.\n\nThe following data are missing:\n\n";
	camposNoRellenados = new Array();
	cont = 0;
	primero = "";
	
		
			for (i=0;i<camposObligatorios.length;i++) {
				if (camposObligatorios[i].indexOf(";") != -1) {
					chbox = new Array();
					chbox = camposObligatorios[i].split(";");
					valor = "";
					
					for (p=0;p<chbox.length;p++) {
						if (chbox[p].length > 1 && document.getElementById(chbox[p]).checked == true) {
							valor = "ok";
						}
					}
					if (primero == "") {
						primero = chbox[0];
					}
				} else {
					elemento = document.getElementById(camposObligatorios[i]);
					valor = elemento.value;
					if (primero == "") {
						primero = camposObligatorios[i];
					}
				}
				if (valor == undefined || valor == "" || valor == null) {
					camposNoRellenados[cont++] = textoCamposObligatorios[i];
				}
			}
			
			if (cont > 0) {
		
				for (i=0;i<cont;i++) { msg += " · "+camposNoRellenados[i]+".\n";}
				alert (msg);
				//document.getElementById(primero).focus();
			} else {
				document.formulario1.submit()
			}
}


function testForm2()	{
	hoteles = new Array
	hotelestxt = new Array
	tarjeta2 = new Array
	tarjeta2txt = new Array	
	facturacion1hot = new Array	
	facturacion1hottxt = new Array	
	personales = new Array ("apellidos", "nombre", "direccion", "cp", "ciudad", "pais", "telefono", "email", "cifnif");
	personalestxt = new Array ("Last Name", "First Name", "Address", "Postal Code", "City", "Country", "Telephone", "E-mail", "Passport number");

	if (getRadioButtonSelectedValue(document.formulario1.formadepago1) == 0){
	ValidarTJ (document.formulario1.pagoi_numa.value, document.formulario1.pagoi_numb.value, document.formulario1.pagoi_numc.value, document.formulario1.pagoi_numd.value, "registration")
	tarjeta1 = new Array ("pagoi_tarjeta_oculto","pagoi_tarjeta_ok", "pagoi_titular", "pagoi_fechaok", "pagoi_ccc")
	tarjeta1txt = new Array ("Registration: Type of card","Registration: Card no.",  "Registration: Name of cardholder", "Registration: Expiration date", "Registration: Security Code")
	} else {
	tarjeta1 = new Array
	tarjeta1txt = new Array
	}
	
		
	if (document.formulario1.pagoi_transferencia.checked) {	
		tarjeta1 = new Array ("pagoi_comprobante")
		tarjeta1txt = new Array ("Payment receipt")
	}
	
	
	
	if (getRadioButtonSelectedValue(document.formulario1.facturacion) == 1){
		facturacion1 = new Array ("factu1_apellidos", "factu1_nombre", "factu1_nif", "factu1_direccion")
		facturacion1txt = new Array ("Invoice: Last name", "Invoice: First name", "Invoice: Passport number", "Invoice: Address for invoice")
	} else {
		facturacion1 = new Array ("factu2_empresa", "factu2_cif", "factu2_direccion");
		facturacion1txt = new Array ("Invoice: Company name", "Invoice: Company VAT number", "Invoice: Address for invoice");
	}
	
	
	
	
	
	if (getRadioButtonSelectedValue(document.formulario1.reserva) == 1){
	hoteles = new Array ("hotel1")
	hotelestxt = new Array ("Hotel Options")
	
		if (document.formulario1.hotel1.options.value.length > 0) {
			hoteles = new Array ("hotel_noreservas", "hotel_noches_total")
			hotelestxt = new Array ("Room reservation", "Dates of arrival and departure")
		
			if (getRadioButtonSelectedValue(document.formulario1.formadepago2) == 0) {	
				ValidarTJ2 (document.formulario1.pagoh_numa.value, document.formulario1.pagoh_numb.value, document.formulario1.pagoh_numc.value, document.formulario1.pagoh_numd.value, "hotel")
				tarjeta2 = new Array ("pagoh_tarjeta_oculto", "pagoh_tarjeta_ok", "pagoh_titular", "pagoh_fechaok", "pagoh_ccc")
				tarjeta2txt = new Array ("Hotel: Type of card","Hotel: Card no", "Hotel: Name of cardholder", "Hotel: Expiration date", "Hotel: Security Code")
				
			}
			
			if (document.formulario1.pagoh_transferencia.checked) {	
				tarjeta1 = new Array ("pagoh_comprobante")
				tarjeta1txt = new Array ("Hotel: Payment receipt")
			}
		}
		
		
		if (getRadioButtonSelectedValue(document.formulario1.facturacion_hotel) == 1){
			facturacion1hot = new Array ("factu1_hotel_apellidos", "factu1_hotel_nombre", "factu1_hotel_nif", "factu1_hotel_direccion")
			facturacion1hottxt = new Array ("Hotel Invoice: Last name", "Hotel Invoice: First name", "Hotel Invoice: Passport number", "Hotel Invoice: Address for invoice")
		}
		if (getRadioButtonSelectedValue(document.formulario1.facturacion_hotel) == 0){
			facturacion1hot = new Array ("factu2_hotel_empresa", "factu2_hotel_cif", "factu2_hotel_direccion");
			facturacion1hottxt = new Array ("Hotel Invoice: Company name", "Hotel Invoice: Company VAT number", "Hotel Invoice: Address for invoice");
		}
		if (getRadioButtonSelectedValue(document.formulario1.facturacion_hotel) == 2){
			facturacion1hot = new Array ();
			facturacion1hottxt = new Array ();
		}			
		
		
		
		
		
	}
	
	
	inspago = personales.concat (tarjeta1, facturacion1)
	inspagotxt = personalestxt.concat (tarjeta1txt, facturacion1txt)
	
	hotpago = hoteles.concat (tarjeta2, facturacion1hot)
	hotpagotxt = hotelestxt.concat (tarjeta2txt, facturacion1hottxt)
	
	datofinal =  inspago.concat(hotpago)
	datofinaltxt =  inspagotxt.concat(hotpagotxt)
	

	camposObligatorios = datofinal
	textoCamposObligatorios = datofinaltxt
	
	testForm()
}



// Funcion que comprueba que "valor" es un numero entero
function EsNumeroEntero(valor){
    var cadena = valor.toString();
	var longitud = cadena.length;
	if (longitud == 0){return false;}
	var ascii = null;
    for (var i=0; i<longitud; i++) {
		ascii = cadena.charCodeAt(i);
        if (ascii < 48 || ascii > 57){return false;}
    }
	return true;
}


// Funcion que valida la tarjeta de credito
function ValidarTJ(numa,numb,numc,numd,seccion) {
	if  (numa.length + numb.length + numc.length + numd.length == 16){
		document.formulario1.pagoi_tarjeta_ok.value = "1"
	} else {
		document.formulario1.pagoi_tarjeta_ok.value = ""
		alert ("The credit card number in the Registration field is wrong");
	};
}


function ValidarTJ2(numa,numb,numc,numd,seccion) {
	if  (numa.length + numb.length + numc.length + numd.length == 16){
		document.formulario1.pagoh_tarjeta_ok.value = "1"
	} else {
		document.formulario1.pagoh_tarjeta_ok.value = ""
		alert ("The credit card number in the Hotel field is wrong");
	};
}



function numbersonly(myfield, e, dec){
	var key;
	var keychar;
	
	if (window.event)
	   key = window.event.keyCode;
	else if (e)
	   key = e.which;
	else
	   return true;
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key==null) || (key==0) || (key==8) ||
	    (key==9) || (key==13) || (key==27) )
	   return true;
	
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	   return true;
	
	// decimal point jump
	else if (dec && (keychar == "."))
	   {
	   myfield.form.elements[dec].focus();
	   return false;
	   }
	else
	   return false;
}



function definepagoi(){
document.formulario1.pagoi_tarjeta_oculto.value = getRadioButtonSelectedValue(document.formulario1.pagoi_tarjeta)
} 

function definepagoh(){
document.formulario1.pagoh_tarjeta_oculto.value = getRadioButtonSelectedValue(document.formulario1.pagoh_tarjeta)
} 


function transferencia1(){

if (document.getElementById('pagoi_transferencia').checked) {
document.getElementById('pagoi_comprobante').disabled= false
} 

if (document.getElementById('pagoi_transferencia').checked == false) {
document.getElementById('pagoi_comprobante').disabled= true
}

}

function transferencia2(){

if (document.getElementById('pagoh_transferencia').checked) {
document.getElementById('pagoh_comprobante').disabled= false
} 

if (document.getElementById('pagoh_transferencia').checked == false) {
document.getElementById('pagoh_comprobante').disabled= true
}

}


function muestrahotel() {
	document.getElementById('hotel').style.display='inline';
}

function ocultahotel() {
	document.getElementById('hotel').style.display='none';
}


function muestrapago1() {
	document.formulario1.pagoi_tarjeta_oculto.value = ""
	document.getElementById('pagoi_transferencia').checked= false
	document.getElementById('pagoi_comprobante').disabled= true
	document.getElementById('pago1c').style.display='none';
	document.getElementById('pago1t').style.display='inline';
	document.formulario1.formadepago2[2].disabled= true
}

function ocultapago1() {
	document.formulario1.pagoi_tarjeta_oculto.value = ""
	document.getElementById('pagoi_transferencia').checked= false
	document.getElementById('pagoi_comprobante').disabled= true
	document.getElementById('pago1c').style.display='inline';
	document.getElementById('pago1t').style.display='none';
	document.formulario1.formadepago2[2].disabled= false
}


function muestrapago2() {
	document.formulario1.pagoh_tarjeta_oculto.value = ""
	document.getElementById('pagoh_transferencia').checked= false
	document.getElementById('pagoh_comprobante').disabled= true
	document.getElementById('pago2c').style.display='none';
	document.getElementById('pago2t').style.display='inline';
}

function ocultapago2() {
	document.formulario1.pagoh_tarjeta_oculto.value = ""
	document.getElementById('pagoh_transferencia').checked= false
	document.getElementById('pagoh_comprobante').disabled= true
	document.getElementById('pago2c').style.display='inline';
	document.getElementById('pago2t').style.display='none';
}

function clonapago2() {
	document.formulario1.pagoh_tarjeta_oculto.value = ""
	document.getElementById('pagoh_transferencia').checked= false
	document.getElementById('pagoh_comprobante').disabled= true
	document.getElementById('pago2c').style.display='none';
	document.getElementById('pago2t').style.display='none';
}


function muestrafactu() {
	document.getElementById('factu1').style.display='none';
	document.getElementById('factu2').style.display='inline';
}

function ocultafactu() {
	document.getElementById('factu1').style.display='inline';
	document.getElementById('factu2').style.display='none';
}


function muestrafactuhotel() {
	document.getElementById('factu1hotel').style.display='none';
	document.getElementById('factu2hotel').style.display='inline';
}

function ocultafactuhotel() {
	document.getElementById('factu1hotel').style.display='inline';
	document.getElementById('factu2hotel').style.display='none';
}

function antesfactuhotel() {
	document.getElementById('factu1hotel').style.display='none';
	document.getElementById('factu2hotel').style.display='none';
}
 

function muestraposter1() {
		document.getElementById('poster_archivo1').reset = true
		document.getElementById('poster_archivo2').reset = true
		document.getElementById('poster_archivo3').reset = true		
	document.getElementById('poster1').style.display='inline';
	document.getElementById('poster2').style.display='none';
	document.getElementById('poster3').style.display='none';
}

function muestraposter2() {
		document.getElementById('poster_archivo1').reset = true
		document.getElementById('poster_archivo2').reset = true
		document.getElementById('poster_archivo3').reset = true			
	document.getElementById('poster1').style.display='none';
	document.getElementById('poster2').style.display='inline';
	document.getElementById('poster3').style.display='none';
}

function muestraposter3() {
		document.getElementById('poster_archivo1').reset = true
		document.getElementById('poster_archivo2').reset = true
		document.getElementById('poster_archivo3').reset = true			
	document.getElementById('poster1').style.display='none';
	document.getElementById('poster2').style.display='none';
	document.getElementById('poster3').style.display='inline';
}


function muestralegales() {
	if (document.getElementById('legales').style.display=="none") {
		document.getElementById('legales').style.display="inline";
	} else {
		document.getElementById('legales').style.display="none";
	}
}


function muestralegales2() {
	if (document.getElementById('legales2').style.display=="none") {
		document.getElementById('legales2').style.display="inline";
	} else {
		document.getElementById('legales2').style.display="none";
	}
}



function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+'.'+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num );
}

function changeMailing(){
	if (document.getElementById("hmailinglist").checked == true){
		document.getElementById("mailinglist").value = 1
	} else {
		document.getElementById("mailinglist").value = 0
	}
}

function hotelreserva (){
	rhotel= new Array()
	rhotel[0]=""
	rhotel[1]="<img src='img/propias/hotel_abascal.jpg' border='0' vspace='10' align='absmiddle'>"
	rhotel[2]="<img src='img/propias/hotel_hightech.jpg' border='0' vspace='10' align='absmiddle'>"
	
	desc= new Array()
	desc[0]=""
	
	desc[1]="<br>Housed in a meticulously remodeled former embassy building, the NH Abascal offers 183 beautifully-designed rooms, all of which are designed to ensure that you enjoy a comfortable stay. A beautiful marble hall, an extraordinary grand staircase, displays of artwork and an attractive terrace help creates a relaxing yet elegant atmosphere that's guaranteed to impress. <br><a href='http://www.nh-hotels.com/nh/en/hotels/spain/madrid/nh-abascal.html' class='link' target='_blank'>http://www.nh-hotels.com/nh/en/hotels/spain/madrid/nh-abascal.html</a><br><br>"
	
	desc[2]="<br>The Petit Palace Embassy is a boutique hotel and in fact the only hotel situated on calle Serrano, the number-one luxury shopping street in the Salamanca district of Madrid (Gucci, Loewe, Carolina Herrera, Versace, Dior, Dolce & Gabanna, Cartier), adjoining the Plaza de Colón and parallel to Paseo de la Castellana.<br><br>It occupies a nineteenth-century building and has a lovely glassed-in, daylit café, where patrons can enjoy the hotel's breakfast buffet and service from the bar/coffee shop and the El Invernadero gourmet restaurant.<br><br><a href='http://www.hthoteles.com/htm01/inforhotel?hid=18&rv=1&rvid=18&cp=0&user_locale=en_US' class='link' target='_blank'>http://www.hthoteles.com/htm01/inforhotel?hid=18&rv=1&rvid=18&cp=0&user_locale=en_US</a><br><br>"
	
	indice= document.formulario1.hotel1.selectedIndex
	
	titulohotel.innerHTML = document.formulario1.hotel1.options[document.formulario1.hotel1.selectedIndex].value
	imagenhotel.innerHTML = rhotel[indice]
	textohotel.innerHTML  = desc[indice]

	calcula(document.formulario1.desde.value, document.formulario1.hasta.value)
}

function none() {
	descripcionreserva.innerHTML = ""
	resultadoreserva.innerHTML = "<font class='subtitulo'>Please select on the form:  hotel, room reservation and dates of arrival and departure.</font>"
}

function calcula (desde , hasta){

	indivi= new Array()
	indivi[0]=""
	indivi[1]="114"
	indivi[2]="156"
	
	dual= new Array()
	dual[0]=""
	dual[1]="126"
	dual[2]="168"

	indice= document.formulario1.hotel1.selectedIndex

	today = new Date(desde)
	BigDay = new Date(hasta)
	msPerDay = 24 * 60 * 60 * 1000 ;
	timeLeft = (BigDay.getTime() - today.getTime());
	e_daysLeft = timeLeft / msPerDay;
	daysLeft = Math.floor(e_daysLeft);
	
	rhotel = document.formulario1.hotel1.options[document.formulario1.hotel1.selectedIndex].value
	rhotel2 = document.formulario1.hotel2.options[document.formulario1.hotel2.selectedIndex].value
	rhotel3 = document.formulario1.hotel3.options[document.formulario1.hotel3.selectedIndex].value
	
	reserv_indiv = document.formulario1.rindividuales.value *1
	reserv_dobles = document.formulario1.rdobles.value *1
	
	desde2= document.formulario1.desde.options[document.formulario1.desde.selectedIndex].text
	hasta2= document.formulario1.hasta.options[document.formulario1.hasta.selectedIndex].text
	
	totalreserva= ((reserv_indiv * indivi[indice])+(reserv_dobles * dual[indice]))*daysLeft
	condireservas = ((reserv_dobles *1) + (reserv_indiv *1)) *1

	
	if (reserv_indiv == 1){
	reserv_indiv_texto = " single room"
	} else {
	reserv_indiv_texto = " singles rooms"
	}
	
	if (reserv_dobles == 1){
	reserv_dobles_texto = " double room"
	} else {
	reserv_dobles_texto = " double rooms"
	}
	
	if (daysLeft > 1){
	nochetxt = "nights"
	} else {
	nochetxt = "night"
	}
	
	
	if (condireservas > 1){
	reservastxt = "reservations"
	} else {
	reservastxt = "reservation"
	}
	
	
	if (condireservas>0){
	
		descripcionreserva.innerHTML = "Mr./s. " + daysLeft + " " + nochetxt + " hotel reservation " + rhotel + ", arrival: " + reserv_indiv + reserv_indiv_texto + " and " + reserv_dobles  + reserv_dobles_texto + " arrival: " + desde2 + " departure: " + hasta2 + ".";

		resultadoreserva.innerHTML = "<span class='subtitulo'>" + daysLeft + " " +   nochetxt + " x " + condireservas + " " + reservastxt + " :&nbsp;&nbsp;</span><span class='precio_total'>"+ formatCurrency(totalreserva) +"&nbsp;€</span>"

	/*	areaoculta.innerHTML = "<input name='hotel_noches_total' type='hidden' value='"+ daysLeft +"' size='2'><input name='hotel_habitaciones_indivi' type='hidden' value='"+ reserv_indiv +"' size='2'><input name='hotel_habitaciones_dobles' type='hidden' value='"+ reserv_dobles +"' size='2'><input name='hotel_precio_simple' type='hidden' value='"+ indivi[indice] +"' size='2'><input name='hotel_precio_doble' type='hidden' value='"+ dual[indice] +"' size='2'><input name='hotel_entrada' type='hidden' value='"+ desde +"' size='12'><input name='hotel_salida' type='hidden' value='"+ hasta +"' size='12'><input name='hotel_totales' type='hidden' value='"+ totalreserva +"' size='2'><input name='rhotel_eleccion1' type='hidden' value='"+ rhotel +"' size='2'><input name='rhotel_eleccion2' type='hidden' value='"+ rhotel2 +"' size='2'><input name='rhotel_eleccion3' type='hidden' value='"+ rhotel3 +"' size='2'>"

*/
document.formulario1.hotel_noches_total.value = daysLeft
document.formulario1.hotel_habitaciones_indivi.value = reserv_indiv
document.formulario1.hotel_habitaciones_dobles.value = reserv_dobles
document.formulario1.hotel_precio_simple.value = indivi[indice]
document.formulario1.hotel_precio_doble.value = dual[indice]
document.formulario1.hotel_entrada.value = desde
document.formulario1.hotel_salida.value = hasta
document.formulario1.hotel_totales.value = totalreserva
document.formulario1.rhotel_eleccion1.value = rhotel
document.formulario1.rhotel_eleccion2.value = rhotel2
document.formulario1.rhotel_eleccion3.value = rhotel3
if ((reserv_indiv + reserv_dobles) == 0){
document.formulario1.hotel_noreservas.value = ""
} else {
document.formulario1.hotel_noreservas.value = reserv_indiv + reserv_dobles
}


	} else {
	document.formulario1.hotel_noches_total.value = daysLeft
document.formulario1.hotel_habitaciones_indivi.value = reserv_indiv
document.formulario1.hotel_habitaciones_dobles.value = reserv_dobles
document.formulario1.hotel_precio_simple.value = indivi[indice]
document.formulario1.hotel_precio_doble.value = dual[indice]
document.formulario1.hotel_entrada.value = desde
document.formulario1.hotel_salida.value = hasta
document.formulario1.hotel_totales.value = totalreserva
document.formulario1.rhotel_eleccion1.value = rhotel
document.formulario1.rhotel_eleccion2.value = rhotel2
document.formulario1.rhotel_eleccion3.value = rhotel3
if ((reserv_indiv + reserv_dobles) == 0){
document.formulario1.hotel_noreservas.value = ""
} else {
document.formulario1.hotel_noreservas.value = reserv_indiv + reserv_dobles
}

		none()
	}
	if (daysLeft <= 0){
		none()
	}
	if ((document.formulario1.hotel1.options[document.formulario1.hotel1.selectedIndex].index) < 1){
		none()
	}
}

function getRadioButtonSelectedValue(ctrl){
    for(i=0;i<ctrl.length;i++)
        if(ctrl[i].checked) return ctrl[i].value;
}


function resultadototal(){
	antes = new Array ()
	antes[0] = 0
	antes[1] = 300  
	antes[2] = 400  
	antes[3] = 200  
	
	entre = new Array ()
	entre[0] = 0
	entre[1] = 350  
	entre[2] = 450  
	entre[3] = 250  
	
	despues = new Array ()
	despues[0] = 0
	despues[1] = 400  
	despues[2] = 500 
	despues[3] = 300
	
	rtotal2= 0;
	
	if (document.formulario1.tarde.value == 2){
		var rtotal1 = antes[getRadioButtonSelectedValue(document.formulario1.cirusecpre)]
	} 
	
	if (document.formulario1.tarde.value == 1){
		var rtotal1 = entre[getRadioButtonSelectedValue(document.formulario1.cirusecpre)]
	}	
	
	if (document.formulario1.tarde.value == 0){
		var rtotal1 = despues[getRadioButtonSelectedValue(document.formulario1.cirusecpre)]
	}
	rtotal =  rtotal1 + rtotal2
	
	document.getElementById("resultadoinscripcion").innerHTML= "<span class='subtitulo'>TOTAL REGISTRATION FEE:&nbsp;&nbsp;</span><span class='precio_total'>" + formatCurrency(rtotal) + "&nbsp;€</span><input type='hidden' name='inscripciontotal' value='"+formatCurrency(rtotal)+"'><input type='hidden' name='inscripcionsolo' value='"+formatCurrency(rtotal2)+"'>"
}

