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();
}

function MM_changeProp(objName,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}

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;
}

// Cambia la visibilidad de una capa
function estadoCapa(capa, estado)
{
    MM_changeProp(capa, "style.visibility", estado);
	//var Netscape = (navigator.appName == "Netscape")?true:false;
	//(Netscape)?eval("document."+capa+".visibility='" +estado+"'"):eval(capa+".style.visibility='"+estado+"'");
}

// Devuelve el texto mostrado del elemento seleccionado de un campo select (no debe ser multiselect)
function getTextoSelect(ctrl)
{
	for (i=0; i<ctrl.options.length; i++)
	{
		if (ctrl.options[i].value == ctrl.value)
			return ctrl.options[i].text;
	}
}

// Necesita que el formulario de la página se llame 'formulario'
function irPagina(url)
{
  f = document.formulario;
  f.action = url;
  f.submit();
}

var wndVar;
function abrirSubVentana(url, nombre, ancho, alto)
{
	w = (screen.availWidth - ancho) / 2;
	h = (screen.availHeight - alto) / 2;
	features = "left="+w+",top="+h;
	features += ",width=" + ancho + ",height=" + alto + ",toolbar=no,menubar=no,resizable=yes,location=no,directories=no,status=no,scrollbars=yes,copyhistory=no";
	if(wndVar !=null)
	{
		wndVar.close();
		wndVar=null;
	}
	wndVar = window.open(url, nombre, features)
	wndVar.focus()
}

function pantallaCompleta()
{
	// Posicionar en toda la pantalla
	top.window.moveTo(0,0);
	if (document.all) 
	{
		top.window.resizeTo(screen.availWidth,screen.availHeight);
	}
	else if (document.layers || document.getElementById) 
	{
		if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth)
		{
			top.window.outerHeight = screen.availHeight;
			top.window.outerWidth = screen.availWidth;
		}
	}
}

function vaciarCombo(obj)
{
	for (var i = obj.options.length - 1; i >= 0; i--) {
		obj.options[i] = null;
	}
		obj.options[0] = new Option("","",false,false);
}

function autotab(thisval, fname, flen)
{
	var fieldname = MM_findObj(fname);

	if(thisval != 9 && thisval != 16)
	{
		if (fieldname.value.length + 1 <= flen)
		{
			fieldname.focus();
		} else 
		{
			for (x=0; x < document.forms[0].elements.length; x++)
			{
				if (fieldname.name == document.forms[0].elements[x].name)
				{
					var nextfield = x + 1;
				}
			}

			document.forms[0].elements[nextfield].focus();
		}
	}
}


///////////////////////////
// Funciones para Listar //
///////////////////////////

function encima(obj) {
	obj.style.backgroundColor = '#ffdf9d';
}

function encima2(obj) {
	obj.style.backgroundColor = '#D6E2F8';
}

function fuera(obj, color_default) {
	obj.style.backgroundColor = color_default;
}
