function Ficha() {}

Ficha.scroll_Top = function () {
	var scrollTop = 0;
	if (window.pageYOffset)
	{
		scrollTop = window.pageYOffset;
	}
	else
	{
		scrollTop = Math.max(document.body.scrollTop, document.documentElement.scrollTop);
	}
	return scrollTop;
}
Ficha.scroll_Left = function () {
	var scrollLeft = 0;
	if (window.pageXOffset)
	{
		scrollLeft = window.pageXOffset;
	}
	else if ( document.body.scrollLeft )
	{
		scrollLeft = Math.max(document.body.scrollLeft, document.documentElement.scrollLeft);
	}
	return scrollLeft;
}

Ficha.viewPortSize = function() {
	var v = new Object();
	v.w = 0;
	v.h = 0;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      v.w = window.innerWidth,
      v.h = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       v.w = document.documentElement.clientWidth,
       v.h = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       v.w = document.getElementsByTagName('body')[0].clientWidth,
       v.h = document.getElementsByTagName('body')[0].clientHeight
 }
 return v;
}

Ficha.centrar = function( nombre, ancho, alto ) {
	var obj = document.getElementById( nombre );
	var v = Ficha.viewPortSize();

	obj.style.top = 
		 ( Ficha.scroll_Top() + 
		   v.h / 2 -
		   alto / 2 ) +
		'px';

	obj.style.left = 
		 ( Ficha.scroll_Left() + 
		   v.w / 2 -
		   ancho / 2 ) +
		'px';
}

Ficha.ampliarATodo = function ( nombre ) {
	var obj = document.getElementById( nombre );
	obj.style.top = "0px";
	obj.style.height = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight) + 'px';
	obj.style.left = "0px";
	obj.style.width = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth) + 'px';
}

Ficha.ocultar = function() {
	document.getElementById( 'contenedorSemitransparenteYFicha' ).style.visibility = 'hidden';
}
Ficha.aparecer = function( etiqueta ) {
	var alto = document.getElementById( 'contenedor_' + etiqueta ).offsetHeight;
	var ancho = document.getElementById( 'contenedor_' + etiqueta ).offsetWidth;
	
	document.getElementById( 'contenedorFicha' ).innerHTML = 
									document.getElementById( 'contenedor_' + etiqueta ).innerHTML;

	document.getElementById( 'contenedorSemitransparenteYFicha' ).style.visibility = 'visible';

	Ficha.ampliarATodo( 'semitransparente' );
	Ficha.centrar( 'contenedorFicha', ancho, alto );
	if ( document.getElementById( 'dibujoEquipo' ) ) {
		document.getElementById( 'semitransparente' ).onclick = Ficha.ocultar;
		document.getElementById( 'contenedorFicha' ).onclick = Ficha.ocultar;
		document.getElementById( 'semitransparente' ).style.cursor = 'pointer';
		document.getElementById( 'contenedorFicha' ).style.cursor = 'pointer';
	}
}


