ie  = (document.all)?true:false;
ns4 = (top.document.layers)?true:false;
var ns6 = (document.getElementById)?true:false;

function openWindowMenu(dir,ancho,alto)
{
	ventana=window.open(dir,'ventana','toolbar=0,titlebar=no,location=0,status=0,menubar=0,resizable=0,scrollbars=no');
	ventana.resizeTo(ancho,alto);
	ventana.focus();
}

function openWindowResize(ancho,alto,windowName)
{
abrir = window.open("",windowName,'width='+ancho+',height='+alto+' toolbar=0,titlebar=no,location=0,status=0,menubar=0,resizable=0,scrollbars=no');
abrir.resizeTo(ancho,alto);
abrir.focus();

}

function openWindowScrBar(ancho,alto,windowName)
{
abrir = window.open("",windowName,'width='+ancho+',height='+alto+' toolbar=0,titlebar=no,location=0,status=0,menubar=0,resizable=0,scrollbars=yes');
abrir.resizeTo(ancho,alto);
abrir.focus();

}
function openWindowPosition(dir,ancho,alto,left,top)
{
	ventana=window.open(dir,'ventana','toolbar=0,titlebar=no,location=0,status=0,menubar=0,resizable=0,scrollbars=no,left='+left+',top='+top);
	ventana.resizeTo(ancho,alto);
	ventana.focus();
}
function openWindowPrint(dir,ancho,alto)
{
	ventana=window.open(dir,'ventana','toolbar=1,titlebar=no,location=0,status=0,menubar=1,resizable=0,scrollbars=1');
	ventana.resizeTo(ancho,alto);
	ventana.focus();
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  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(!(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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
	
	
// alto de pantalla
function dameAlto()
{
	if (ie)
	{
		return window.screen.availHeight -131;
	}
	else
	{
		return 0;
	}
}

// Funciones del desplegable
function menuOn()
{
  setVisibility('menuOn', true);
}
function menuOff()
{
  setVisibility('menuOn', false);
}
function setVisibility(layer,on)
{
    DOM = (document.getElementById) ? 1 : 0;
    NS4 = (document.layers) ? 1 : 0;
	if (on)
    {
		if (DOM) { document.getElementById(layer).style.visibility = "visible"; }
        else if (NS4) { document.layers[layer].visibility = "show"; }
        else { document.all[layer].style.visibility = "visible"; }
	}
    else
    {
		if (DOM) { document.getElementById(layer).style.visibility = "hidden"; }
        else if (NS4) { document.layers[layer].visibility = "hide"; }
        else { document.all[layer].style.visibility = "hidden"; }
	}
}

// Fin funciones del desplegable

//Funciones de iluminacion de celdas

function filai(src,color_entrada) {
src.bgColor=color_entrada;src.style.cursor="hand";
}

function filao(src,color_default) {
src.bgColor=color_default;src.style.cursor="default";
}

//reajuste de la altura del pie para netscape
function desplazarPie()
{
	nsX=false;
	if(navigator.appName.indexOf('Netscape')>-1)
	{
		nsX=true;
	}
	if(nsX)
	{	
		tamanoActual=document.height;
		//var limite=window.innerHeight-17;
		var limite=window.innerHeight+180;
		if(limite>tamanoActual)
		{
			document.write('<img src=/comun/img/sp.gif height=');
			document.write(limite-tamanoActual);
			document.write(' width=1>');
		}
	}
}

function capitalize(texto)
{
var palabras=texto.toLowerCase().split(" ");
var textoFormateado="";
for (i=0;i<palabras.length;i++)
	{
		var palabra=palabras[i];
		if (!palabra.match(/[^xiv]/))
			textoFormateado+=" "+palabra.toUpperCase();
		else if (palabra.indexOf("-")!=-1)
			{
				guion=palabra.substring(palabra.indexOf("-"),palabra.indexOf("-")+2).toUpperCase();
				palabra=palabra.replace(/-\w/,guion);
				textoFormateado+=" "+palabra.substring(0,1).toUpperCase()+palabra.substring(1);
			}
		else if (palabra.substring(0,1)=="\"")
			textoFormateado+=" "+palabra.substring(0,2).toUpperCase()+palabra.substring(2);
		else
			textoFormateado+=" "+palabra.substring(0,1).toUpperCase()+palabra.substring(1);
	}


textoFormateado=textoFormateado.replace(/^\s/, "");
textoFormateado=textoFormateado.replace(/ Y /gi, " y ");
textoFormateado=textoFormateado.replace(/ Del /gi, " del ");
textoFormateado=textoFormateado.replace(/ De /gi, " de ");
textoFormateado=textoFormateado.replace(/ do /gi, " do ");
textoFormateado=textoFormateado.replace(/ La /gi, " la ");
textoFormateado=textoFormateado.replace(/ El /gi, " el ");
textoFormateado=textoFormateado.replace(/ Los /gi, " los ");
textoFormateado=textoFormateado.replace(/ Las /gi, " las ");
textoFormateado=textoFormateado.replace(/ Al /gi, " al ");
return(textoFormateado);
}

