
// Rellena el contenido del combo de vehículos, en función de la oficina seleccionada
function ColocaLugar() {

	// Si se ha elegido una página de Málaga, poner sus vehículos, y
	// los lugares de entrega sólamente de Málaga
	// Si se ha elegido Lanzarote, poner sus vehículos, y de lugar de
	// entrega sólamente Lanzarote
	
	document.formPresupuesto.vhc.options.length=0;
	
	if ((document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "5") ||
		(document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "1") ||
		(document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "3") ||
		(document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "201") ||
		(document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "202") ||
		(document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "205") ||
		(document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "100")
		) {
		// Málaga
		
/*	'A'=>'Ch. Matiz or similar',
	'B'=>'Kia Picanto, Ford Ka or similar',
	'C'=>'S.Ibiza, F.Fiesta, O.Corsa or similar',
	'D'=>'S.Cordoba, T.Corolla or similar',
	'E'=>'F.Focus, S.Leon, R.Megane, K.Cerato or similar',
	'F'=>'F.Mondeo, N.Primera or similar',
	'Z'=>'F.Tourneo Connect, O.Combo or similar',
	'G'=>'F.Focus SW, O.Astra SW or similar',
	'H'=>'S.Altea XL, O.Meriva, C.Picasso or similar',
	'I'=>'7 Seater S.Alhambra, F.Galaxy or similar',
	'I1'=>'7 Seater O.Zafira or similar',
	'K'=>'9 Seater N.Primastar, F.Transit or similar',
	'L'=>'7 Seater AUT. S.Alhambra or similar',
	'L1'=>'AUT. 8 Seater Chevrolet Van Express XL',
	'N'=>'AUT. S.Ibiza, O.Corsa or similar',
	'O'=>'AUT. F.Focus, S.Leon, R.Megane or similar',
	'P'=>'AUT. Mercedes "A" or similar',
	'P1'=>'CONVERTIBLE P.307, R.Megane, O.Astra or similar',
	'R'=>'Audi A4, BMW 320, Audi A3 AUT. or similar',
	'S'=>'Audi A4 Aut, BMW 320 AUT. or similar',
	'T'=>'AUT. Mercedes CLK Cabrio, A6, BMW 5 Series or similar',
	'U'=>'AUT. A8, Q7, BMW X5, VW.Touareg V10, Merc.CLS or similar',
	'W'=>'AUT. BMW 6 Series, P.Cayenne, P.Carrera, Merc.S320 or similar'
*/		// Vehículos
		document.formPresupuesto.vhc.options[0]= new Option("Choose car...", "0", true, false);
		document.formPresupuesto.vhc.options[1]= new Option("Ch. Matiz or similar", "A", false, false);
		document.formPresupuesto.vhc.options[2]= new Option("Kia Picanto, Ford Ka or similar", "B", false, false);
		document.formPresupuesto.vhc.options[3]= new Option("S.Ibiza, F.Fiesta, O.Corsa or similar", "C", false, false);
		document.formPresupuesto.vhc.options[4]= new Option("S.Cordoba, T.Corolla or similar", "D", false, false);
		document.formPresupuesto.vhc.options[5]= new Option("F.Focus, S.Leon, R.Megane, K.Cerato or similar", "E", false, false);
		document.formPresupuesto.vhc.options[6]= new Option("F.Mondeo, N.Primera or similar", "F", false, false);
		document.formPresupuesto.vhc.options[7]= new Option("Volkswagen Golf or similar", "F1", false, false);
		document.formPresupuesto.vhc.options[8]= new Option("Mini Manual or similar", "F2", false, false);
		document.formPresupuesto.vhc.options[9]= new Option("F.Tourneo Connect, O.Combo or similar", "Z", false, false);
		document.formPresupuesto.vhc.options[10]=new Option("F.Focus SW, O.Astra SW or similar", "G", false, false);
		document.formPresupuesto.vhc.options[11]=new Option("S.Altea XL, O.Meriva, C.Picasso or similar", "H", false, false);
		document.formPresupuesto.vhc.options[12]=new Option("7 Seater S.Alhambra, F.Galaxy or similar", "I", false, false);
		document.formPresupuesto.vhc.options[13]=new Option("7 Seater O.Zafira or similar", "I1", false, false);
		document.formPresupuesto.vhc.options[14]=new Option("9 Seater N.Primastar, F.Transit or similar", "K", false, false);
		document.formPresupuesto.vhc.options[15]=new Option("AUT. 7 Seater S.Alhambra or similar", "L", false, false);

		document.formPresupuesto.vhc.options[16]=new Option("AUT. 8 Seater Chevrolet Van Express XL or similar", "L1", false, false);
		
		document.formPresupuesto.vhc.options[17]=new Option("AUT. S.Ibiza, O.Corsa or similar", "N", false, false);
		document.formPresupuesto.vhc.options[18]=new Option("AUT. F.Focus, S.Leon, R.Megane or similar", "O", false, false);
		document.formPresupuesto.vhc.options[19]=new Option("AUT. Mercedes \"A\" or similar", "P", false, false);
		document.formPresupuesto.vhc.options[20]=new Option("CONVERTIBLE P.307, R.Megane, O.Astra or similar", "P1", false, false);
		document.formPresupuesto.vhc.options[21]=new Option("Mini Cabrio Manual or similar", "P2", false, false);
		document.formPresupuesto.vhc.options[22]=new Option("Audi A4, BMW 320, Audi A3 AUT. or similar", "R", false, false);
		document.formPresupuesto.vhc.options[23]=new Option("Mini Cooper Cabrio Automatic or similar", "R1", false, false);
		document.formPresupuesto.vhc.options[24]=new Option("Volvo C70, AUT. Audi A4, BMW 320 or similar", "S",  false, false);
		document.formPresupuesto.vhc.options[25]=new Option("A6, AUT. Merc.CLK Cabrio, BMW 5 Series or similar", "T", false, false);
		document.formPresupuesto.vhc.options[26]=new Option("AUT. Q7, A8, BMW X5, Merc.CLS or similar", "U", false, false);
		document.formPresupuesto.vhc.options[27]=new Option("AUT. P.Cayenne, P.Carrera, Merc.S320 or similar", "W", false, false);

	} else if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "10") {
		// Lanzarote

/*	'A'=>'Ford Ka or similar',
	'B'=>'K. Picanto or similar',
	'C'=>'F.Fiesta, SMART For Four or similar',
	'E'=>'F.Focus, K.Cerato or similar',
	'G'=>'F.Focus Station Wagon or similar',
	'H'=>'O.Meriva or similar',
	'I'=>'S.Alhambra or similar',
	'X'=>'M.Colt Cabrio or similar',
	'P1'=>'P.307 Cabrio or similar',
	'T'=>'Mercedes 320 CLK Cabrio (Aut.) or similar'
*/		// Vehículos
		document.formPresupuesto.vhc.options[0]= new Option("Choose car...", "0", true, false);
		document.formPresupuesto.vhc.options[1]= new Option("Ford Ka or similar", "A", false, false);
		document.formPresupuesto.vhc.options[2]= new Option("K.Picanto or similar", "B", false, false);
		document.formPresupuesto.vhc.options[3]= new Option("F.Fiesta, SMART For Four or similar", "C", false, false);
		document.formPresupuesto.vhc.options[4]= new Option("F.Focus, K.Cerato or similar", "E", false, false);
		document.formPresupuesto.vhc.options[5]= new Option("F.Focus Station Wagon or similar", "G", false, false);
		document.formPresupuesto.vhc.options[6]= new Option("O.Meriva or similar", "H", false, false);
		document.formPresupuesto.vhc.options[7]= new Option("S.Alhambra or similar", "I", false, false);
		document.formPresupuesto.vhc.options[8]= new Option("M.Colt Cabrio or similar", "X", false, false);
		document.formPresupuesto.vhc.options[9]= new Option("P.307 Cabrio or similar", "P1", false, false);
		document.formPresupuesto.vhc.options[10]=new Option("Mercedes 320 CLK Cabrio (Aut.) or similar", "T", false, false);

	} else if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "0") {
		// Selección vacia

		// Vehículos
		document.formPresupuesto.vhc.options[0]=new Option("Choose car...", "0", true, false);

	} else if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "200") {
		// Selección de otros destinos
		// Vehículos
		document.formPresupuesto.vhc.options[0]=new Option("Choose car...", "0", true, false);
		// Lugares
		document.formPresupuesto.lgr_rtr.options.selectedIndex = 0;

		window.location = "reserva.php?other=yes";

	}	

	// Si estamos en "reserva.php", se rellena la oficina de entrega, y se borra el presupuesto
	var path = location.pathname;
	if (path.match("reserva") != null) { // Estamos en "reserva.php"
		DeshabilitaPresupuesto();

		document.formPresupuesto.lgr_ent.options.length=0;

	if ((document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "5") ||
		(document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "1") ||
		(document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "3") ||
		(document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "100")
		) {
			// Málaga
		
			// Lugares
			document.formPresupuesto.lgr_ent.options[0]=new Option("Malaga Airport", "5", false, false);
			document.formPresupuesto.lgr_ent.options[1]=new Option("Marbella", "1", false, false);
			document.formPresupuesto.lgr_ent.options[2]=new Option("Cabopino", "3", false, false);
			document.formPresupuesto.lgr_ent.options[3]=new Option("Málaga Hotel & Home Delivery", "100", false, false);

			if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "5") {
				document.formPresupuesto.lgr_ent.options.selectedIndex = 0;
			} else if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "1") {
				document.formPresupuesto.lgr_ent.options.selectedIndex = 1;
			} else if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "3") {
				document.formPresupuesto.lgr_ent.options.selectedIndex = 2;
			} else if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "100") {
				document.formPresupuesto.lgr_ent.options.selectedIndex = 3;
			}
			
		} else if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "10") {
			// Lanzarote

			// Lugares
			document.formPresupuesto.lgr_ent.options[0]=new Option("Lanzarote", "10", true, false);

		} else if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "0") {
			// Selección vacia

			// Lugares
			document.formPresupuesto.lgr_ent.options[0]=new Option("Choose location...", "0", true, false);
		}	

	} else if (path.match("marriot") != null) { // if "en marriot.php"

		if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "201") {
			document.formPresupuesto.lgr_ent.options.selectedIndex = 0;
			document.getElementById('spanlugarresidencia').style.display = 'none';
		} else if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "202") {
			document.formPresupuesto.lgr_ent.options.selectedIndex = 1;
			document.getElementById('spanlugarresidencia').style.display = 'none';
		} else if (document.formPresupuesto.lgr_rtr.options[document.formPresupuesto.lgr_rtr.selectedIndex].value == "205") {
			document.formPresupuesto.lgr_ent.options.selectedIndex = 2;
			document.getElementById('spanlugarresidencia').style.display = 'block';
		}

	}
}


// Coloca la selección "msn_ent" al valor que tenga "msn_rtr"
function ColocaMes() {

	// Lo primero se oculta el presupuesto ya antiguo
	// pero SOLO si la página es "reserva.htm" 
	var path = location.pathname;
	if (path.match("reserva") != null) {
		DeshabilitaPresupuesto();
	}

	document.formPresupuesto.msn_ent.options.selectedIndex =
	document.formPresupuesto.msn_rtr.options.selectedIndex;
	
}


// Vacia el contenido de "document.getElementById("Presupuesto").innerHTML=tablahtml;"
function DeshabilitaPresupuesto() {

	// Lo primero se oculta el presupuesto ya antiguo
	// pero SOLO si la página no es "reserva.htm" 
	var path = location.pathname;
	if ( (path.match("reserva") != null) || (path.match("marriott") != null) ) {

		
		// Se ponen a 'none' para que no ocupen espacio
		document.getElementById('Reserva').style.display = 'none';
		document.getElementById('Reservaoffline').style.display = 'none';
/*
		str = new String(document.getElementById("Presupuesto").innerHTML);
		str = str.replace("!disabled","disabled");
		document.getElementById("Presupuesto").innerHTML = str;
*/
		document.getElementById("Presupuesto").innerHTML = '<h3>Please press "New quote"</h3>';

		// NUEVO: Se oculta el campo del "supercodigo"
//		document.getElementById('codediv').style.display = 'none';

		// NUEVO: Se oculta el campo del "book and join"
//		document.getElementById('bookandjoin').style.display = 'none';

		// NUEVO: Se vacia el cuadro de los upgrades
		document.getElementById("Upgrade").innerHTML = '';
		
	}

}


// Habilita el botón "booknow", en caso de haberse aceptado las condiciones
function ClickCondiciones() {

	if (document.getElementById('accept').checked) {
		document.getElementById('booknowbutton').disabled = false;
	} else {
		document.getElementById('booknowbutton').disabled = true;
	}
}


function clearForm() {
	document.formPresupuesto.lgr_rtr.options.selectedIndex = 0;
//	document.formPresupuesto.vhc.options.selectedIndex = 0;
	document.formPresupuesto.vhc.options.length=0;
	document.formPresupuesto.vhc.options[0]=new Option("Choose car...", "0", true, false);
	return true;
}

// Añade un comentario como owner de Marriott
function ClickMarriotOwner() {

	if (document.getElementById('marriot_owner').checked) {
		document.getElementById('comentariosreserva').value += "I am a Marriott Vacation Club owner. ";
	}

}



