
function abrir(url,nombre,scrollbar,width,height){
    window.open(url,nombre,scrollbar,width,height)
}


function centrar(theDiv,h,v,hPx,vPx){
    var obj,fun,dw,dh,lw,lh,x,y,offset;
    if(document.all) {
        offset = 308; //Explorer
    } else {
        offset = 318; //Netscape
    }
    fun = (document.getElementById) ? "document.getElementById" : "MM_findObj";
    obj = (document.getElementById) ? document.getElementById(theDiv) : MM_findObj(theDiv);
    if(obj){if(document.all){
    dw = document.body.clientWidth;dh = document.body.clientHeight;}
    else{dw = innerWidth;dh = innerHeight;}
    if(document.layers){lw = obj.clip.width;lh = obj.clip.height;}else{
    lw = obj.style.width.replace("px","");lh = obj.style.height.replace("px","");}
    dw = dw/2 - lw/2 - offset;
    x = (document.layers) ? ".left" : ".style.left";
    y = (document.layers) ? ".top" : ".style.top";
    eval(fun+"('"+theDiv+"')"+x+"="+dw);
    }
}


function centrar2(theDiv,h,v,hPx,vPx){
    var obj,fun,dw,dh,lw,lh,x,y,offset;
    if(document.all) {
        offset = 280; //Explorer
    } else {
        offset = 288; //Netscape
    }
    fun = (document.getElementById) ? "document.getElementById" : "MM_findObj";
    obj = (document.getElementById) ? document.getElementById(theDiv) : MM_findObj(theDiv);
    if(obj){if(document.all){
    dw = document.body.clientWidth;dh = document.body.clientHeight;}
    else{dw = innerWidth;dh = innerHeight;}
    if(document.layers){lw = obj.clip.width;lh = obj.clip.height;}else{
    lw = obj.style.width.replace("px","");lh = obj.style.height.replace("px","");}
    dw = dw/2 - lw/2 - offset;
    x = (document.layers) ? ".left" : ".style.left";
    y = (document.layers) ? ".top" : ".style.top";
    eval(fun+"('"+theDiv+"')"+x+"="+dw);
    }
}


function centrar3(theDiv,h,v,hPx,vPx){
    var obj,fun,dw,dh,lw,lh,x,y,offset;
    if(document.all) {
        offset = 146; //Explorer
    } else {
        offset = 154; //Netscape
    }
    fun = (document.getElementById) ? "document.getElementById" : "MM_findObj";
    obj = (document.getElementById) ? document.getElementById(theDiv) : MM_findObj(theDiv);
    if(obj){if(document.all){
    dw = document.body.clientWidth;dh = document.body.clientHeight;}
    else{dw = innerWidth;dh = innerHeight;}
    if(document.layers){lw = obj.clip.width;lh = obj.clip.height;}else{
    lw = obj.style.width.replace("px","");lh = obj.style.height.replace("px","");}
    dw = dw/2 - lw/2 - offset;
    x = (document.layers) ? ".left" : ".style.left";
    y = (document.layers) ? ".top" : ".style.top";
    eval(fun+"('"+theDiv+"')"+x+"="+dw);
    }
}


function P7_MultiMove() { //v1.2 PVII
  var a,b,x,xx,y,yy,args=P7_MultiMove.arguments;
    for (i=0; i<(args.length-3); i+=4) if ((a=MM_findObj(args[i]))!=null) {
      b=(document.layers)?a:a.style;x=args[i+1];y=args[i+2];
      if (args[i+3]==1) {
         xx=(parseInt(b.left))?parseInt(b.left):0;
     yy=(parseInt(b.top))?parseInt(b.top):0;
       x+=xx;y+=yy;
      }
      b.left = parseInt(x);b.top = parseInt(y);
    }
}


function fecha()
{
today = new Date()
day = today.getDay()
if ( day == 0 ) {
document.write("Domingo, ");
}
if ( day == 1 ) {
document.write("Lunes, ");
}
if ( day == 2 ) {
document.write("Martes, ");
}
if ( day == 3 ) {
document.write("Miércoles, ");
}
if ( day == 4 ) {
document.write("Jueves, ");
}
if ( day == 5 ) {
document.write("Viernes, ");
}
if ( day == 6 ) {
document.write("Sábado, ");
}

today = new Date()
hours = today.getHours()
minutes = today.getMinutes()
year = parseInt(today.getYear(),10)

zerom = ''
zeroh = ''
if ( minutes < 10 ) { zerom = 0 }
if ( hours < 10 ) { zeroh = 0 }

if ( today.getMonth() == 0 ) { month = "Enero" }
if ( today.getMonth() == 1 ) { month = "Febrero" }
if ( today.getMonth() == 2 ) { month = "Marzo" }
if ( today.getMonth() == 3 ) { month = "Abril" }
if ( today.getMonth() == 4 ) { month = "Mayo" }
if ( today.getMonth() == 5 ) { month = "Junio" }
if ( today.getMonth() == 6 ) { month = "Julio" }
if ( today.getMonth() == 7 ) { month = "Agosto" }
if ( today.getMonth() == 8 ) { month = "Septiembre" }
if ( today.getMonth() == 9 ) { month = "Octubre" }
if ( today.getMonth() == 10 ) { month = "Noviembre" }
if ( today.getMonth() == 11 ) { month = "Diciembre" }
if ( today.getYear() == 99 ) { year = "1999" }
if ( today.getYear() == 0 || today.getYear() == 100 || today.getYear() == 2000) { year = "2000" }

document.write( today.getDate()," de ",month," de ",year );
}


function abrirpopup(nombre,ancho,alto,cerrar) {
dat = 'width=' + ancho + ',height=' + alto + ',left=0,top=0,scrollbars=no,resize=no';
ventana=window.open(nombre,'',dat);
if (cerrar == 1) setTimeout("ventana.close()",20*1000);
}


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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


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 regenerate(){
window.location.reload()
}


function regenerate2(){
if (document.layers){
setTimeout("window.onresize=regenerate",450)
intializemarquee()
}
}


function intializemarquee(){
document.cmarquee01.document.cmarquee02.document.write(marqueecontents)
document.cmarquee01.document.cmarquee02.document.close()
thelength=document.cmarquee01.document.cmarquee02.document.height
scrollit()
}


function scrollit(){
if (document.cmarquee01.document.cmarquee02.top>=thelength*(-1)){
document.cmarquee01.document.cmarquee02.top-=speed
setTimeout("scrollit()",75)
}
else{
document.cmarquee01.document.cmarquee02.top=marqueeheight
scrollit()
}
}


function desplz_marquee(mensaje,ancho,alto,vel){
// ancho
var marqueewidth=ancho
// alto
var marqueeheight=alto
// velocidad
var speed=vel
// contenido
var marqueecontents=mensaje


// cambio el contenido de marquee
var marqueecontents=mensaje


document.write('<marquee behavior= "scroll" direction="up" scrollAmount='+speed+' width='+marqueewidth+' height='+marqueeheight+' onmouseover="this.stop()" onmouseout="this.start()">'+marqueecontents+'</marquee>')
}


function saltar_pagina( url, post_actual, total_posts )
{
msg = "Por favor, escribe un número entre 1 y" + " " + total_posts;
if ( post_actual < total_posts )   { show_page = post_actual + 1; }
if ( post_actual >= total_posts )  { show_page = post_actual - 1; }
userPage = prompt( msg, show_page );
if ( userPage > 0  )
{
    if ( userPage < 1 )             { userPage = 1;  }
    if ( userPage > total_posts )   { userPage = total_posts; }
    window.location = url + userPage;
}
}


/* dice si cadena es url (http://... ) o no */
function url(cadena)
{
    // DECLARACION DE CONSTANTES
    var http = "http://";              // protocolo HTTP
                                       // DECLARACION DE VARIABLES
    var es_url;                        // cadena es url o no
    if(cadena.length <= 7)             // INICIO
      es_url = false;                  // no cabe "http://*"
    else
      es_url = http.indexOf(cadena.substring(0, 7)) != - 1; // lee "http://*"
    return(es_url);
}


/* salta caracteres alfanumericos y otros a partir de  cadena[i]  y  da  si- */
/* guiente posicion                                                          */
function salta_alfanumerico(cadena, i, otros)
{
    // DECLARACION DE VARIABLES
    var j;                             // indice en cadena
    var car;                           // caracter de cadena
    var alfanum;                       // cadena[j] es alfanumerico u otros
    for(j = i, alfanum = true; (j < cadena.length) && alfanum; j++) // INICIO
      {
        car = cadena.charAt(j);
        alfanum = alfanumerico(car) || (otros.indexOf(car) != -1);
      }
    if(!alfanum)                       // lee "alfanumX"
      j--;
    return(j);
}


/* dice si car es alfanumerico */
function alfanumerico(car)
{
    return(alfabetico(car) || numerico(car));
}


/* dice si car es alfabetico */
function alfabetico(car)
{
    var alfa = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // caracteres alfabeticos
    return(alfa.indexOf(car) != - 1);  // INICIO
}


/* dice si car es numerico */
function numerico(car)
{
    var num = "0123456789";            // caracteres numericos
    return(num.indexOf(car) != - 1);   // INICIO
}


/* dice si cadena es texto no vacio o no */
function vacio(cadena)
{
    // DECLARACION DE CONSTANTES
    var blanco = " \n\t" + String.fromCharCode(13); // blancos
                                       // DECLARACION DE VARIABLES
    var i;                             // indice en cadena
    var es_vacio;                      // cadena es vacio o no
    for(i = 0, es_vacio = true; (i < cadena.length) && es_vacio; i++) // INICIO
    es_vacio = blanco.indexOf(cadena.charAt(i)) != - 1;
    return(es_vacio);
}


/* dice si cadena es un email (alfanum@alfanum.alfanum[.alfanum]) o no, don- */
/* de alfanum son caracteres alfanumericos u otros                           */
function email(cadena, otros)
{
    // DECLARACION-INICIALIZACION VARIABLES
    var i, j;                          // indice en cadena
    var es_email = 0 < cadena.length;  // cadena es email o no
    i = salta_alfanumerico(cadena, 0, otros); // INICIO
    if(es_email = 0 < i)               // lee "alfanum*"
      if(es_email = (i < cadena.length))
        if(es_email = cadena.charAt(i) == '@') // lee "alfanum@*"
          {
            i++;
            j = salta_alfanumerico(cadena, i, otros);
            if(es_email = i < j)       // lee "alfanum@alfanum*"
              if(es_email = j < cadena.length)
                if(es_email = cadena.charAt(j) == '\.')
                  {                    // lee "alfanum@alfanum.*"
                    j++;
                    i = salta_alfanumerico(cadena, j, otros);
                    if(es_email = j < i) // lee "alfanum@alfanum.alfanum*"
                      while(es_email && (i < cadena.length))
                        if(es_email = cadena.charAt(i) == '\.')
                          {
                            i++;
                            j = salta_alfanumerico(cadena, i, otros);
                            if(es_email = i < j) // lee "alfanum@alfanum.alfanum[.alfanum]*"
                              i = j;
                          }
                  }
          }
    return(es_email);
}


function ValidaCamposContacto(form)
{
    if(vacio(form.nombre.value)) {
        alert("Debe introducir su nombre.");
        form.nombre.focus();
    }
    else if(vacio(form.consulta.value) || (form.consulta.value == 'Escriba aquí su consulta')) {
        alert("Debe introducir su consulta.");
        form.consulta.focus();
    }
    else if(vacio(form.correo.value)) {
        alert("Debe introducir su dirección Email.");
        form.correo.focus();
    }
    else if(!vacio(form.correo.value) && !email(form.correo.value, "-_")) {
        alert("Dirección Email incorrecta.");
        form.correo.focus();
    }
    else
      return(true);
    return(false);
}


function ValidaCamposTrabaja(form)
{
    if(vacio(form.nombre.value)) {
        alert("Debe introducir su nombre.");
        form.nombre.focus();
    }
    else if(vacio(form.consulta.value) || (form.consulta.value == 'Escriba aquí su comentario')) {
        alert("Debe introducir su comentario.");
        form.consulta.focus();
    }
    else if(vacio(form.correo.value)) {
        alert("Debe introducir su dirección Email.");
        form.correo.focus();
    }
    else if(!vacio(form.correo.value) && !email(form.correo.value, "-_")) {
        alert("Dirección Email incorrecta.");
        form.correo.focus();
    }
    else
      return(true);
    return(false);
}


function ValidaCamposSugerencia(form)
{
    if(vacio(form.nombre.value)) {
        alert("Debe introducir su nombre.");
        form.nombre.focus();
    }
    else if(vacio(form.sugerencia.value) || (form.sugerencia.value == 'Escriba aquí su sugerencia')) {
        alert("Debe introducir su sugerencia.");
        form.sugerencia.focus();
    }
    else if(vacio(form.correo.value)) {
        alert("Debe introducir su dirección Email.");
        form.correo.focus();
    }
    else if(!vacio(form.correo.value) && !email(form.correo.value, "-_")) {
        alert("Dirección Email incorrecta.");
        form.correo.focus();
    }
    else
      return(true);
    return(false);
}


function ValidaCamposTFM(form)
{
    if(vacio(form.username.value)) {
        alert("Debe introducir su nombre de Usuario.");
        form.username.focus();
    }
    else if(vacio(form.password.value)) {
        alert("Debe introducir su Clave.");
        form.password.focus();
    }
    else
      return(true);
    return(false);
}


function viewHideMETs(id,total) {
    var targetElement,i;
    var targetElement = document.getElementById(id);

    if (targetElement.style.display == "none") {
        targetElement.style.display = "";
        document.getElementById('material').style.display = "none";
        document.getElementById('res_material').style.display = "";
    }
    else {
        targetElement.style.display = "none";
        document.getElementById('res_material').style.display = "none";
        document.getElementById('material').style.display = "";
    }

    for (i = 1; i <= total; i++)
        if (('tabla' + i) != id) document.getElementById('tabla' + i).style.display = "none";
}


function viewHideFAQs(id,total) {
    var targetElement,i;
    var targetElement = document.getElementById(id);

    if (targetElement.style.display == "none")
        targetElement.style.display = "";
    else
        targetElement.style.display = "none";

    for (i = 1; i <= total; i++)
        if (('tabla' + i) != id) document.getElementById('tabla' + i).style.display = "none";
}


function ValidaBusqueda(form) {
    if(vacio(form.buscar.value))
      form.buscar.focus();
    else
      return(true);
    return(false);
}


// Elimina el mensaje de información del txtarea para poder escribir uno nuevo
function eliminaInfo(name_form, name_txtarea, txtinfo) {
    var txtarea = eval('document.'+name_form+'.'+name_txtarea);

    if ((txtarea.value == txtinfo) && (txtarea.value.length == txtinfo.length)) {
        txtarea.value = '';
    }
}


function onhover(row) {
    row.style.backgroundColor = on;
}


function offhover(row) {
    row.style.backgroundColor = off;
}


function rollover(id) {
    on  = '#a7c4d6';
    off = '#c8d9e5';
    var table = document.getElementById(id);

    for(var i = 0; i < table.rows.length; i++) {
        table.rows[i].onmouseover = function(){onhover(this)};
        table.rows[i].onmouseout = function(){offhover(this)};
    }
}


function submenu(id,path) {
    var targetElement = document.getElementById(id);

    if (targetElement.style.display == "none") {
        document.images['sel_'+id].src = path + "/imagenes/general/sel_menos.gif";
        targetElement.style.display = "";
    } else {
        document.images['sel_'+id].src = path + "/imagenes/general/sel_mas.gif";
        targetElement.style.display = "none";
    }
}


function activa_opc(opc) {
    var targetElement = "";

    for(var i = 1; i <= 5; i++) {
        targetElement = parent.document.getElementById(i);

        if (i == opc)
            targetElement.className = "rollover_on";
        else
            targetElement.className = "rollover";
    }

    if (parent.document.getElementById('buscar').value != '' && (opc != -1))
        parent.document.getElementById('buscar').value = '';
}


function cambiaCurso(){
    var act=document.getElementById('activo').value;
    var cuan=document.getElementById('cuantos').value;
    var nombre='curso'+act;
    document.getElementById(nombre).style.display='none';
    if (act==cuan){
        act=1;
    }else{
        act++;
    }
    document.getElementById('curso'+act).style.display='block';
    var tiempo=document.getElementById('tiempo'+act).value;
    window.clearInterval(idIntervalCursos);
    idIntervalCursos=setInterval('cambiaCurso()',tiempo);
    document.getElementById('activo').value=act;
}


function cambiaBanner(){
    var act=document.getElementById('ban_activo').value;
    var cuan=document.getElementById('ban_cuantos').value;
    var nombre='banner'+act;
    document.getElementById(nombre).style.display='none';
    if (act==cuan){
        act=1;
    }else{
        act++;
    }
    document.getElementById('banner'+act).style.display='block';
    var tiempo=document.getElementById('ban_tiempo'+act).value;
    window.clearInterval(idIntervalBanners);
    idIntervalBanners=setInterval('cambiaBanner()',tiempo);
    document.getElementById('ban_activo').value=act;
}

