
//****************************
//** Funciones JS Generales **
//****************************
function limpiar_formulario(){
	document.forms[0].reset();
}
function siguiente(_pagina){
	document.forms[0].Pagina.value = _pagina;
	document.forms[0].submit();
}
function siguiente_promocion(_id){
	document.forms[0].Id.value = _id;
	document.forms[0].submit();
}
function cargarPopup(_url,_ancho,_alto,_x,_y){
	ventana = window.open (_url,'ventana','menubar=no,location=no,resizable=no,scrollbars=yes,status=no,width='+_ancho+',height='+_alto + ',top='+_x+',left='+_y);
	ventana.focus();
}
function enviar_buscar(_ruta){
	if (comprobar_operacion() == false) return;
	if (comprobar_avisame()){
		if (_ruta == 1){
			document.forms[0].action = "aviso.php";
		}else{
			document.forms[0].action = "../aviso.php";
		}
		document.forms[0].submit();
		return;
	}
	if (_ruta == 1){
		document.forms[0].action = "contenidos02/resultados.php";
	}else{
		document.forms[0].action = "../contenidos02/resultados.php";
	}
	document.forms[0].submit();
}
function comprobar_avisame(){
	if (document.forms[0].Avisame.checked){
		return true;
	}else{
		return false;
	}
}
function enviar_buscar_avanzado(){
	if (comprobar_operacion() == false) return;
	if (comprobar_avisame()){
		document.forms[0].action = "aviso.php";
		document.forms[0].submit();
		return;
	}
	document.forms[0].action = "contenido01_02.php";
	document.forms[0].submit();
}
function comprobar_operacion(){
	
	if ((document.forms[0].Operacion[0].checked == false) && (document.forms[0].Operacion[1].checked == false)){
		alert("Por favor, indique si desea buscar un inmueble para alquiler o compra");
		return false;
	}
	
}
function isEmailAddress(theElement, nombre_del_elemento){
	var s = theElement.value;
	var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (s.length == 0 ) return true;
	if (filter.test(s))
	return true;
	else
	alert("Ingrese una dirección de correo válida");
	theElement.focus();
	return false;
}
function rellenar_buscador(_operacion, _tipo, _localidad, _superficie01, _superficie02, _avisame){
	objeto = document.forms[0];
	for (var i=0;i<objeto.Operacion.length;i++){
		if (objeto.Operacion[i].value == _operacion){
			objeto.Operacion[i].checked = true;
		}
	}
	for (var i=0;i<objeto.Tipo.length;i++){
		if (objeto.Tipo[i].value == _tipo){
			objeto.Tipo[i].selected = true;
		}
	}
	for (var i=0;i<objeto.Localidad.length;i++){
		if (objeto.Localidad[i].value == _localidad){
			objeto.Localidad[i].selected = true;
		}
	}
	if (_superficie01 != 0){
		objeto.Superficie01.value = _superficie01;
	}
	if (_superficie02 != 0){
		objeto.Superficie02.value = _superficie02;
	}
	if (_avisame != 0){
		objeto.Avisame.checked = true;
	}
}
function cargar_combo(campo,tabla){
	campo_formulario = eval("document.formulario." + campo);
	for(i=1 ; i <= eval(tabla+".length") ; i++){
		opcion = new Option(eval(tabla+"[i-1][1]"),eval(tabla+"[i-1][0]"))
		campo_formulario.options[i] = opcion;
	}
}
function cargar_seleccion(campo_origen,tabla_origen,campo_destino,tabla_destino){
	campo_origen = eval("document.formulario." + campo_origen);
	campo_destino = eval("document.formulario." + campo_destino);
	valor = campo_origen.options[campo_origen.selectedIndex].value;
	campo_destino.length = 1;
	f = 0;
	for(i=0 ; i < eval(tabla_destino+".length") ; i++){
		elemento = eval(tabla_destino+"[i][0]").split("-");
		if (valor == elemento[0]){
			f++;
			opcion = new Option(eval(tabla_destino+"[i][1]"),elemento[1])
			campo_destino.options[f] = opcion;
		}
	}
}
function rellenar_buscador_avanzado(_operacion, _tipo, _localidad, _superficie01, _superficie02, _avisame, _precio01, _precio02,_zona){
	objeto = document.forms[0];
	for (var i=0;i<objeto.Operacion.length;i++){
		if (objeto.Operacion[i].value == _operacion){
			objeto.Operacion[i].checked = true;
		}
	}
	for (var i=0;i<objeto.Tipo.length;i++){
		if (objeto.Tipo[i].value == _tipo){
			objeto.Tipo[i].selected = true;
		}
	}
	for (var i=0;i<objeto.Localidad.length;i++){
		if (objeto.Localidad[i].value == _localidad){
			objeto.Localidad[i].selected = true;
		}
	}
	cargar_seleccion('Localidad','tabla_localidades','Zona','tabla_zonas');
	for (var i=0;i<objeto.Zona.length;i++){
		if (objeto.Zona[i].value == _zona){
			objeto.Zona[i].selected = true;
		}
	}
	if (_superficie01 != 0){
		objeto.Superficie01.value = _superficie01;
	}
	if (_superficie02 != 0){
		objeto.Superficie02.value = _superficie02;
	}
	if (_precio01 != 0){
		objeto.Precio01.value = _precio01;
	}
	if (_precio02 != 0){
		objeto.Precio02.value = _precio02;
	}
	if (_avisame != 0){
		objeto.Avisame.checked = true;
	}
}
<!--
function inhabilitar(){
	return false
}
var ventana;
var cont=0;
var titulopordefecto = "GlobyShop" //texto por defecto a mostrar en la barra de título en caso de omitir el argumento titulo
function afoto(cual,titulo)
{
	if(cont==1){ventana.close();ventana=null}
	if(titulo==null){titulo=titulopordefecto}
	ventana=window.open('','ventana','resizable=yes,scrollbars=no,width=1,height=1');
	/*ventana.document.write('<html><head><title>' + 'GlobyShop' + '</title><script>function inhabilitar(){return false;} document.oncontextmenu=inhabilitar</script></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no" onUnload="opener.cont=0"><a href="javascript:window.close()"><img src="' + cual + '" border="0" onLoad="opener.redimensionar(this.width, this.height)"></a>');
//document.body.scrollWidth
alert(document.images[0].scrollWidth, document.images[0].scrollHeight);
*/	
	ventana.document.write('<html><head><title>' + 'GlobyShop' + '</title><script>function inhabilitar(){return false;} document.oncontextmenu=inhabilitar</script></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no" onUnload="opener.cont=0"><a href="javascript:window.close()"><img src="' + cual + '" border="0" onLoad="opener.redimensionar(document.images[0].scrollWidth, document.images[0].scrollHeight)"></a>');
	ventana.document.close();
	cont++;
}
function redimensionar(ancho,alto)
{
	if (ventana.XMLHttpRequest) {
		if(document.all){
			//document.write("IE 7");
			ancho = ancho;//-50;
			alto = alto+40;//+30;           
		}else{
			//document.write("Mozilla");
			//mozilla, safari, opera 9…etc
			ancho = ancho+7;
			alto = alto+53;
		}
	}
	else {
		//document.write("IE 6");
		// IE6, older browsers
		ancho = ancho+3;
		alto = alto+32;
	}
	ventana.resizeTo(ancho, alto);
	ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2); //centra la ventana. Eliminar si no se quiere centrar el popup
}
