function enfocar(formulario,campo)
{
	eval("document."+formulario+"."+campo+".focus()");
}

function comprueba(formulario,campo,campotext)
{
	var formu = eval("document."+formulario+"."+campo+".value");
	if (formu=="")
	{
		alert(dic_falta_campo + ": " + campotext);
		enfocar(formulario,campo)
		return false;
	}
	else
		return true;
}


function comprobar()
{
	return (comprueba("formulario","usuario","Usuario") && comprueba("formulario","clave","Clave"));
}

var estiloant = "";
var selant = "";

function recargar(codigo, orden, tipo)
{
var actual;

	try {
		actual = eval("paginas" + codigo);	
		frames.message.location = actual[orden];
		fillnumpag(codigo,orden, 0);
	} catch (e) {
		frames.message.location = "/gestor/blanco.htm";
	}
	
	if (document.all){	
		divpag.style.visibility =  "visible";
		if ( tipo == 1 ) {				
			estilo = eval("h" +codigo);
			if ( estilo != estiloant  ) {
				estilo.className = "Submenusel";
				if ( estiloant != "" ) {
					estiloant.className = "Submenu";
				}
				estiloant = estilo;	
			}
		}			
	} else if (document.layers){
		divpag.visibility = "show";
		if ( tipo == 1 ) {				
			estilo = eval("h" +codigo);
			if ( estilo != estiloant  ) {
				estilo.className = "Submenusel";
				if ( estiloant != "" ) {
					estiloant.className = "Submenu";
				}
				estiloant = estilo;	
			}
		}		
	} else if ( document.getElementById  ) {										
		document.getElementById("divpag").style.visibility =  "visible";
		if ( tipo == 1 ) {				
			estilo = "h" +codigo;
			if ( estilo != estiloant  ) {
				document.getElementById(estilo).style.color = "#FE863E";				
				if ( estiloant != "" ) {	
					document.getElementById(estiloant).style.color = "#FFFFFF";	
				}
				estiloant = estilo;	
			}
		}
		
	} 
}

function senala(codigo) {

var selec;

	if (document.all){

		selec = eval("sel" + codigo);
		if (  selec != selant ) {
			selec.style.visibility = "visible";
			if ( selant != "" ) {
				selant.style.visibility = "hidden";
			}
		}
	} else if (document.layers){

		selec = eval("document.sel" + codigo);
		if (  selec != selant ) {
			selec.visibility =  "show";
			if ( selant != "" ) {
				selant.visibility = "hide";
			}				
		}
	} else if ( document.getElementById  ) {

		selec = "sel" + codigo;			
		if (  selec != selant ) {		
			document.getElementById("sel" + codigo).style.visibility =  "visible";				
			if ( selant != "" ) {
				document.getElementById(selant).style.visibility = "hidden";
			}									
		}
	}
	selant = selec;	
}

function cargarOpcion(codigo)
{
var actual;

	document.formulario.action = "recursos/acceso.asp";

	senala(codigo);
	texto = titulos[codigo];
	if (document.all){	
			titulo.innerHTML = "<nobr>" + texto + "</nobr>";
	} else if (document.layers){
			titulo.document.write("<nobr>" + texto + "</nobr>");
	} else if ( document.getElementById  ) {										
			document.getElementById("titulo").innerHTML =  "<nobr>" + texto + "</nobr>";				
	} 	

	fillup(codigo);
	try {
		actual = eval("paginas" + codigo);
		recargar(codigo,1,0);			
	} catch (e) {
			try {			
				ejecuta = eval("prim" + codigo);
				cargarSubMenu(ejecuta);						
			} catch (e) {
	//			alert(e.message);
				frames.message.location = "/gestor/blanco.htm";
				if (document.all){	
					piepag.style.visibility =  "hidden";
					piepagtop.style.visibility =  "hidden";				
				} else if (document.layers){
					piepag.visibility = "hide";
					piepagtop.visibility = "hide";
				} else if ( document.getElementById  ) {
					document.getElementById("piepag").style.visibility =  "hidden";	
					document.getElementById("piepagtop").style.visibility =  "hidden";				
				} 
			}		
	}
}

function cargarSubMenu(codigo){

		ejecuta = eval("eje" + codigo);
		var cmd = new Array();
		cmd = ejecuta.split(',')

		switch (cmd[0]){   
			case "recargar" :
					recargar(cmd[1],cmd[2],cmd[3]);
				break;		
			case "cargarAltern" :
					cargarAltern(cmd[1],cmd[2]);
				break;		
			case "cargarFuera" :
					cargarFuera(cmd[1]);
				break;
			case "cargarOtra" :
					cargarOtra(cmd[1]);
				break;
	}
}

function cargarFuera(codigo)
{
var actual;

	actual = eval("paginas" + codigo);
	if ( actual.length > 0 ) {
		document.location.href = actual[1];
	}	
}

function cargarOtra(codigo)
{
var actual;
	actual = eval("paginas" + codigo);
	if ( actual.length > 0 ) {
		window.open(actual[1]);
	}	
}

function cargarAltern(codigo, tipo)
{
var actual;

	if ( tipo == 0 ) {
		senala(codigo);
	}
	texto = titulos[codigo];
	if (document.all){	
			titulo.innerHTML = "<nobr>" + texto + "</nobr>";
	} else if (document.layers){
			titulo.document.write("<nobr>" + texto + "</nobr>");
	} else if ( document.getElementById  ) {										
			document.getElementById("titulo").innerHTML =  "<nobr>" + texto + "</nobr>";				
	} 
	
	actual = eval("paginas" + codigo);
	if ( actual.length > 0 ) {
		frames.message.location = actual[1];
	} else {
		frames.message.location = "gestor/blanco.htm";		
	}		 



		if (document.all){
				menu.style.visibility =  "hidden";
				test2.innerHTML= "";
				piepag.style.visibility =  "hidden";
				piepagtop.style.visibility =  "hidden";										
		} else if (document.layers){
				menu.visibility = "hide";
				ns_scroll.document.write("");
				piepag.visibility = "hide";
				piepagtop.visibility = "hide";														
		} else if ( document.getElementById  ) {						
				document.getElementById("menu").style.visibility =  "hidden";
				document.getElementById("test2").style.visibility =  "hidden";
				document.getElementById("test2").innerHTML= "";
				document.getElementById("piepag").style.visibility =  "hidden";	
				document.getElementById("piepagtop").style.visibility =  "hidden";																
		}
}

function cargarSeccion(orden, totalpag) {

	frames.message.location = seccion[orden];
	fillnumpag("", orden, totalpag);
}

function fillnumpag(codigo,orden, totalpag){

var actual;
var pagact;
var textocont = "<font style=\"color: #00305A; font-family: Arial; text-decoration: none;font-size: 8 pt;\">Páginas: </font>";
var alguno = false;

	if ( codigo != "" ) {
		
		try {
			actual = eval ("paginas" + codigo);	
			for ( j = 1; j< actual.length; j++) {
	
				if (orden == j ) {
					textocont= textocont + "<span style=\"color: #00305A; font-family: Arial; text-decoration: none;font-size: 8 pt;\">"+ j + "</span>&nbsp;";	
				} else {
					textocont= textocont + "<a href=\"#\" onclick=\" javascript:recargar(" + codigo +  "," + j + ",0);\" style=\"color: #00305A; font-family: Arial; text-decoration: none;font-size: 8 pt;font-weight: bold;\">" + j +  "</a>&nbsp;"; 
				}
			}
		} catch (e) {		
		}
	} else {
			for ( j = 1; j <= totalpag; j++) {
				if (orden == j ) {
					textocont= textocont + "<span style=\"color: #00305A; font-family: Arial; text-decoration: none;font-size: 8 pt;\">"+ j + "</span>&nbsp;";	
				} else {
					textocont= textocont + "<span onclick=\"javascript:cargarSeccion(" + j + "," + totalpag +");\" ";
					textocont= textocont + "style=\"cursor: hand; color: #00305A; font-family: Arial; text-decoration: none;font-size: 8 pt;font-weight: bold;\">";
					textocont= textocont + j +  "</span>&nbsp;";
				}
			}					
	}		
	
	if (document.all){
		piepag.style.pixelLeft = 0;						
		piepag.innerHTML = "<nobr>" + textocont +"</nobr>";	
		piepag.style.visibility =  "visible";
		piepagtop.innerHTML = "<nobr>" + textocont +"</nobr>";	
		piepagtop.style.visibility =  "visible";				
	} else if (document.layers){
		piepag.left= 0;						
		piepag.document.write("<nobr>" + textocont + "</nobr>");
		piepag.visibility = "show";
		piepagtop.document.write("<nobr>" + textocont + "</nobr>");
		piepagtop.visibility = "show";
	} else if ( document.getElementById  ) {
			document.getElementById("piepag").style.left = 0;												
			document.getElementById("piepag").innerHTML =  "<nobr>" + textocont +"</nobr>";										
			document.getElementById("piepag").style.visibility =  "visible";				
			document.getElementById("piepagtop").innerHTML =  "<nobr>" + textocont +"</nobr>";										
			document.getElementById("piepagtop").style.visibility =  "visible";				
	} 		
}


//function fillnumnot(orden, totalpag){
function fillnumnot(orden, idnot){
var actual;
var pagact;
var textocont = "<font style=\"color: #00305A; font-family: Arial; text-decoration: none;font-size: 8 pt;\">Páginas: </font>";
var alguno = false;
var num;

	noticias =	eval("noticias" + idnot);	
	totalpag = noticias.length -1;
	for ( j = 2; j <= totalpag; j++) {
		num = j -1;
		if (orden == j-1 ) {
			frames.message.location = noticias[orden+1];
			textocont= textocont + "<span style=\"color: #00305A; font-family: Arial; text-decoration: none;font-size: 8 pt;\">"+ num + "</span>&nbsp;";	
		} else {
			textocont= textocont + "<span onclick=\"javascript:fillnumnot(" + num + "," + idnot +");\" ";
			textocont= textocont + "style=\"cursor: hand; color: #00305A; font-family: Arial; text-decoration: none;font-size: 8 pt;font-weight: bold;\">";
			textocont= textocont + num +  "</span>&nbsp;";		
		}
	}					
	
	texto = "Noticias: " + noticias[1];	
	if (document.all){
		var ss = texto.substring(0, 60);   
		titulo.innerHTML = "<nobr>" + ss + "...</nobr>";
		

		piepag.style.pixelLeft = 0;						
		piepag.innerHTML = "<nobr>" + textocont +"</nobr>";	
		piepag.style.visibility =  "visible";
		piepagtop.innerHTML = "<nobr>" + textocont +"</nobr>";	
		piepagtop.style.visibility =  "visible";				
	} else if (document.layers){
		titulo.document.write("<nobr>" + texto + "</nobr>");
		piepag.left= 0;						
		piepag.document.write("<nobr>" + textocont + "</nobr>");
		piepag.visibility = "show";
		piepagtop.document.write("<nobr>" + textocont + "</nobr>");
		piepagtop.visibility = "show";
	} else if ( document.getElementById  ) {
			document.getElementById("titulo").innerHTML =  "<nobr>" + texto + "</nobr>";				
			document.getElementById("piepag").style.left = 0;												
			document.getElementById("piepag").innerHTML =  "<nobr>" + textocont +"</nobr>";										
			document.getElementById("piepag").style.visibility =  "visible";				
			document.getElementById("piepagtop").innerHTML =  "<nobr>" + textocont +"</nobr>";										
			document.getElementById("piepagtop").style.visibility =  "visible";				
	} 		
}

function cargarnoticia(idnot ){
		fillnumnot(1, idnot);
}


var scrollspeed=6;
var actualwidth='';
var ns_scroll;

function fillup(codigo){
var actual;

	try {
		actual = eval ("subPag" + codigo);	
		if (document.all){

			test2.style.pixelLeft = 0; 	
			menu.style.visibility =  "visible";	
			test2.innerHTML= "<nobr>" + actual + "</nobr>";							
			actualwidth=test2.offsetWidth;
		} else if (document.layers){

			ns_scroll.left= 0;						
			menu.visibility = "show";
			ns_scroll=document.ns_scrollmenu.document.ns_scrollmenu2;				
			ns_scroll.document.write("<nobr>" + actual + "</nobr>");
			ns_scroll.document.close();
			actualwidth=ns_scroll.document.width;
		
		} else if ( document.getElementById  ) {
		
			document.getElementById("test2").style.left = 0; 
			document.getElementById("menu").style.visibility =  "visible";
			document.getElementById("test2").innerHTML= "<nobr>" + actual + "</nobr>";
			document.getElementById("test2").style.visibility =  "visible";							
			actualwidth=document.getElementById("test2").offsetWidth;
		
		}				
	} catch (e) {
		if (document.all){
				menu.style.visibility =  "hidden";
				test2.innerHTML= "";						
		} else if (document.layers){
				menu.visibility = "hide";
				ns_scroll.document.write("");										
		} else if ( document.getElementById  ) {						
				document.getElementById("menu").style.visibility =  "hidden";
				document.getElementById("test2").style.visibility =  "hidden";
				document.getElementById("test2").innerHTML= "";												
		}
	}
}


function moveleft(){
var cadena;

	if (document.all&&test2.style.pixelLeft>(menuwidth-actualwidth)) {
		test2.style.pixelLeft-=scrollspeed;
	} else if (document.layers&&ns_scroll.left>(menuwidth-actualwidth)) {
		ns_scroll.left-=scrollspeed;
	}  else if (document.getElementById ) {
				
					cadena = document.getElementById("test2").style.left;
					cadena = cadena.substr(0,cadena.length-2);	
					if  ( cadena>(menuwidth-actualwidth) ) {
					
							document.getElementById("test2").style.left= parseInt(cadena,10) - scrollspeed;
					}
	}	
	lefttime=setTimeout("moveleft()",50);
}

function moveright(){
var cadena;

	if (document.all&&test2.style.pixelLeft<0) {
		test2.style.pixelLeft+=scrollspeed;
	} else if (document.layers&&ns_scroll.left<0) {
		ns_scroll.left+=scrollspeed;
	} else if (document.getElementById ) {
	
					cadena = document.getElementById("test2").style.left;
					cadena = cadena.substr(0,cadena.length-2);
					if ( cadena<0) {
						 document.getElementById("test2").style.left = parseInt(cadena,10) + scrollspeed;
					}
	}
	righttime=setTimeout("moveright()",50);
}

function votar(form)
{

	var x = ((screen.width-800)/2)
	carac="status=no,toolbar=no,width=300,height="+((form.RAD.length*50)+100)+",left="+x+",top=0"
	for (var i=0; i<form.RAD.length; ++i) {
	if (form.RAD[i].checked)
	{
		window.open("votacion.asp?VOT=O"+i,"votaciones",carac);
	}}
	return false;

}


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();
}
MM_reloadPage(true);

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];}
}
