//--- Funciones que sacan el texto y el url de los vectores del menu
function geturl(idmenu,x) {
  return eval('menu_'+idmenu+'['+x+']').slice(eval('menu_'+idmenu+'['+x+']').indexOf('|')+1,eval('menu_'+idmenu+'['+x+']').lastIndexOf('|'));
}
function gettexto(idmenu,x) {
 return eval('menu_'+idmenu+'['+x+']').slice(0,eval('menu_'+idmenu+'['+x+']').indexOf('|'));
}

//--- Funcion construye la fecha ----

function makeArray() {
     for (i = 0; i<makeArray.arguments.length; i++)
          this[i + 1] = makeArray.arguments[i];
}

function getFecha() {
  var months = new makeArray('Enero','Febrero','Marzo',
    'Abril','Mayo','Junio','Julio','Agosto','Septiembre',
    'Octubre','Noviembre','Diciembre');
  var date = new Date();
  var day  = date.getDate();
  var month = date.getMonth() + 1;
  var yy = date.getYear();
  var year = (yy < 1000) ? yy + 1900 : yy;
  return day + " de " + months[month] + " de " + year;
}

//--- Funcion que imprime el título de la subpagina ----
function ImprimeTitulo(titulo,imagen) {
 var StrTitSubPag = '<table cellpadding="0" cellspacing="0" width="100%">'+
' <tr>';
   if (imagen!='') 
      StrTitSubPag += '<td width="200">'+
                      '<img src="img/'+imagen+'" width="200" height="70" class="foto"></td>';
  StrTitSubPag += '<td width="550" class="area">'+titulo+'</td></tr>';
  ' <tr>';
      StrTitSubPag += '<td height="20" class="area" background="img/titulo.gif">'+'</td>';
  StrTitSubPag += '<td height="20" class="area" background="img/titulo.gif">'+'</td></tr></table> ';

return StrTitSubPag;
}


function ImprimeTitulo2(titulo,imagen,imagen2) {

 var StrTitSubPag = '<table cellpadding="0" cellspacing="0" width="100%">'+
' <tr>';
   if (imagen!='') 
      StrTitSubPag += '<td width="200">'+
                      '<img src="img/'+imagen+'" width="200" height="70" class="foto"></td>';
  StrTitSubPag += '<td width="*" class="area">'+titulo+'</td><td class="area" width="214"><img border="0" src="img/'+imagen2+'" width="213" height="57"></td></tr>';
  ' <tr>';
      StrTitSubPag += '<td height="20" class="area" background="img/titulo.gif">'+'</td>';
  StrTitSubPag += '<td height="20" class="area" background="img/titulo.gif" colspan="2">'+'</td></tr></table> ';

return StrTitSubPag;
}



//----- Tabla que contiene el submenu de la izquierda de la página de contenido --------------------------------

function getMenuCtx(idmenu,postitulo) {
var MenuCtxTitOpc =  '<table width="96%" border="0" cellspacing="0" cellpadding="0"> \n' + 
' <tr>  \n' +
' <td class="titMenuCtx">'+gettexto('0',postitulo)+'</td> \n' + /*postitulo saca el titulo del menu del vector menu_0*/
' </tr>  \n';
  var n=0;
  for (x=0;x<eval('menu_'+idmenu).length;x++) {
    if(geturl(idmenu,x)!='*') {
    	MenuCtxTitOpc +='<tr><td class="botOpc"><a class="menu" href="'+ geturl(idmenu,x) +'">'+gettexto(idmenu,x)+'</a></td></tr> \n';
    } else {
        if (n==0) { n=1;} else { MenuCtxTitOpc +='<tr><td>&nbsp;</td></tr> \n'; }
    	MenuCtxTitOpc +='<tr><td class="mnuppal">'+gettexto(idmenu,x)+'</td></tr> \n';
    }
    
  }
MenuCtxTitOpc +='</table>';
return MenuCtxTitOpc;
}


function getPath(v) {
  var Path = '<a class="menupath" href="./">Inicio</a>';
  var a = "";
	var l = "";
  for (x=0;x<v.length;x++) {
	 a = v[x].indexOf('|');
	 l = v[x].length;
     if (x<v.length-1) {
     Path += ' > <a class="menupath" href="'+
              geturl( v[x].slice(0,a), v[x].slice(a+1,l) ) +'">'+
              gettexto( v[x].slice(0,a), v[x].slice(a+1,l) ) + '</a>'; 
     } else {
     Path += ' > ' + gettexto( v[x].slice(0,a), v[x].slice(a+1,l));
     
     }
  }
  return Path;

}

function openNewWindow(src)
{
        window.open(src,"","width=640, height=480, top="+(screen.height-550)/2+", left="+(screen.width-690)/2+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no");
}

function openNewWindow3(src)
{
        window.open(src,"","width=640, height=280, top="+(screen.height-550)/2+", left="+(screen.width-690)/2+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no");
}



function openNewWindow2(src)
{
        window.open(src,"","width=780, height=520, top="+(screen.height-520)/2+", left="+(screen.width-810)/2+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no");
}

function openUpload(src)
{
        window.open(src,"","width=300, height=130, top="+(screen.height-200)/2+", left="+(screen.width-300)/2+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no");
}
function openEvaluacion(src)
{
        window.open(src,"","width=610, height=300, top="+(screen.height-300)/2+", left="+(screen.width-610)/2+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no");
}
function openAdminWindow(src)
{
        window.open(src,"","width=350, height=520, top="+(screen.height-520)/2+", left="+(screen.width-350)/2+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no");
}
function openPass(src)
{
        window.open(src,"","width=300, height=190, top="+(screen.height-140)/2+", left="+(screen.width-300)/2+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no");
}
function openWindowHorarios(src)
{
		window.open(src,"","width=600, height=450, top="+(screen.height-450)/2+", left="+(screen.width-600)/2+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no");
}
function accesar(url)
{
	document.location.reload(url); 
}




//--- Funcion Mostrar Banner
function windowhelpadmin()
{
        window.open("helpadmin/index.html","","width=798, height=590, top="+(screen.height-550)/2+", left="+(screen.width-790)/2+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no");
}


function windowhelpmaterias()
{
        window.open("archivos/materiasenlinea.html","","width=800, height=600, top="+(screen.height-600)/2+", left="+(screen.width-800)/2+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no");
}


function openCartelera()
{
        window.open("cartelera/cartelera_view.jsp","","width=680, height=520, top="+(screen.height-520)/2+", left="+(screen.width-680)/2+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no");
}
