function capturaTecla(){
         var tecla = event.keyCode; 
         if ((tecla == 13)) {
		     buscar(); 
         } 
         return tecla;
}
function buscar(){
	if (document.getElementById('palabra').value != ''){
		document.location = 'busqueda.asp?txt=' + document.getElementById('palabra').value;
	}
}

function AumentarTamanyo(idElemento) {
	var elemento;
	if (document.all){
		elemento = document.all[idElemento];
	}else{
		elemento = document.getElementById(idElemento);
	}
	if (!elemento.style.fontSize) {
		//primera vez que se intenta aumentar el tamaño del texto
		elemento.style.fontSize =  '120%';
	} else {
		var fsize =  elemento.style.fontSize;
		if (fsize.indexOf(" & chr(34) & "%" & chr(34) & ")) {
			// el valor está indicado en porcentaje:
			fsize =  fsize.substring(0,fsize.indexOf("%"))
			fsize =  Number(fsize)+factor_reduccion;
				if(fsize >=  max_size){
					alert("No se puede aumentar más.")
				}else{
					elemento.style.fontSize =  (fsize+'%');
				}
		}
	}
}

function ReducirTamanyo(idElemento) {
	var elemento;
	if (document.all){
		elemento = document.all[idElemento];
	}else{
		elemento = document.getElementById(idElemento);
	}
	if (!elemento.style.fontSize) {
		//primera vez que se intenta reducir el tamaño del texto
		elemento.style.fontSize =  '80%';
	} else {
		var fsize =  elemento.style.fontSize;
		if (fsize.indexOf("%")) {
			// el valor está indicado en porcentaje:
			fsize =  fsize.substring(0,fsize.indexOf("%"))
			fsize =  Number(fsize)-factor_reduccion;
			if(fsize <=  min_size){
				alert("No se puede reducir más.")
			}else{
				elemento.style.fontSize =  (fsize+'%');
			}
		}
	}
}

function RecuperarTamanyo(idElemento) {
	var elemento;
	if (document.all){
		elemento = document.all[idElemento];
	}else{
		elemento = document.getElementById(idElemento);
	}
	elemento.style.fontSize = '100%';
}

var max_size =  250;
var min_size =  50;
var factor_reduccion = 20;
var tamagnoLetras =  100;


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function PopupAtOL(){
         if (document.all&&window.print) //if ie5
	         eval('window.showModelessDialog("../atenciononline.html", "", "help:0;resizable:0;dialogWidth:555px;dialogHeight:420px;status:0;scroll:no")')
		 else
		     eval('window.open("../atenciononline.html", "", "width=555px,height=400px,resizable=0,scrollbars=0,status=0")')
}


function HabilitarDesabilitar(){
	if ($('#tipoviaje').val() == 'idayvuelta'){
		$('#fechasalida').val('');
		$('#horasalida').val('');		
		//$('#fechasalida').attr('disabled', false);
		//$('#horasalida').attr('disabled', false);
		$('#campos_salida').show('slow');
	}
	else{
		$('#fechasalida').val('');
		$('#horasalida').val('');		
		//$('#fechasalida').attr('disabled', true);
		//$('#horasalida').attr('disabled', true);
		$('#campos_salida').hide('slow');
	}
	
	$('#Precio').html('?');
}

function mayor(fecha, fecha2){ 
   if (fecha2 != ''){
    var xMes=fecha.substring(3, 5);
    var xDia=fecha.substring(0, 2);
    var xAnio=fecha.substring(6,10); 
    var yMes=fecha2.substring(3, 5);
    var yDia=fecha2.substring(0, 2);
    var yAnio=fecha2.substring(6,10); 
    if (xAnio > yAnio)
       return(true)
    else 
       if (xAnio == yAnio){ 
	      if (xMes > yMes)
             return(true)
          else{ 
		     if (xMes == yMes){
                if (xDia >= yDia)
                   return(true);
                else
                   return(false);
	         }
             else
                return(false); 
          }
       } 
       else
          return(false);
   }
   else{return(false);}
} 

function faltandatos(){
	var Resultado;
	Resultado = ($('#numadultos').val() + $('#numninios').val() + $('#numbebes').val() == 0);
	Resultado = Resultado || ($('#localizacion_origen').val() == '');
	Resultado = Resultado || ($('#localizacion_destino').val() == '');
	Resultado = Resultado || ($('#fechallegada').val() == '');
	Resultado = Resultado || ($('#hora_llegada').val() == '');
	
	if ($('#tipoviaje').val() == 'idayvuelta'){
		Resultado = Resultado || ($('#fechasalida').val() == '');
  	    Resultado = Resultado || ($('#hora_salida').val() == '');
		
		var fecha_invalida_1 = '24/12/2006';
		var fecha_invalida_2 = '25/12/2006';
		var fecha_invalida_3 = '31/12/2006';
		var fecha_invalida_4 = '01/01/2007';
		if ((mayor($('#fechallegada').val(), $('#fechasalida').val())) ||
			($('#fechallegada').val() == fecha_invalida_1) ||
			($('#fechallegada').val() == fecha_invalida_2) ||
			($('#fechallegada').val() == fecha_invalida_3) ||
			($('#fechallegada').val() == fecha_invalida_4) ||
			($('#fechasalida').val() == fecha_invalida_1) ||
			($('#fechasalida').val() == fecha_invalida_2) ||
			($('#fechasalida').val() == fecha_invalida_3) ||
			($('#fechasalida').val() == fecha_invalida_4)){			
			Resultado = 'Invalid dates. Only via telephone.';			
			alert(Resultado);
		}	
		else{
			if (($('#fechasalida').val() == '') || ($('#hora_salida').val() == '')){
				alert('Data missing...');
			}
		}	
	}

	if ($('#localizacion_origen').val().charAt(0) == $('#localizacion_destino').val().charAt(0)){
		if ($('#localizacion_origen').val().charAt(0) == 'P'){Resultado = 'You can not select 2 airports';}
		else{Resultado = 'You must to select 1 airport at least';}
	}
	
    return Resultado
}

function faltandatos_paraelprecio(){
	var Resultado;
	Resultado = ($('#numadultos').val() + $('#numninios').val() + $('#numbebes').val() == 0);
	Resultado = Resultado || ($('#localizacion_origen').val() == '');
	Resultado = Resultado || ($('#localizacion_destino').val() == '');
	
	if ($('#localizacion_origen').val().charAt(0) == $('#localizacion_destino').val().charAt(0)){
		if ($('#localizacion_origen').val().charAt(0) == 'P'){Resultado = 'You can not select 2 airports';}
		else{Resultado = 'You must to select 1 airport at least';}
	}
	
    return Resultado
}

function mostrar_precio(){
	var Resultado = faltandatos_paraelprecio();
	if (!Resultado){
		$('#Precio').html('...');
        $.post("http://www.elmarservices.es/html_ing/obtener_precio.asp", {
			   		tipoviaje:$('#tipoviaje').val(), 
					localizacion_origen:$('#localizacion_origen').val(), 
					localizacion_destino:$('#localizacion_destino').val(), 
					adultos:$('#numadultos').val(), 
					ninios:$('#numninios').val(), 
					bebes:$('#numbebes').val()
			   }, 
		       function(data){
				        $('#Precio').html(data);
			   })
	}
	else{
		$('#Precio').html('?'); 
		if (Resultado == true){
			alert('Data missing...');			
		}
		else{
			alert(Resultado);
		}
	}
}



function ActualizaCombos(i){
	$('#Precio').html('?');
	$('#localizacion_origen').empty();
	$('#localizacion_destino').empty();
	
	var contenido_combos;
	
	if (i==1){	
		document.getElementById('localizacion_origen').options[0]= new Option('','');
		document.getElementById('localizacion_origen').options[1]= new Option('Airport Reina Sofia','P1');	
		document.getElementById('localizacion_origen').options[2]= new Option('Airport Los Rodeos','P2');	
		document.getElementById('localizacion_origen').options[3]= new Option('Port Los Cristianos','P3');			
		document.getElementById('localizacion_origen').options[4]= new Option('Port Santa Cruz','P4');					
		document.getElementById('localizacion_origen').options[5]= new Option('','');
		document.getElementById('localizacion_origen').options[6]= new Option('--------------------------','');
		document.getElementById('localizacion_origen').options[7]= new Option('','');
		document.getElementById('localizacion_origen').options[8]= new Option('Adeje (Callao Salvaje)','L3');
		document.getElementById('localizacion_origen').options[9]= new Option('Adeje (Costa Adeje)','L1');
		document.getElementById('localizacion_origen').options[10]= new Option('Adeje (Playa Paraiso)','L2');
		document.getElementById('localizacion_origen').options[11]= new Option('Arona (Los Cristianos)','L4');
		document.getElementById('localizacion_origen').options[12]= new Option('Arona (Playa Las Américas)','L5');
		document.getElementById('localizacion_origen').options[13]= new Option('Candelaria','L6');
		document.getElementById('localizacion_origen').options[14]= new Option('El Rosario','L7');
		document.getElementById('localizacion_origen').options[15]= new Option('El Sauzal','L8');
		document.getElementById('localizacion_origen').options[16]= new Option('Granadilla de Abona (El Médano)','L9');
		document.getElementById('localizacion_origen').options[17]= new Option('Guía de Isora (Abama)','L26');
		document.getElementById('localizacion_origen').options[18]= new Option('Guía de Isora (Alcalá)','L10');
		document.getElementById('localizacion_origen').options[19]= new Option('Guía de Isora (Piedra Hincada)','L24');
		document.getElementById('localizacion_origen').options[20]= new Option('Guía de Isora (Playa de San Juan)','L23');
		document.getElementById('localizacion_origen').options[21]= new Option('Guía de Isora (Varadero)','L25');
		document.getElementById('localizacion_origen').options[22]= new Option('La Laguna','L11');
		document.getElementById('localizacion_origen').options[23]= new Option('La Matanza de Acentejo','L12');
		document.getElementById('localizacion_origen').options[24]= new Option('La Orotava','L13');
		document.getElementById('localizacion_origen').options[25]= new Option('La Victoria de Acentejo','L14');
		document.getElementById('localizacion_origen').options[26]= new Option('Los Gigantes - Santiago del Teide','L20');
		document.getElementById('localizacion_origen').options[27]= new Option('Los Realejos','L15');
		document.getElementById('localizacion_origen').options[28]= new Option('Puerto de La Cruz','L16');
		document.getElementById('localizacion_origen').options[29]= new Option('San Miguel (Golf del Sur)','L17');
		document.getElementById('localizacion_origen').options[30]= new Option('Santa Cruz de Tenerife','L18');
		document.getElementById('localizacion_origen').options[31]= new Option('Santa Úrsula','L19');
		
		document.getElementById('localizacion_origen').options[32]= new Option('Santiago del Teide (Pl. La Arena)','L28');
		document.getElementById('localizacion_origen').options[33]= new Option('Santiago del Teide (Pto. Santiago)','L27');
		document.getElementById('localizacion_origen').options[34]= new Option('Santiago del Teide (Urb. San Francisco)','L29');
		document.getElementById('localizacion_origen').options[35]= new Option('Tacoronte','L21');
		document.getElementById('localizacion_origen').options[36]= new Option('Tegueste','L22');
		
		document.getElementById('localizacion_destino').options[0]= new Option('','');
		document.getElementById('localizacion_destino').options[1]= new Option('Airport Reina Sofia','P1');	
		document.getElementById('localizacion_destino').options[2]= new Option('Airport Los Rodeos','P2');	
		document.getElementById('localizacion_destino').options[3]= new Option('Port Los Cristianos','P3');			
		document.getElementById('localizacion_destino').options[4]= new Option('Port Santa Cruz','P4');					
		document.getElementById('localizacion_destino').options[5]= new Option('','');
		document.getElementById('localizacion_destino').options[6]= new Option('--------------------------','');
		document.getElementById('localizacion_destino').options[7]= new Option('','');
		document.getElementById('localizacion_destino').options[8]= new Option('Adeje (Callao Salvaje)','L3');
		document.getElementById('localizacion_destino').options[9]= new Option('Adeje (Costa Adeje)','L1');
		document.getElementById('localizacion_destino').options[10]= new Option('Adeje (Playa Paraiso)','L2');
		document.getElementById('localizacion_destino').options[11]= new Option('Arona (Los Cristianos)','L4');
		document.getElementById('localizacion_destino').options[12]= new Option('Arona (Playa Las Américas)','L5');
		document.getElementById('localizacion_destino').options[13]= new Option('Candelaria','L6');
		document.getElementById('localizacion_destino').options[14]= new Option('El Rosario','L7');
		document.getElementById('localizacion_destino').options[15]= new Option('El Sauzal','L8');
		document.getElementById('localizacion_destino').options[16]= new Option('Granadilla de Abona (El Médano)','L9');
		document.getElementById('localizacion_destino').options[17]= new Option('Guía de Isora (Abama)','L26');
		document.getElementById('localizacion_destino').options[18]= new Option('Guía de Isora (Alcal&aacute;)','L10');
		document.getElementById('localizacion_destino').options[19]= new Option('Guía de Isora (Piedra Hincada)','L24');
		document.getElementById('localizacion_destino').options[20]= new Option('Guía de Isora (Playa de San Juan)','L23');
		document.getElementById('localizacion_destino').options[21]= new Option('Guía de Isora (Varadero)','L25');
		document.getElementById('localizacion_destino').options[22]= new Option('La Laguna','L11');
		document.getElementById('localizacion_destino').options[23]= new Option('La Matanza de Acentejo','L12');
		document.getElementById('localizacion_destino').options[24]= new Option('La Orotava','L13');
		document.getElementById('localizacion_destino').options[25]= new Option('La Victoria de Acentejo','L14');
		document.getElementById('localizacion_destino').options[26]= new Option('Los Gigantes - Santiago del Teide','L20');
		document.getElementById('localizacion_destino').options[27]= new Option('Los Realejos','L15');
		document.getElementById('localizacion_destino').options[28]= new Option('Puerto de La Cruz','L16');
		document.getElementById('localizacion_destino').options[29]= new Option('San Miguel (Golf del Sur)','L17');
		document.getElementById('localizacion_destino').options[30]= new Option('Santa Cruz de Tenerife','L18');
		document.getElementById('localizacion_destino').options[31]= new Option('Santa Úrsula','L19');
		document.getElementById('localizacion_destino').options[32]= new Option('Santiago del Teide (Pl. La Arena)','L28');
		document.getElementById('localizacion_destino').options[33]= new Option('Santiago del Teide (Pto. Santiago)','L27');
		document.getElementById('localizacion_destino').options[34]= new Option('Santiago del Teide (Urb. San Francisco)','L29');
		document.getElementById('localizacion_destino').options[35]= new Option('Tacoronte','L21');
		document.getElementById('localizacion_destino').options[36]= new Option('Tegueste','L22');
	}
	if (i==2){
		document.getElementById('localizacion_origen').options[0]= new Option('','');
		document.getElementById('localizacion_origen').options[1]= new Option('Airport of Gran Canaria','P7');	
		document.getElementById('localizacion_origen').options[2]= new Option('','');
		document.getElementById('localizacion_origen').options[3]= new Option('--------------------------','');
		document.getElementById('localizacion_origen').options[4]= new Option('','');
		document.getElementById('localizacion_origen').options[5]= new Option('Agaete','L43');
		document.getElementById('localizacion_origen').options[6]= new Option('Agüimes','L44');
		document.getElementById('localizacion_origen').options[7]= new Option('Artenara','L45');
		document.getElementById('localizacion_origen').options[8]= new Option('Arucas','L46');
		document.getElementById('localizacion_origen').options[9]= new Option('Firgas','L47');
		document.getElementById('localizacion_origen').options[10]= new Option('Gáldar','L48');
		document.getElementById('localizacion_origen').options[11]= new Option('Ingenio','L49');
		document.getElementById('localizacion_origen').options[12]= new Option('Las Palmas De Gran Canaria','L50');
		document.getElementById('localizacion_origen').options[13]= new Option('Mogán','L51');
		document.getElementById('localizacion_origen').options[14]= new Option('Moya','L52');
		document.getElementById('localizacion_origen').options[15]= new Option('San Bartolomé De Tirajana','L53');
		document.getElementById('localizacion_origen').options[16]= new Option('San Nicolás De Tolentino','L54');
		document.getElementById('localizacion_origen').options[17]= new Option('Santa Brígida','L55');
		document.getElementById('localizacion_origen').options[18]= new Option('Santa Lucía','L56');
		document.getElementById('localizacion_origen').options[19]= new Option('Santa María De Guía De G.C.','L57');
		document.getElementById('localizacion_origen').options[20]= new Option('Tejeda','L58');
		document.getElementById('localizacion_origen').options[21]= new Option('Telde','L59');
		document.getElementById('localizacion_origen').options[22]= new Option('Teror','L60');
		document.getElementById('localizacion_origen').options[23]= new Option('Valleseco','L61');
		document.getElementById('localizacion_origen').options[24]= new Option('Valsequillo De Gran Canaria','L62');
		document.getElementById('localizacion_origen').options[25]= new Option('Vega De San Mateo','L63');

        document.getElementById('localizacion_destino').options[0]= new Option('','');
		document.getElementById('localizacion_destino').options[1]= new Option('Airport of Gran Canaria','P7');	
		document.getElementById('localizacion_destino').options[2]= new Option('','');
		document.getElementById('localizacion_destino').options[3]= new Option('--------------------------','');
		document.getElementById('localizacion_destino').options[4]= new Option('','');
		document.getElementById('localizacion_destino').options[5]= new Option('Agaete','L43');
		document.getElementById('localizacion_destino').options[6]= new Option('Agüimes','L44');
		document.getElementById('localizacion_destino').options[7]= new Option('Artenara','L45');
		document.getElementById('localizacion_destino').options[8]= new Option('Arucas','L46');
		document.getElementById('localizacion_destino').options[9]= new Option('Firgas','L47');
		document.getElementById('localizacion_destino').options[10]= new Option('Gáldar','L48');
		document.getElementById('localizacion_destino').options[11]= new Option('Ingenio','L49');
		document.getElementById('localizacion_destino').options[12]= new Option('Las Palmas De Gran Canaria','L50');
		document.getElementById('localizacion_destino').options[13]= new Option('Mogán','L51');
		document.getElementById('localizacion_destino').options[14]= new Option('Moya','L52');
		document.getElementById('localizacion_destino').options[15]= new Option('San Bartolomé De Tirajana','L53');
		document.getElementById('localizacion_destino').options[16]= new Option('San Nicolás De Tolentino','L54');
		document.getElementById('localizacion_destino').options[17]= new Option('Santa Brígida','L55');
		document.getElementById('localizacion_destino').options[18]= new Option('Santa Lucía','L56');
		document.getElementById('localizacion_destino').options[19]= new Option('Santa María De Guía De G.C.','L57');
		document.getElementById('localizacion_destino').options[20]= new Option('Tejeda','L58');
		document.getElementById('localizacion_destino').options[21]= new Option('Telde','L59');
		document.getElementById('localizacion_destino').options[22]= new Option('Teror','L60');
		document.getElementById('localizacion_destino').options[23]= new Option('Valleseco','L61');
		document.getElementById('localizacion_destino').options[24]= new Option('Valsequillo De Gran Canaria','L62');
		document.getElementById('localizacion_destino').options[25]= new Option('Vega De San Mateo','L63');
	}
	if (i==3){
		document.getElementById('localizacion_origen').options[0]= new Option('','');
		document.getElementById('localizacion_origen').options[1]= new Option('Airport of Fuerteventura','P5');	
		document.getElementById('localizacion_origen').options[2]= new Option('','');
		document.getElementById('localizacion_origen').options[3]= new Option('--------------------------','');
		document.getElementById('localizacion_origen').options[4]= new Option('','');
		document.getElementById('localizacion_origen').options[5]= new Option('Antigua','L30');
		document.getElementById('localizacion_origen').options[6]= new Option('Betancuria','L31');
		document.getElementById('localizacion_origen').options[7]= new Option('La Oliva','L32');
		document.getElementById('localizacion_origen').options[8]= new Option('Pájara','L33');
		document.getElementById('localizacion_origen').options[9]= new Option('Puerto Del Rosario','L34');
		document.getElementById('localizacion_origen').options[10]= new Option('Tuineje','L35');
		
		document.getElementById('localizacion_destino').options[0]= new Option('','');
		document.getElementById('localizacion_destino').options[1]= new Option('Airport of Fuerteventura','P5');	
		document.getElementById('localizacion_destino').options[2]= new Option('','');
		document.getElementById('localizacion_destino').options[3]= new Option('--------------------------','');
		document.getElementById('localizacion_destino').options[4]= new Option('','');
		document.getElementById('localizacion_destino').options[5]= new Option('Antigua','L30');
		document.getElementById('localizacion_destino').options[6]= new Option('Betancuria','L31');
		document.getElementById('localizacion_destino').options[7]= new Option('La Oliva','L32');
		document.getElementById('localizacion_destino').options[8]= new Option('Pájara','L33');
		document.getElementById('localizacion_destino').options[9]= new Option('Puerto Del Rosario','L34');
		document.getElementById('localizacion_destino').options[10]= new Option('Tuineje','L35');
	}
	if (i==4){
		document.getElementById('localizacion_origen').options[0]= new Option('','');
		document.getElementById('localizacion_origen').options[1]= new Option('Airport of Lanzarote','P6');	
		document.getElementById('localizacion_origen').options[2]= new Option('','');
		document.getElementById('localizacion_origen').options[3]= new Option('--------------------------','');
		document.getElementById('localizacion_origen').options[4]= new Option('','');
		document.getElementById('localizacion_origen').options[5]= new Option('Arrecife','L36');
		document.getElementById('localizacion_origen').options[6]= new Option('Haría','L37');
		document.getElementById('localizacion_origen').options[7]= new Option('San Bartolom&Eacute;','L38');
		document.getElementById('localizacion_origen').options[8]= new Option('Teguise','L39');
		document.getElementById('localizacion_origen').options[9]= new Option('Tías','L40');
		document.getElementById('localizacion_origen').options[10]= new Option('Tinajo','L41');
		document.getElementById('localizacion_origen').options[10]= new Option('Yaiza','L42');
		
		document.getElementById('localizacion_destino').options[0]= new Option('','');
		document.getElementById('localizacion_destino').options[1]= new Option('Airport of Lanzarote','P6');	
		document.getElementById('localizacion_destino').options[2]= new Option('','');
		document.getElementById('localizacion_destino').options[3]= new Option('--------------------------','');
		document.getElementById('localizacion_destino').options[4]= new Option('','');
		document.getElementById('localizacion_destino').options[5]= new Option('Arrecife','L36');
		document.getElementById('localizacion_destino').options[6]= new Option('Haría','L37');
		document.getElementById('localizacion_destino').options[7]= new Option('San Bartolom&Eacute;','L38');
		document.getElementById('localizacion_destino').options[8]= new Option('Teguise','L39');
		document.getElementById('localizacion_destino').options[9]= new Option('Tías','L40');
		document.getElementById('localizacion_destino').options[10]= new Option('Tinajo','L41');
		document.getElementById('localizacion_destino').options[10]= new Option('Yaiza','L42');
	}
}