/********Rutinas generales para los casos Javascript***********/
/***Objetos globales definidos aquí**********/
function oNavegador(  ) {
	this.nombre = navigator.appName;
	this.iniciar = iniciar;
	this.ponerModVer = ponerModVer;
	this.IE = this.nombre.toUpperCase().indexOf('MICROSOFT') >=0;
	this.NS = this.nombre.toUpperCase().indexOf('NETSCAPE') >=0;
	this.OP = this.nombre.toUpperCase().indexOf('OPERA') >= 0;
	this.XX = !this.IE && !this.NS && !this.OP;
	this.version = this.iniciar();
	this.Verent = parseInt(this.version);
	this.standard = (this.IE && this.Verent >=5) || (this.NS && this.Verent >=5)
	this.modVer = this.ponerModVer();
/* ======================================================================
	FUNCION:	iniciar( ), miembro de oNavegador
	ARGS: 		none.
	DEVUELVE:	nada
	DESCRIP:	Inicializa los valores del objeto
====================================================================== */
  function iniciar() {
  var ver = navigator.appVersion;
  if(ver+"" != "NaN")
	if (this.IE)
		{
		ver.match(/(MSIE)(\s*)([0-9].[0-9]+)/ig);
  		ver = RegExp.$3;
		}
  return ver;
  } //Termina la funcion iniciar el objeto
 //Selector para usar en sentencias switch
 //Los modelos de navegadores serán de la forma IE4, IE5, NS4, NS5 ...
  function ponerModVer()
  {
  if (this.IE) return "IE"+this.Verent;
  if (this.NS) return "NS"+this.Verent;
  if (this.OP) return "OP"+this.Verent;
  return "XXNN";
   }
}

window.miNavegador = new oNavegador()
window.miNavegador.iniciar();
var mie = "IE4, IE5, IE6, NS5".indexOf(miNavegador.modVer)>=0;
var version=navigator.appVersion, verex;
if ( window.miNavegador.IE ) 
{
   version.match(/(MSIE)(\s*)([0-9].[0-9]+)/ig);
   verex = RegExp.$3;
}
//Busca un valor de estilo en un descriptor. Solo MSIE <5
//no llamar con otro explorador
function estiloActual(obj, estilo, atributo)
{
var regla;
var devolver=null
//Si el estilo está definido en linea
if (miNavegador.NS && miNavegador.version < 5) return obj[atributo];
if (obj.style[atributo] != '') return obj.style[atributo]
if (verex >=5)
	devolver = obj.currentStyle[atributo]
else{
	regla = buscaEstilo(estilo)
	devolver = regla.style[atributo];	
	}
return devolver;
}
function buscaEstilo(estilo)
{
var hj, fin, hojas = document.styleSheets;
for (hj = 0; hj < hojas.length; hj++)
	{
	reglas = hojas[hj].rules;
	for (ti=0; ti< reglas.length; ti++)       
		{
		if (reglas[ti].selectorText.toUpperCase() == '.'+estilo.toUpperCase())
			{
			devolver = reglas[ti];	
			fin = true;
			break;
			}
		}	
	if (fin) break;		
	}		
return reglas[ti];
}//Cambia el valor de un atributo (MSIE)
function atributoClase(nombre, atributo, valor)
{
var regla = buscaEstilo(nombre)
regla.style[atributo] = valor;
}

function objHtml(n, d) { 
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
    }
  if (d.getElementById) 
  		x = d.getElementById(n);
  if(!x && !(x=d[n]) && d.all) 
      x=d.all[n]; 
  for (i=0; !x && i<d.forms.length; i++) 
      x=d.forms[i][n];
  for(i=0; !x && d.layers &&i< d.layers.length; i++) 
      x=objHtml(n,d.layers[i].document); 
  return x;
}

function cambImg() {
var i,j=0,x,a=cambImg.arguments; 
document.arIm=new Array; 
for(i=0;i<(a.length-2);i+=2)
if ((x=objHtml(a[i]))!=null){
    document.arIm[j++]=x; 
    if(!x.oSrc) x.oSrc=x.src; 
    x.src=a[i+1];}
}
function restImg() { 
  var i,x,a=document.arIm;
 for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

/* Precarga de imágenes */
/*Argumentos: nombres y situación de imágenes a precargar*/
function precargaImags() { 
 if(document.images){ 
     if(!document.prs) 
        document.prs=new Array();
 var i,j=document.prs.length,args=precargaImags.arguments; 
 for(i=0; i<args.length; i++)
    { document.prs[j]=new Image; document.prs[j].src=args[i]; j++}}
}

function ultActual() {
var cfecha = document.lastModified;
return fechaDia(cfecha);
}

function fechaDia(cfecha)
{
var meses = new Array("Enero", "Febrero","Marzo","Abril","Mayo","Junio",
"Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");
var fecha
if (cfecha)
	fecha = new Date(Date.parse(cfecha));
else
	fecha = new Date();
var dia = fecha.getDate();
var mes = meses[fecha.getMonth()];
var agno = fecha.getFullYear();
if (agno <= 1900)
	agno += 100
return (dia +" de "+mes +" de "+agno);
}
function mostrarCapa(obj)
{
var eleHtml = objHtml(obj)
if (eleHtml.style)
	eleHtml.style.visibility = "visible"
else	
	eleHtml.visibility = "visible"
}

function mostrarBlq(obj, sino)
{
var estado;
if (arguments.length >1)
	{
	estado = sino?'visible':'hidden';
	if (miNavegador.standard)
		obj.style.visibility = estado;
	else 
		obj.visibility = estado;
	}		
else
	{
	if (miNavegador.standard)
		estado = obj.style.visibility;
	else 
		estado = obj.visibility;
	}	
return estado;		
}
function ctrlError()
{
return true;
}
//window.onerror = ctrlError;

function cambProp(objeto,Prop,Valor) { 
  var obj;
  if (objeto.id) obj = objeto;
  else obj = objHtml(objeto);
  if (!obj) return;
  if (miNavegador.standard || (miNavegador.IE && miNavegador.Verent == 4))
  	{
	if (obj[Prop])
	    obj[Prop]=Valor;    
	else
	    obj.style[Prop]=Valor;    
	if (obj.style.cursor == "hand")
		obj.style.cursor = "default";
	else
		obj.style.cursor = "hand"	
	}  
  else {
	if (Prop == "className")
		if (document.classes[Valor].all.backgroundColor)
			obj.bgColor = document.classes[Valor].all.backgroundColor;
		else
			obj.bgColor = null;	
	else
		obj[Prop] = Valor;	 	
    }
}

function posAbsY(obj)
{
if (obj.offsetParent!=null)
	return obj.offsetTop+posAbsY(obj.offsetParent)
return obj.offsetTop;
}
function posAbsX(obj)
{
if (obj.offsetParent!=null)
	return obj.offsetLeft+posAbsX(obj.offsetParent)
return obj.offsetLeft;
}
//Alto del documento en la ventana
function altoDoc()
{
var i, max = 0;
var colec;
if (miNavegador.standard)
	{
	if (miNavegador.IE)
		{
		max=document.body.scrollHeight;	
		colec = document.all.tags('Div');
		}
	else	
		colec = document.getElementsByTagName('Div');
	for (i=0; i < colec.length; i++)
		max = Math.max(posAbsY(colec[i])+colec[i].offsetHeight, max);
	}
  else 	
	max = document.Height ;
return max;
}
function ponerPie(nombPie)
{
if(miNavegador.IE && document.readyState != 'complete')
	{
	setTimeout("ponerPie('"+nombPie+"')", 500);
	return;
	}

var altura;
var pie = objHtml(nombPie);
if (!pie) return;
if (miNavegador.standard || miNavegador.IE)
	{
	altura = altoDoc();
	pie.style.top = altura;
	pie.style.left = 30;
	pie.style.visibility = 'visible';
	pie.style.zIndex = 0;
	}
else
	{
	pie.top = document.height;
	document.height += pie.clip.height;
	pie.visibility = 'visible';
	}
}