// JavaScript Document
// Precios de inscripción

 	var p1_priceins = 268; //  antes
	var p2_priceins = 268; //  antes
	

// Precios de hoteles
	var h1_price = 92; //santemar doble
 	var h2_price = 81; //Santemar individual
	
	

	



function redondeo(value)
{
  var str = "" + Math.round(value*100);
  var len = str.length;

  return (str=="0")?"":(str.substring(0,len-2)+"."+str.substring(len-2,len));
}

	
function CalcularPrecio(form)
{
	var sub_hotel = 0;
	var sub_inscripcion = 0;	
	var sub_unanoche = 0;
	var nnoches = 0;
	var niva = 0;
	

// Calcula precio inscripción de congreso ---------------------------------------------------
  	if (form.registration[0].checked){sub_inscripcion += p1_priceins} 	// socios
	  	if (form.registration[1].checked){sub_inscripcion += p2_priceins} 	// socios


	
  	if (sub_inscripcion > 0){niva = ((sub_inscripcion * 7) /100)};
	
// Cálculo de noches de estancia --------------------------------------------------------------
if ((form.hotel[0].checked) || (form.hotel[1].checked) )
  	{
// 	if (form.mes_llegada.value == 2 && form.mes_salida.value == 3){nnoches = ((form.dia_salida.value * 1) + (28 - form.dia_llegada.value))}
//	if (form.mes_llegada.value == 3 && form.mes_salida.value == 3)
//		{
		if(form.dia_salida.value > form.dia_llegada.value){nnoches = form.dia_salida.value - form.dia_llegada.value}
//		}		
	form.n_noches.value = nnoches;
	}

//	Precio de depósito y total del Hotel-------------------------------------------------------
if (form.hotel[0].checked){sub_hotel += h1_price * Math.abs(form.n_habitaciones.value) * Math.abs(form.n_noches.value)}
if (form.hotel[1].checked){sub_hotel += h2_price * Math.abs(form.n_habitaciones.value) * Math.abs(form.n_noches.value)}

//// 	if (form.hotel[1].checked){sub_hotel += h1_price * Math.abs(form.n_habitaciones.value) * Math.abs(form.n_noches.value)}




// SUBTOTAL Precios parciales ---------------------------------------------------------
//	form.IMPORTE_INSCRIPCION.value = redondeo(sub_inscripcion); 
//	form.IVA.value = redondeo(niva);
//	form.precio_inscripcion.value = redondeo(sub_inscripcion + niva); 
//	Esta vez tienen la graciosa idea de no desglosar el IVA para facilitar el trabajo de los demás
	form.precio_inscripcion.value = redondeo(sub_inscripcion); 

	form.precio_hotel.value = redondeo(sub_hotel);    
	
	
//	form.precio_unanoche.value = redondeo(sub_unanoche);

// TOTAL a pagar con tarjeta de crédito ------------------------------------------------ 
	form.total_a_pagar.value = redondeo(Math.abs(form.precio_inscripcion.value) + Math.abs(form.precio_hotel.value));
// 	form.total_a_pagar.value = redondeo(Math.abs(form.precio_inscripcion.value) + Math.abs(form.precio_unanoche.value));

		if ((form.hotel[0].checked)) {form.habitacion.value = "Doble";} 
	    if ((form.hotel[1].checked)) {form.habitacion.value = "Individual";}
	




}

function verificar(form)
{
  CalcularPrecio(form);

	var cnt_ins = 0;
	var cnt_res = 0;
  	var nnoches = 0;


    if (form.registration[0].checked){form.fecha.value = "Antes 15/04/07";} 
    if (form.registration[1].checked){form.fecha.value = "Tras 15/04/07";}
	


		


}