
var Es_IE = navigator.userAgent.toLowerCase ().indexOf ('msie') > 0;


function Clase (Etiqueta, Valor)
{
	var Aux = document.getElementById (Etiqueta);

	if (Aux) Aux.className = Valor;
}


function Display (Etiqueta, Valor)
{
	var Aux = document.getElementById (Etiqueta);
	
	if (Aux) Aux.style.display = Valor;
}


function DisplayTable ()
{
	if (Es_IE) return ('block')
	else return ('table');
}


function DisplayTD ()
{
	if (Es_IE) return ('block')
	else return ('table-cell');
}


function DisplayTR ()
{
	if (Es_IE) return ('block')
	else return ('table-row');
}


function EliminarHijos (Padre)
{
	var i;
	
	if (Padre.hasChildNodes())
	{	for (i = Padre.childNodes.length - 1; i >= 0; i--)
			 Padre.removeChild (Padre.childNodes [i]);
	}
}


function EtiquetaTexto (id, Texto)
{
	var Etiqueta = document.getElementById (id);
	
	if (Etiqueta) Etiqueta.firstChild.nodeValue = Texto;
}


function FlashById (Ident)
{
	if (isSafari) return (document.getElementById (Ident));

	if (document.embeds [Ident]) return (document.embeds [Ident]);
	return (document.getElementById (Ident));
}


function ImageSrc (Imagen, Valor)
{
	if (document.images [Imagen])	document.images [Imagen].src = Valor;
}


function InHTML (Etiqueta, Valor)
{
	var Aux = document.getElementById (Etiqueta);

	if (Aux) Aux.innerHTML = Valor;
}


function OptionSelect (oSelect, Valor, Texto)
{
	var Nodo;
	
	Nodo = document.createElement ('option');
	Nodo.value = Valor;
	Nodo.appendChild (document.createTextNode (Texto));
	oSelect.appendChild (Nodo);
}


function OptionSelectVacio (Select)
{
	var Nodo;
	
	Nodo = document.createElement ('option');
	Nodo.value = '0';
	Nodo.appendChild (document.createTextNode (''));
	Select.appendChild (Nodo);
}


//=======================================================================================
//=======================================================================================
//=======================================================================================
//=======================================================================================



function Color (Etiqueta, Valor)
{
	var Aux = document.getElementById (Etiqueta);
	
	if (Aux) Aux.style.color = Valor;
}


 
function Visible (Etiqueta, Visible)
{
	var Aux = document.getElementById (Etiqueta);
	
	if (Aux) Aux.style.visibility = Visible ? 'visible' : 'hidden';
}


function PosicionAbsoluta (Etiqueta)
{
	var oAux  = document.getElementById (Etiqueta);
	var iLeft = 0;
	var iTop  = 0;
	
	if (oAux && oAux.offsetParent)
	{	iLeft = oAux.offsetLeft;
		iTop  = oAux.offsetTop;
		while (oAux = oAux.offsetParent)
		{	iLeft += oAux.offsetLeft;
			iTop  += oAux.offsetTop;
		}
	}
	return [iLeft, iTop];
}


// Devuelve un array con la anchura y altura de la página y la anchura y altura de la ventana.
function PageSize ()
{
	var xScroll, yScroll;
	var windowWidth, windowHeight;
	
	if (window.innerHeight && window.scrollMaxY) 
	{	xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight)
	{ xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else 
	{ xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	if (self.innerHeight) 
	{	if(document.documentElement.clientWidth) windowWidth = document.documentElement.clientWidth; 
		else windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) 
	{	windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) 
	{ windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(yScroll < windowHeight) pageHeight = windowHeight;
	else pageHeight = yScroll;

	if(xScroll < windowWidth) pageWidth = xScroll;		
	else pageWidth = windowWidth;

	return (new Array(pageWidth,pageHeight,windowWidth,windowHeight));
}


