/*=======================================================================================
FUNCION:	showpic()
ARGS:		--- 
DEVUELVE:	---
DESCRIP:	Muestra una imagen ajustndola al tamao de la ventana que la contiene.  
=======================================================================================*/
function showpic(src, w, h, alt, aln, pw, ph, bw, bh) {
if (src == null) return;
var iw, ih; // Set inner width and height
if (window.innerWidth == null) {
iw = document.body.clientWidth;
ih=document.body.clientHeight; 
}
else {
iw = window.innerWidth;
ih = window.innerHeight;
}
if (w == null) w = iw;
if(h == null)  h = ih;
if(alt == null) alt = "Picture";
if(aln == null) aln = "left";
if(pw == null) pw = 100;
if(ph == null) ph = 100;
if(bw == null) bw = 24;
if(bh == null) bh = 24;
var sw = Math.round((iw - bw) * pw / 100);
var sh = Math.round((ih - bh) * ph / 100);
if ((w * sh) / (h * sw) < 1) sw = Math.round(w * sh / h);
else sh = Math.round(h * sw / w);
document.write('<img src="'+src+'" alt="'+alt+'" width="'+sw+'" height="'+sh+'" align="'+aln+'">');
}


/*========================================================================================
FUNCION:	expand()
ARGS:		--- 
DEVUELVE:	---
DESCRIP:	Abre una ventana maximizada.  
========================================================================================*/
function expand() {
  window.moveTo(0,0);
  window.resizeTo(screen.availWidth, screen.availHeight);
}


/*========================================================================================
FUNCION:	expandSlowly()
ARGS:		--- 
DEVUELVE:	---
DESCRIP:	Abre una ventana, la centra y va aumentando su tamao hasta maximizarla. 
                Esta funcin va un poco lenta cuando se ejecuta a travs de Internet y
                no en local.
========================================================================================*/
function expandSlowly() {
  for(x = 0; x < 50; x++) {
    window.moveTo(screen.availWidth * -(x - 50) / 100, screen.availHeight * -(x - 50) / 100);
    window.resizeTo(screen.availWidth * x / 50, screen.availHeight * x / 50);
  }
  window.moveTo(0,0);
  window.resizeTo(screen.availWidth, screen.availHeight);
}


/*========================================================================================
FUNCION:	noBackspaceKey()
ARGS:		--- 
DEVUELVE:	---
DESCRIP:	Inhabilita la tecla "backspace", y saca un mensaje avisando de ello 
                cuando se pulse. Para que funcione, hay que llamar a esta funcin en
                el "OnKeyDown" del BODY del documento HTML.
========================================================================================*/
function noBackspaceKey() {
  if(window.event.keyCode==8){
    alert("Backspace key not allowed.");
    window.event.returnValue = false;
  }
}



/*========================================================================================
FUNCION:	printWindow()
ARGS:		--- 
DEVUELVE:	---
DESCRIP:	Sirve para imprimir la pagina actual.
========================================================================================*/
function printWindow() {
	bV = parseInt(navigator.appVersion);
	if (bV >= 4) window.print();
}


/*========================================================================================
FUNCION:	chColor()
ARGS:		el objeto a cambiar de color, el color al que tiene que cambiar.
DEVUELVE:	---
DESCRIP:	Para cambiar el color del objeto que se manda.
========================================================================================*/
function chColor(src,clr) {
	src.bgColor = clr;
}

/*========================================================================================
FUNCION:	CheckAll(chk)
ARGS:		El listado de Checkbox a seleccionar
DEVUELVE:	---
DESCRIP:	Seleccionar todos los Checkbox
========================================================================================*/
function CheckAll(chk)
{
	for (i = 0; i < chk.length; i++)
		chk[i].checked = true ;
}

/*========================================================================================
FUNCION:	UnCheckAll(chk)
ARGS:		El listado de Checkbox a deseleccionar
DEVUELVE:	---
DESCRIP:	Deseleccionar todos los Checkbox
========================================================================================*/
function UnCheckAll(chk)
{
	for (i = 0; i < chk.length; i++)
		chk[i].checked = false ;
}

