// Funciones comunes (Desguace 24h)

// Cambia el gif del saludo en la seleccion de banderas
function VerSaludo(pais) {
 document.getElementById('imgSaludo').src='imagenes/saludo_'+pais+'.gif';
}

// Sustituye un gif de un saludo por un gif transparente
function QuitarSaludo() {
 document.getElementById('imgSaludo').src='imagenes/transparent.gif';
}

// Abre una ventana con un efecto de despliegue
function AbrirVentana(url,poswidth,posheigth,wantscroll) {
 DOM=(document.getElementById)?true:false;
 IE4=(document.all)? true:false;
 Mozilla=(window.navigator.userAgent.indexOf("Gecko")>1)? true:false
 NS=(navigator.appName=="Netscape")?true:false;
 (NS)? PosX="screenX=" : PosX="left=";
 (NS)? PosY=",screenY=" : PosY=",top=";
 
 factorancho=parseInt((poswidth/10)+0.5);
 factoralto=parseInt((posheigth/10)+0.5);
 
 if (wantscroll==true)
  wantscroll='yes';
 else
  wantscroll='no';
  
 var alto=100+factoralto;
 var ancho=100+factorancho;
 var CVentana='ventana=window.open("","","'+PosX+parseInt((screen.width - poswidth)/2)+PosY+parseInt((screen.height - posheigth)/2)+',status=no, resizable, scrollbars='+wantscroll+', width='+ancho+',height='+alto+'")';

 eval(CVentana);
 
 do {
  ((ancho+factorancho)<poswidth) ? ancho=ancho+factorancho: ancho=poswidth;
  ((alto+factoralto)<posheigth) ? alto=alto+factoralto: alto=posheigth;
  ventana.resizeTo(ancho,alto)
 }

 while ((ancho<poswidth) || (alto<posheigth))
  ventana.location=url
}

// Valida los caracteres que se escriben en un input
function filtrar_tecla(e, tipo) {
 var patron=new Array(2);
	
 patron[0] = /[0-9]|\./;	// Float
 patron[1] = /[0-9]/;		// Entero
	
 tecla = (document.all) ? e.keyCode : e.which;
 
 if (tecla==8) return true;  // Tecla de retroceso (para poder borrar) 
 if (tecla==9) return true;  // Tecla TAB
 if (tecla==46) return true; // Tecla Suprimir
	
 te = String.fromCharCode(tecla);
 return patron[tipo].test(te);
} 

