

		window.addEvent('domready', function(){
		
				

/*
 ------------------ start ajax request buscador -------------------------
*/

$('slidein').addEvent('click', function(e) {
	e = new Event(e).stop();
 
	var url = "html/searchform.php";
 
	new Ajax(url, {
		method: 'get',
		update: $('filter_box'),
		evalScripts: true
	}).request();
});

$('toggle_in').addEvent('click', function(e) {
	e = new Event(e).stop();
 
	var url = "html/searchform.php";
 
	new Ajax(url, {
		method: 'get',
		update: $('filter_box'),
		evalScripts: true
	}).request();
});

$('buscar_coche').addEvent('click', function(e) {
	e = new Event(e).stop();
 
	var url = "html/searchform.php";
 
	new Ajax(url, {
		method: 'get',
		update: $('filter_box'),
		evalScripts: true
	}).request();
});


		

/*
 ------------------ toggle search panel -------------------------
*/
			
			var mySlide = new Fx.Slide('filter_box');
			mySlide.hide();
		   $('slidein').addEvent('click', function(e){
	         e = new Event(e);
	         mySlide.toggle();
	         e.stop();
           });
           
           $('toggle_in').addEvent('click', function(e){
	         e = new Event(e);
	         mySlide.toggle();
	         e.stop();
           });
		   
		    $('buscar_coche').addEvent('click', function(e){
	         e = new Event(e);
	         mySlide.slideIn();
	         e.stop();
           });
		   

				
		 					
		
});
		



/*
 ------------------ rollover functions -------------------------
*/

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_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 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];}
}




/*
 ------------------ search form (switch, validation) -------------------------
*/
	 
		 function cambio_operacion(theForm) {
	if(theForm.operacion[theForm.operacion.selectedIndex].value == 'alquiler') {
		//Coloco los valores de compra en ambos combos
		theForm.desde.length = 1;
		theForm.desde.options[0] = new Option('50 €', '50');
		theForm.desde.options[1] = new Option('80 €', '80');
		theForm.desde.options[2] = new Option('150 €', '150');
		theForm.desde.options[3] = new Option('200 €', '200');
		theForm.desde.options[4] = new Option('330 €', '330');
		theForm.desde.options[5] = new Option('450 €', '450');
		theForm.desde.options[6] = new Option('600 €', '600');
		theForm.desde.options[7] = new Option('750 €', '750');
		theForm.desde.options[8] = new Option('900 €', '900');
		theForm.desde.options[9] = new Option('1.200 €', '1200');
		theForm.desde.options[10] = new Option('2.400 €', '2400');

		theForm.hasta.length = 1;	
		theForm.hasta.options[0] = new Option('80 €', '80');
		theForm.hasta.options[1] = new Option('150 €', '150');
		theForm.hasta.options[2] = new Option('200 €', '200');
		theForm.hasta.options[3] = new Option('330 €', '330');
		theForm.hasta.options[4] = new Option('450 €', '450');
		theForm.hasta.options[5] = new Option('600 €', '600');
		theForm.hasta.options[6] = new Option('750 €', '750');
		theForm.hasta.options[7] = new Option('900 €', '900');
		theForm.hasta.options[8] = new Option('1.200 €', '1200');
		theForm.hasta.options[9] = new Option('2.400 €', '2400');
		theForm.hasta.options[10] = new Option('2.400 € ó +', 'null');
	} else {
		//Coloco los valores de alquiler en ambos combos
		theForm.desde.length = 1;	
		theForm.desde.options[0] = new Option('0 €', '1');
		theForm.desde.options[1] = new Option('12.000 €', '12000');
		theForm.desde.options[2] = new Option('18.000 €', '18000');
		theForm.desde.options[3] = new Option('30.000 €', '30000');
		theForm.desde.options[4] = new Option('60.000 €', '60000');
		theForm.desde.options[5] = new Option('90.000 €', '90000');
		theForm.desde.options[6] = new Option('120.000 €', '120000');
		theForm.desde.options[7] = new Option('150.000 €', '150000');
		theForm.desde.options[8] = new Option('180.000 €', '180000');
		theForm.desde.options[9] = new Option('210.000 €', '210000');
		theForm.desde.options[10] = new Option('240.000 €', '240000');
		theForm.desde.options[11] = new Option('270.000 €', '270000');
		theForm.desde.options[12] = new Option('300.000 €', '300000');
		theForm.desde.options[13] = new Option('330.000 €', '330000');
		theForm.desde.options[14] = new Option('360.000 €', '360000');
		theForm.desde.options[15] = new Option('450.000 €', '450000');
		theForm.desde.options[16] = new Option('540.000 €', '540000');


		theForm.hasta.length = 1;
		theForm.hasta.options[0] = new Option('12.000 €', '12000');
		theForm.hasta.options[1] = new Option('18.000 €', '18000');
		theForm.hasta.options[2] = new Option('30.000 €', '30000');
		theForm.hasta.options[3] = new Option('60.000 €', '60000');
		theForm.hasta.options[4] = new Option('90.000 €', '90000');
		theForm.hasta.options[5] = new Option('120.000 €', '120000');
		theForm.hasta.options[6] = new Option('150.000 €', '150000');
		theForm.hasta.options[7] = new Option('180.000 €', '180000');
		theForm.hasta.options[8] = new Option('210.000 €', '210000');
		theForm.hasta.options[9] = new Option('240.000 €', '240000');
		theForm.hasta.options[10] = new Option('270.000 €', '270000');
		theForm.hasta.options[11] = new Option('300.000 €', '300000');
		theForm.hasta.options[12] = new Option('330.000 €', '330000');
		theForm.hasta.options[13] = new Option('360.000 €', '360000');
		theForm.hasta.options[14] = new Option('450.000 €', '450000');
		theForm.hasta.options[15] = new Option('540.000 €', '540000');
		theForm.hasta.options[16] = new Option('660.000 €', '660000');
	}
}

function Validar_Buscador(theForm){
	
	
	if(theForm.hasta[theForm.hasta.selectedIndex].value != "null") { 
		if(Number(theForm.hasta[theForm.hasta.selectedIndex].value) <= Number(theForm.desde[theForm.desde.selectedIndex].value)) {
			alert("Debe seleccionar un precio máximo mayor al mínimo!");
			theForm.hasta.focus();
			return (false);
		} 
	} 
	
return (true);
}

/*
 ------------------ search form (switch isla) -------------------------
*/
	 
		 function cambio_isla(theForm) {
	if(theForm.isla[theForm.isla.selectedIndex].value == 'fuerteventura') {
		//Coloco los valores de fuerteventura en ambos combos
		theForm.region.length = 1;
		theForm.region.options[0] = new Option('todo/ all/ alle', 'igual');
		theForm.region.options[1] = new Option('Corralejo', 'Corralejo');
		theForm.region.options[2] = new Option('Puerto del Rosario', 'Puerto del Rosario');
		theForm.region.options[3] = new Option('Nuevo Horizonte', 'Nuevo Horizonte');
	} else {
		//Coloco los valores de tenerife en ambos combos
        theForm.region.length = 1;
		theForm.region.options[0] = new Option('todo/ all/ alle', 'igual');
		theForm.region.options[1] = new Option('Adeje', 'Adeje');
		theForm.region.options[2] = new Option('Arona', 'Arona');
		theForm.region.options[3] = new Option('Granadilla', 'Granadilla');
		theForm.region.options[4] = new Option('Guia de Isora', 'Guia de Isora');
		theForm.region.options[5] = new Option('San Miguel', 'San Miguel');
	}
}