var $imagenes;
var $step;
function buscar()
{
	var ubicacion = document.getElementById('estados').value;
	var operacion = document.getElementById('propiedades').value;
	var precio    = document.getElementById('preciomax').value;
	
	if(ubicacion == "")
	{
		alert("Elija una ubicación.");
		return false;
	} else if(operacion == "")
	{
		alert("Elija una operación");
		return false;
	/*} else if(precio == "")
	{
		alert("Elija un rango de precio.");
		return false;*/
	} else {
	
	ubicacion = document.getElementById('ocultodato1').value;
	operacion = document.getElementById('ocultodato2').value;
	location.href = '/'+ubicacion+'/'+operacion+'/hasta_'+precio+'_pesos';
	}
}

function buscarClave()
{
	var clave = document.getElementById('clavewebs');
	if(clave.value != "")
	{
		location.href = 'propiedades.php?cw=' + clave.value;
	} else {
		
		alert("Debe introducir una clave web primero.");
		return false;
	}
}



function preCarga() 
{
	if (!document.images) return;
	var ar = new Array();
	var argumentos = preCarga.arguments;
	for (var i = 0; i < argumentos.length; i++) 
	{
		ar[i] = new Image();
		ar[i].src = argumentos[i];
	}
}


//window.onload=" preCarga('images/menu_con_01.gif', 'images/menu_sin_01.gif', 'images/menu_con_02.gif','images/menu_sin_02.gif','images/menu_con_02.gif','images/menu_sin_03.gif','images/menu_con_03.gif','images/menu_con_04.gif','images/menu_sin_04.gif','images/menu_con_05.gif','images/menu_sin_05.gif' )" ;

function rollOver(name,imagen)
{
	document.images[name].src = imagen;  
}
function chgseleccion(tbox,val)
{
	if(val != 0)
	{
	
		tbox.className = 'selFormBuscar';
		document.getElementById(val).className = 'selFormBuscar';
		document.getElementById(val).disabled = false;
	
	} else if (val == "cotizacion")
	{
	
		tbox.className = 'selFormBuscar';
		//setTimeout("document.getElementById(val).className = 'selectcot'",1000);
	
	} else {
		
			tbox.className = 'selFormBuscar';
			
	
	}
}
function imprimir(id)
{
	ancho=911; alto=600;
	var _W=window.open('/verimprimir.php?id='+id,'imprimir',"scrollbars=yes,width="+ancho+",height="+alto); 
	_W.focus(); 
    iz=(screen.width-ancho) / 2;
    de=(screen.height-alto) / 2;
    _W.moveTo(iz,de);	
}
function verFoto(p,i)
{
	ancho=500; alto=500;
	var _W=window.open('verfoto.php?p='+p+'&i='+i,'verfoto',"scrollbars=yes,width="+ancho+",height="+alto); 
	_W.focus(); 
  /*  iz=(screen.width-ancho) / 2;
    de=(screen.height-alto) / 2;
    _W.moveTo(iz,de);	*/
}
function cchg(a)
{
	a.className = 'selFormBuscar';
}
function seleccion(texto)
{
	//alert(texto);

		texto.className = 'selFormBuscar';
	
}
function seleccion2(b)
{
	b.className = "selFormBuscar";
}
function recomendar(url){
  ancho=347; alto=400;
 var _W=window.open('/recomendar.php?url='+url,'recomendar',"scrollbars=yes,width="+ancho+",height="+alto);
	   _W.focus(); 
    iz=(screen.width-ancho) / 2;
    de=(screen.height-alto) / 2;
    _W.moveTo(iz,de);	
}
function parseUrl(url)
{
	var cadena = url.length;
	var cadena1 = url.substr(url.indexOf('images/'),cadena);
	return cadena1;
}
function showlist()
{
	var lista = document.getElementById('lista_fav');
	var imagen = parseUrl(document.getElementById('seelist').src);
	if(imagen == "images/up.gif")
	{
		lista.style.display = 'block';
		document.getElementById('seelist').src = "images/down.gif";
	} else {
		lista.style.display = 'none';
		document.getElementById('seelist').src = "images/up.gif";
	}
	
}
function AgregarFavoritas(id,banio,cuartos,ubicacion,precio,foto,url)
{
	//alert(id +" " + precio + " " + banio + " "+cuartos+ " " + ubicacion);
	document.getElementById('titulo_fav').style.display = "block";
	document.getElementById('lista_fav').style.display = "block";
	xajax_addFavoritos(id,precio,banio,cuartos,ubicacion,foto,url);
}
	
	
function verpagina(vr,variables)
{
	location.href = 'propiedades.php?'+variables+'&ver='+vr.value;
}
function selectchck(chck)
{
	
	var checar;


	if(chck.checked == true)
	{
			checar = true;
			
	}else if(chck.checked == false)
	{
		checar = false;
	}	
	
	j = 0;
	for(i = 0; i < document.forms[0].elements.length; i++)
	{
		j++;
		if(j != 6)
		{
			document.comparacion.elements[i].checked = checar;
		}
	}
	//chck.checked = cbx;
		
}

function chck5(obj)
{
var j = 0;
	for(i = 0; i < document.forms[0].elements.length; i++)
	{
			//alert(j);
		if(document.forms[0].elements[i].checked == true)
		{
			j++;
		
		}
	}
	if(j > 4)
	{
		obj.checked = false;
	}
}


/******************IMG SLIDE BY zir3******************/
function imgsSlide(btn){
	var path;
    if ($imagenes.length==0)
		return false;
    else{
        var $img = document.getElementById('slide');
		var $numimgs = document.getElementById('desdehasta');
        var $dir = "/imagenes/";
		var $ref = document.getElementById('refimg');
        switch(btn){
            case 'init':
				path = $dir+$imagenes[0];
                $img.src= path;
				$ref.href = path+"zoom.jpg";
				$numimgs.innerHTML = "1 de "+$imagenes.length;
            break;
            case 'back':
            if($step<$imagenes.length-1)
                $step++;
                else
                $step = 0;
				path = $dir+$imagenes[$step];
                $img.src= path;
				$ref.href = path+"zoom.jpg";;
					$numimgs.innerHTML = ($step+1)+" de "+$imagenes.length;
            break;
            case 'next':
            if($step>0)
                $step--;
                else
                $step = $imagenes.length-1;
                path = $dir+$imagenes[$step];
                $img.src= path;
				/*nPath = path.split('.');
				path = nPath[0]+".jpgzoom."+nPath[1];*/
				$ref.href = path+"zoom.jpg";;
				$numimgs.innerHTML = ($step+1)+" de "+$imagenes.length;
            break;
        }
    }
}
/******************IMG SLIDE BY zir3******************/
