/*
Función para abrir ventanas emergentes.
Parámetros:
url: dirección de destino.
target: nombre de la ventana donde se mostrará el contenido.
width: ancho de la ventana.
height: alto de la ventana.
*/
function abrirPopup(url, target, width, height){

	var max_width = 640;
	var max_height = 480;
	
	if(target == ""){target = "popup";}

	if(width == ""){width = max_width;}
	if(height == ""){height = max_height;}

	if(width < max_width){
		for(var w = max_width; w > width; w *= 0.9){
			if(w <= width){break;}	
		}
		width = w;
	}else{
		if(width > max_width){
			for(var w = width; w > max_width; w *= 0.9){
				if(w <= max_width){break;}	
			}
			width = w;
		}
	}
	
	if(height < max_height){
		for(var h = max_height; h > height; h *= 0.9){
			if(h <= height){break;}	
		}
		width = w;
	}else{	
		if(height > max_height){
			for(var h = height; h > max_height; h *= 0.9){
				if(h <= max_height){break;}	
			}
			height = h;
		}	
	}

	var popup = window.open(url,target,"width="+width+",height="+height+",left=50,top=50,status=no,toolbar=no,menubar=no,location=no,directories=no,scrollbars=yes,resizable=yes");
	popup.focus();
}