

//Para la paginacion de resultados:
function GotoPage(form_name,pag){
	document.forms[form_name].pagina.value = pag;
	document.forms[form_name].submit();
}

//Quita los espacios de una cadena
function trimStr(str) {
  str = this != window? this : str;
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function Control_Subtipos(main_value,subtype_div){
	//segun el valor de main, llevamos a cabo acciones en la div
	//main -> tipo de villa
	//subtype_div -> nombre de la div de subtipos
	//Valores:1 -> villas pareadas, 2 - > villas, 13 -> promociones, 14 -> adosados

	if (main_value == 1 || main_value == 2 || main_value == 13 || main_value == 14){
		eval(subtype_div + ".style.display = 'block';");

	}else{
		eval(subtype_div + ".style.display = 'none';");
	}
}

function OpenSelector(table,key){
	//** table -> la tabla que tratamos
	//** Key -> la referencia a otra tabla
	if (table == "provincias"){
		if(formulario.select_countries.value == ""){
			alert("Por favor seleccione un pais");
			return;
		}
	}

	if (table == "ciudades"){
		if(formulario.select_provincias.value == ""){
			alert("Por favor seleccione una provincia");
			return;
		}
	}

	if (table == "zonas"){
		if(formulario.select_ciudades.value == ""){
			alert("Por favor seleccione una ciudad");
			return;
		}
	}

	if (table == "localizacion"){
		if(formulario.select_zonas.value == ""){
			alert("Por favor seleccione una zona");
			return;
		}
	}
	window.open("selector.php?table=" + table + "&key=" + key,"","left=200,top=250,width="+ 500 +",height= "+ 170 +",toolbar=no,status=no,scrollbars=no,fullscreen=no,resizable=yes");
}

function OpenUpdater(select_object,value){
	if (value == ""){
		return;
	}

	window.open("updater.php?select_object=" + select_object + "&key=" + value,"","left=200,top=250,width="+ 250 +",height= "+ 80 +",toolbar=no,status=no,scrollbars=no,fullscreen=no,resizable=yes");

}

//Cambia el color de una fila de una tabla al recibir el foco
function RowFocus(row,color){
	row.style.backgroundColor = color ;
}

//igual al perder el foco
function RowBlur(row,color){
	row.style.backgroundColor = color ;
}

function dar_foco(objeto) {
	objeto.style.backgroundColor="#DDDDDD";
	objeto.style.cursor="hand";
}

function quitar_foco(objeto) {
	objeto.style.backgroundColor="";
}

function OpenLink(page){
	window.open(page);
}


function ShowImage (image,width,height){
	width_window = width;
	height_window = height + 50;
	if (height_window > 700){ height_window = 700}

	if (width < 800){ width_window = 800} //para las imagenes de las caņitas esas, ancho minimo

	window.open("view_image.php?imagen=" + image + "&img_width=" + width + "&img_height=" + height,"","left=0,top=0,width="+ width_window +",height= "+ height_window +",toolbar=no,status=no,scrollbars=yes,fullscreen=no,resizable=yes");
}