function Elementos(nombre, botok, botover, botnok, cabtxt, cabosc, cabcla, cuadok, cuadnok) {

this.nombre = nombre;

this.botok = botok;
this.botover = botover;
this.botnok = botnok;

this.cabtxt = cabtxt;
this.cabosc = cabosc;
this.cabcla = cabcla;

this.cuadok = cuadok;
this.cuadnok = cuadnok;

this.finCabecera = function() {
   var s = '';
   s =   '<table border="0" cellpadding="0" cellspacing="0" width="10" height="5">';
   s +=   '<tr height=1>';
   s +=      '<td width=9 class="' + this.cabosc + '"></td>';
   s +=      '<td width=1></td></tr>';
   s +=   '<tr>';
   s +=      '<td colspan=2 class="' + this.cabosc + '"></td></tr>';
   s +=   '<tr height=1>';
   s +=      '<td class="' + this.cabosc + '"></td>';
   s +=      '<td></td></tr>';
   s += '</table>';
   return s;
};

this.writeFinCabecera = function() {
   document.write(this.finCabecera());
};

this.cabecera = function(texto, imglogocab, macizo, imgfin, imgevt, idtxt) {
   var s = '';
   s =   '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
   s +=   '<tr>';
   if ((imglogocab != null) && (imglogocab != '')) {
   s +=      '<td rowspan="2" valign="top"><img src="' + imglogocab + '" border="0"/>';
   }
   s +=      '<td class="' + this.cabtxt + '" valign="bottom" width="100%">&nbsp;<b' + ((idtxt != null) ? ' id="' + idtxt + '"' : '') + '>' + texto + '</b></td>';
   s +=      '<td>' + (((imgfin != null) && (imgfin != '')) ? '<img class="' + cabcla + '" src="' + imgfin + '" style="cursor: pointer" border="0" ' + imgevt + '/>' : '') + '</td></tr>';
   s +=   '<tr>';
   s +=      '<td colspan="2" valign="top">';
   s +=         '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
   s +=            '<tr height="1">';
   s +=               '<td width="100%" height="1"/>';
   s +=               '<td rowspan="5" height="5">' + this.finCabecera() + '</td></tr>';
   s +=            '<tr height="1"><td class="' + this.cabosc + '" width="100%" height="1"/></tr>';
   if (macizo == 'S') {
   s +=            '<tr height="1"><td class="' + this.cabosc + '" width="100%" height="1"/></tr>';
   } else {
   s +=            '<tr height="1"><td class="' + this.cabcla + '" width="100%" height="1"/></tr>';
   }
   s +=            '<tr height="1"><td class="' + this.cabosc + '" width="100%" height="1"/></tr>';
   s +=            '<tr height="1"><td width="100%" height="1"/></tr>';
   s +=         '</table></td></tr>';
   s +='</table>';
   return s;
};
this.writeCabecera = function(texto, imglogocab) {
   document.write(this.cabecera(texto, imglogocab, 'N'));
};
this.writeCabeceraMaciza = function(texto, imglogocab) {
   document.write(this.cabecera(texto, imglogocab, 'S'));
};
this.writeCabeceraCierre = function(texto, imglogocab, imgfin, imgevt, idtxt) {
   document.write(this.cabecera(texto, imglogocab, 'N', imgfin, imgevt, idtxt));
};

this.writeLineaBotonera = function() {
   var s = '';
   s  =    '<table border="0" cellpadding="0" cellspacing="0" width="100%">';
   s +=   '   <tr height="1">';
   s +=   '      <td width="100%" class="' + this.cabosc + '" colspan="3" /></tr>';
   s +=   '   <tr>';
   s +=   '      <td>';
   s +=   '         <table width="9" height="1" border="0"  cellpadding="0" cellspacing="0">';
   s +=   '            <tr height="1">';
   s +=   '               <td class="' + this.cabosc + '" /></tr>';
   s +=   '         </table></td>';
   s +=   '      <td width="100%"/>';
   s +=   '      <td>';
   s +=   '         <table width="9" height="1" border="0"  cellpadding="0" cellspacing="0">';
   s +=   '            <tr height="1">';
   s +=   '               <td class="' + this.cabosc + '" /></tr>';
   s +=   '         </table></td></tr>';
   s +=   '   <tr height="1">';
   s +=   '   	<td width="100%" class="' + this.cabosc + '" colspan="3" /></tr>';
   s +=   '</table>';
   document.write(s);
};

this.boton = function(id, texto, funcion, estado, lateral, resaltado, ancho, align) {
   if (lateral == null) lateral = true;
   if (estado == null) estado = 'normal';
   if (resaltado == null) resaltado = 0;
   resaltado = (resaltado)? 'style="border:' + resaltado + 'px outset white" ' : '';
   if (ancho == null) ancho = 84;
   align = (align == null) ? ' align="center"' : ' align="' + align + '"';
   id = (id != null) ? ' id="' + id + '"' : '';
   var s = '<table' + id + align + ' width="' + ancho + '" border="0" cellspacing="0" cellpadding="0" ';
   if (estado == 'normal') {
      if (funcion != null) s += 'onclick="' + funcion + '" style="cursor:pointer;cursor:pointer" ';
   } else s += 'style="cursor: default"';
   s += '><tr>';
   if (lateral) {
      s+='<td class="' + this.cabosc + '" width="6"/>';
      s+='<td width="1"/>';
   }
   if (estado == 'normal') {
      s += '<td  class="' + this.botok + '" ' + resaltado;
      s += 'onmouseover="this.className=\'' + this.botover + '\'" onmouseout="this.className=\'' + this.botok + '\'" ';
   } else if (estado == 'activo') {
     s += '<td class="' + this.botover + '" ' + resaltado;
   } else {
     s += '<td class="' + this.botnok + '" ' + resaltado;
   }
   s += 'width="' + ((!lateral) ? ancho : (ancho - 15)) + '" align="center">' + texto + '</td>';
   if (lateral) {
      s+='<td width="1"/>';
      s+='<td class="' + this.cabosc + '" width="6"/>';
   }
   s+='</tr></table>';
   return s;   
};
this.writeBoton = function(id, texto, funcion, estado, lateral, resaltado, ancho, align) {
   document.write(this.boton(id, texto, funcion, estado, lateral, resaltado, ancho, align));
};
this.activaBoton = function(boton, activa, fun) {
   var tb = document.getElementById(boton);
   var td = (tb.firstChild.firstChild.childNodes.length > 1) ? tb.firstChild.firstChild.childNodes[2] : tb.firstChild.firstChild.firstChild;
   if (activa) {
      eval('tb.onclick = ' + fun);   
      if (td.className == this.botnok) {      
         td.className = this.botover; 
         td.style.cursor = 'pointer';
      }
      eval('td.onmouseover = function () { this.className=\'' + this.botover + '\' };');
   } else {
      fun = tb.onclick; 
      eval('tb.onclick = function() { };');   
      td.className = this.botnok;
      td.style.cursor = 'wait';
      eval('td.onmouseover = function () { this.className=\'' + this.botnok + '\' };');
      setTimeout(this.nombre + '.activaBoton(\'' + boton + '\', true,' + fun + ')', 6000);
   }
};

this.cuadrado = function(texto, estado, tamanyo) {
   if (!texto) texto = '';
   if (!tamanyo) tamanyo = 5;
   return '<table class="' + (((estado == 'activo') || (estado == null)) ? this.cuadok : this.cuadnok) + '" width="' + tamanyo + '" height="' + tamanyo + '" border="0" cellspacing="0" cellpadding="1"><tr><td>' + texto + '</td></tr></table>';
};
this.writeCuadrado = function(texto, estado, tamanyo) {
   document.write(this.cuadrado(texto, estado, tamanyo));
};

this. getPX = function(objeto, relativo) {
   var offset = 0;
   var obj = objeto.offsetParent;
   while (obj != null) {
      offset += obj.offsetLeft + ((relativo) ? - obj.scrollLeft : 0);
      obj = obj.offsetParent;
   }
   return objeto.offsetLeft + offset;
};

this. getPY = function(objeto, relativo) {
   var offset = 0;
   var obj = objeto.offsetParent;
   while (obj != null) {
      offset += obj.offsetTop + ((relativo) ? - obj.scrollTop : 0);
      obj = obj.offsetParent;
   }
   return objeto.offsetTop + offset;
};

this.getSizeFrame = function(obj) {
   var alt = obj.offsetHeight;
   obj = obj.parentNode;
   while (obj != null) {
      if (obj.offsetHeight != null) alt = obj.offsetHeight;
      obj = obj.parentNode;
   }
   return alt;
};

this.getCookie = function(sName) {
   var aCookie = document.cookie.split('; ');
   for (var i=0; i < aCookie.length; i++) {
      var aCrumb = aCookie[i].split('=');
      if ((sName == aCrumb[0]) && (aCrumb.length > 1)) {
         return unescape(aCrumb[1]);
      }
   }
   return '';
};

this.firstElement = function (obj, nivel) {
	if (obj == null) { return null; }

	var child = obj.firstChild;
	while (child != null && child.nodeType != 1) {
		child = child.nextSibling;
	}
	
	if (nivel > 1) {
		return this.firstElement (child, nivel - 1);
	}else{
		return child;
	}
};

this.lastElement = function (obj) {
   if (obj == null) { return null; }

   var last = null;
   var child = obj.firstChild;
   while (child != null ) {
      if (child.nodeType == 1) {
         last = child;
      }
      child = child.nextSibling;
   }

   return last;
};

this.childElements = function (obj) {
   if (obj == null) { return null; }

   var childs = new Array();
   var child  = obj.firstChild;	
   var ind = 0;

   while (child != null) {
      if (child.nodeType == 1) {
         childs[ind++] = child;
      }
      child = child.nextSibling;
   }
   return childs;
};

}

elementos = new Elementos('elementos', 'verdana_10_oscuro_pastel_borde', 'verdana_10_oscuro_naranja_borde', 'verdana_10_oscuro_gris_borde', 'verdana_12_oscuro_blanco', 'fondo_oscuro', 'fondo_naranja', 'verdana_10_oscuro_naranja_borde', 'verdana_10_oscuro_gris_borde');

function popUp(url, nom, args) {
	if (typeof(popupWin) != "object")
	{
	popupWin = window.open(url,nom,args);
	}
	else
	{
		if (!popupWin.closed)
		{
		popupWin.location.href = url;
		}
		else
		{
		popupWin = window.open(url, nom,args);
		}
	}
popupWin.focus();
}
