// FUNCIONES: Validar fechas

//  definimos las varables globales que van a contener la fecha completa, cada una de sus partes
//  y los dias correspondientes al mes de febrero segun sea el año bisiesto o no

var a, mes, dia, anyo, febrero;
   
// funcion para comprobar si una año es bisiesto argumento anyo > año extraido de la fecha introducida por el usuario

function anyoBisiesto(anyo) {
  // si el año introducido es de dos cifras lo pasamos al periodo de 2000. Ejemplo: 25 > 2000

  if (anyo < 100)
	var fin = anyo + 2000;
  else
    var fin = anyo ;

        /*
         primera condicion: si el resto de dividir el año entre 4 no es cero > el año no es bisiesto
         es decir, obtenemos año modulo 4, teniendo que cumplirse anyo mod(4)=0 para bisiesto
        */
        
        if (fin % 4 != 0)
            return false;
        else
        {
            if (fin % 100 == 0)
            {
                /*
                 si el año es divisible por 4 y por 100 y divisible por 400 > es bisiesto
                */
                
                if (fin % 400 == 0)
                {
                    return true;
                }
                /*
                 si es divisible por 4 y por 100 pero no lo es por 400 > no es bisiesto
                */
                else
                {
                    return false;
                }
            }
            /*
             si es divisible por 4 y no es divisible por 100 > el año es bisiesto
            */
            else
            {
                return true;
            }
        }
    }
   
    // funcion principal de validacion de la fecha argumento fecha > cadena de texto de la fecha introducida por el usuario

    function validarfecha(campo) {
       // obtenemos la fecha introducida y la separamos en dia, mes y año

       	a=campo;
       	dia=a.split("-")[0];
       	mes=a.split("-")[1];
       	anyo=a.split("-")[2];

        if (campo.lenght>0) {
			if( (isNaN(dia)==true) || (isNaN(mes)==true) || (isNaN(anyo)==true) )  {
        		alert("La fecha introducida debe estar formada sólo por números");
        		return;
    		}
    	}
    
		if(anyoBisiesto(anyo))
           febrero=29;
       	else
           febrero=28;

	   	/*
        	si el mes introducido es negativo, 0 o mayor que 12 > alertamos y detenemos ejecucion
       	*/
       	if ((mes<1) || (mes>12)) {
           alert("El mes introducido no es valido. Por favor, introduzca un mes correcto");
           //document.forms[0].campo.focus();
           //document.forms[0].campo.select();
           return;
       	}

	   	/*
        	si el mes introducido es febrero y el dia es mayor que el correspondiente
        	al año introducido > alertamos y detenemos ejecucion
       	*/
	    if ((mes==2) && ((dia<1) || (dia>febrero))) {
           alert("El dia introducido no es valido. Por favor, introduzca un dia correcto");
           //document.forms[0].campo.focus();
           //document.forms[0].campo.select();
           return;
       	}

		/*
        	si el mes introducido es de 31 dias y el dia introducido es mayor de 31 > alertamos y detenemos ejecucion
       	*/

	   	if (((mes==1) || (mes==3) || (mes==5) || (mes==7) || (mes==8) || (mes==10) || (mes==12)) && ((dia<1) || (dia>31))) {
	        alert("El dia introducido no es valido. Por favor, introduzca un dia correcto");
           //document.forms[0].campo.focus();
           //document.forms[0].campo.select();
           return;
    	}

		/*
        	si el mes introducido es de 30 dias y el dia introducido es mayor de 301 > alertamos y detenemos ejecucion
       	*/
       	if (((mes==4) || (mes==6) || (mes==9) || (mes==11)) && ((dia<1) || (dia>30))) {
           alert("El dia introducido no es valido. Por favor, introduzca un dia correcto");
           //document.forms[0].campo.focus();
           //document.forms[0].campo.select();
           return;
       	}

		/*
        	si el mes año introducido es menor que 1900 o mayor que 2010 > alertamos y detenemos ejecucion
        	NOTA: estos valores son a eleccion vuestra, y no constituyen por si solos fecha erronea
       	*/
  }
// **************** FIN funciones validar fechas

// FUNCIONES: Validar URL

var re = /^(file|http):\/\/\S+\.(com|net|org|info|biz|ws|us|tv|cc|es)$/i;

function validarurl(campo) {
	/*if (!re.test(campo)) {
 		alert ("URL no valida")
		document.principal.nombreurl.select();
 		document.principal.nombreurl.focus();
 		document.principal.nombreurl.value = "";
        
 	}*/
 }
 
// **************** FIN funciones validar url

//FUNCION: Enviar formulario

function enviar() {
	alert(document.principal.attachimg.value);
	document.principal.attachimg.value='a';
	document.principal.submit();
}

// **************** FIN funciones validar url

//FUNCION: validar campos con attach llevan algo

var boton=0;

function saberboton(id) {
	boton=id;
}

function validarattch () {
	var caso = boton;
	switch(caso){
		case '1':
		    if((document.principal.userfile.value=='')) {
				alert ("No ha seleccionado ningún archivo o descripción vacía");
				return false;
		    }
			break;
		case '2':
		    if((document.principal.userimg.value=='') || (document.principal.nombreimg.value=='')) {
				alert ("No ha seleccionada ninguna imagen o descripción vacía");
				return false;
		    }
			break;
		case '3':
		    if((document.principal.nombreurl.value=='')  || (document.principal.urldesc,value='')){
				alert ("No ha seleccionada ningúna URL o descripción vacía");
			    return false;
		    }
			break;
		case '0':
			return false;
			break;
		default:
			return true;
			break;
	}
}

// *************** FIN funcion validar attch

// FUNCION rellenar campo

function buscaObj(n, d) { //v4.0
	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=buscaObj(n,d.layers[i].document);

	if(!x && document.getElementById) x=document.getElementById(n);

	return x;
}

function textoAcampo(objName,x,newText) { //v3.0
  var obj = buscaObj(objName);
  if (obj) obj.value = newText;
}

//*************** FIN rellenar campo

// FUNCION validar email

function validarmail(texto) {
  var correcto=true;
  if ((texto.indexOf("@")<1) || (texto.indexOf("@")>12))
    { alert("Lo siento. Esta dirección parece incorrecta. Compruebe el prefijo y el signo '@'.");
      correcto=false; }
  if ( (texto.indexOf(".com")<0) && (texto.indexOf(".net")<0) && (texto.indexOf(".es")<0)  &&
       (texto.indexOf(".edu")<0) && (texto.indexOf(".org")<0))
    { alert("Lo siento. Esta dirección parece incorrecta. Compruebe el sufijo.");
      correcto=false; }
  
	return;
}



// FUNCION validar CP

function validarEntero(valor){
      //intento convertir a entero.
      //si era un entero no le afecta, si no lo era lo intenta convertir
       valor = parseInt(valor)

      //Compruebo si es un valor numérico
      if (isNaN(valor)) {
         //entonces (no es numero) devuelvo el valor cadena vacia
         return ""
      }else{
         //En caso contrario (Si era un número) devuelvo el valor
         return valor
      }
}

function validarCP(valor){
   CPValido=true
   //si no tiene 5 caracteres no es válido
   if (valor.length != 5)
      CPValido=false
   else{
      for (i=0;i<5;i++){
         CActual = valor.charAt(i)
         if (validarEntero(CActual)==""){
            CPValido=false
            break;
         }
      }
   }
   if (!CPValido){
         alert ("Debe escribir un código postal válido")
         //selecciono el texto
         //document.f1.codigo.select()
         //coloco otra vez el foco
         //document.f1.codigo.focus()
      }
      return;
   }

// FUNCION habilitaDeshabilita
function habilitaDeshabilita(form) {
    if (form.miembro.checked == true) {
        alert("activo vocal");
	    form.vocal.disabled = false;
    }

    if (form.miembro.checked == false) {
        alert("desactivo vocal");
	    form.vocal.disabled = true;
    }

	if (form.vocalias.value == 0) {
	    form.vocal.disabled = true;
	    form.miembro.disabled = true;
	} else {
   	    form.miembro.disabled = false;
	    form.vocal.disabled = true;
    }
}

//*************** FIN habilitaDeshabilita

// FUNCION rellenar campo con un combo

function comboValor(objNameLee, objNameEscribe, objNameOculto)  {
	var objl = buscaObj(objNameLee);
  	var obje = buscaObj(objNameEscribe);
  	var objo = buscaObj(objNameOculto);
  
   	var myindex=objl.selectedIndex;

	if (myindex==0) {
		objl.focus();
	}else {
		obje.value = objl.options[myindex].text;
	    objo.value = objl.options[myindex].value;
		return true;
   }
}
// ************** FIN rellenar campo con un combo


// FUNCION DeshabilitarHabilitar

function DeshabilitarHabilitar(numero, capa, modo){
	for (i=1;i<=numero;i++) {
    	document.getElementById(capa+i).style.display=modo;
	}
}

// ************** FIN  DeshabilitarHabilitar


// FUNCION popUp

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=300,left = 250,top = 150');");
}

// ************** FIN popUp

// ***
function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function

/*
 * Sets/unsets the pointer and marker in vertical browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 *
 * @author Garvin Hicking <me@supergarv.de> (rewrite of setPointer.)
 */

// **
function devuelve_falso() {
	window.event.returnValue = false;
	}

if (document.all) {
  //   document.onselectstart = devuelve_falso;
}

function sombra(obj, colorF) {
	obj.style.backgroundColor = colorF;
}



// validar los campos de resgistro de usuarios
function validarPasswd () {
 var n = document.usuarios.username.value;
 var e = document.usuarios.user_email.value;
 var p1 = document.usuarios.user_password.value;
 var p2 = document.usuarios.user_password2.value;
 
 var espacios = true;
 var cont = 0;

 // Este bucle recorre la cadena para comprobar que no todo son espacios
 while (espacios && (cont < p1.length)) {
    if (p1.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
  }

  if (espacios) {
    alert ("La contraseña no puede ser todo espacios en blanco");
    return false;
  }

  if (n.length == 0) {
    alert("El campo Nick no puede quedar vacio");
    return false;
  }

  if (e.length == 0) {
    alert("El campo E-mail no puede quedar vacio");
    return false;
  }

  if (p1.length == 0 || p2.length == 0) {
    alert("Los campos de la password no pueden quedar vacios");
    return false;
  }

  if (p1 != p2) {
    alert("Las passwords deben de coincidir");
    return false;
  } else {
    alert("Todo esta correcto");
    return true;
  }
}


// validar numero entero

function validarEntero(valor){
	//intento convertir a entero.
	//si era un entero no le afecta, si no lo era lo intenta convertir
	valor = parseInt(valor.value)
	
	//Compruebo si es un valor numérico
	if (isNaN(valor)) {
		//entonces (no es un numero) devuelvo el valor cadena vacia
		alert ("El valor no es numérico");
		return false;
	}else{
		//En caso contrario (Si era un número) devuelvo el valor
		return true;
	}
}

//***

// validar los campos de resgistro de usuarios
function validarAltaUsuario() {
 var n = document.configuracion.nombre.value;
 var ap1 = document.configuracion.apellido_1.value;
 var ap2 = document.configuracion.apellido_2.value;
 var e = document.configuracion.especialidad_id.value;
 var lt = document.configuracion.l_trabajo.value;
 var ca = document.configuracion.cargo.value;
 
 var dp = document.configuracion.direccion_pro.value;
 var lp = document.configuracion.localidad_pro.value;
 var cp = document.configuracion.cp_pro.value;
 var pp = document.configuracion.provincia_pro.value;
 var pa = document.configuracion.pais_pro.value;
 var tl = document.configuracion.telefono_pro.value;
 
 var nf = document.configuracion.nif.value;

 var retorno = true;
 var espacios = true;
 var cont = 0;

 // Este bucle recorre la cadena para comprobar que no todo son espacios
 
 while (espacios && (cont < n.length)) {
    if (n.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }
 
 cont = 0;
 
 while (espacios && (cont < ap1.length)) {
    if (ap1.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }
 
 cont = 0;
 
 while (espacios && (cont < ap2.length)) {
    if (ap2.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }
 
 cont = 0;

 while (espacios && (cont < lt.length)) {
    if (lt.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }
 
 cont = 0;

 while (espacios && (cont < ca.length)) {
    if (ca.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }
 
 cont = 0;

 while (espacios && (cont < dp.length)) {
    if (dp.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }
 
  cont = 0;

 while (espacios && (cont < cp.length)) {
    if (cp.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }

  cont = 0;

 while (espacios && (cont < lp.length)) {
    if (lp.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }

  cont = 0;

 while (espacios && (cont < pa.length)) {
    if (pa.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }
 
   cont = 0;

 while (espacios && (cont < tl.length)) {
    if (tl.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }
 
 cont = 0;
 
 while (espacios && (cont < nf.length)) {
    if (nf.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }
 
  if (espacios) {
    alert ("No se puede dejar en blanco los campos.");
    retorno = false;
  }

  if (e == 0) {
    alert("El campo Especialidad no puede quedar vacio");
	retorno = false;
  }
  
  if (pp == 0) {
    alert("El campo Provincia no puede quedar vacio");
    retorno = false;
  }

  if (n.length == 0) {
    alert("El campo Nombre no puede quedar vacio");
    retorno = false;
  }

  if (ap1.length == 0) {
    alert("El campo Apellido 1 no puede quedar vacio");
    retorno = false;
  }
  
  if (ap2.length == 0) {
    alert("El campo Apellido 2 no puede quedar vacio");
    retorno = false;
  }
  
  if (lt.length == 0) {
    alert("El campo Lugar de trabajo no puede quedar vacio");
    retorno = false;
  }

  if (ca.length == 0) {
    alert("El campo Cargo no puede quedar vacio");
    retorno = false;
  }

  if (dp.length == 0) {
    alert("El campo Dirección no puede quedar vacio");
    retorno = false;
  }

  if (lp.length == 0) {
    alert("El campo Localidad no puede quedar vacio");
    retorno = false;
  }

  if (cp.length == 0) {
    alert("El campo Codigo Postal no puede quedar vacio");
    retorno = false;
  }

  if (pa.length == 0) {
    alert("El campo País no puede quedar vacio");
    retorno = false;
  }

  if (tl.length == 0) {
    alert("El campo Teléfono no puede quedar vacio");
    retorno = false;
  }
  
  if (nf.length == 0) {
    alert("El campo NIF no puede quedar vacio");
    retorno = false;
  }

  
    return retorno;
}

// funcion flash
function CrearFlash(ruta){
	var entrar = confirm('¿Desea crear un flash de esta noticia?')
	if (entrar) window.location=ruta;
}


function obtenerDigito(valor){
  valores = new Array(1, 2, 4, 8, 5, 10, 9, 7, 3, 6);
  control = 0;
  for (i=0; i<=9; i++)
    control += parseInt(valor.charAt(i)) * valores[i];
  control = 11 - (control % 11);
  if (control == 11) control = 0;
  else if (control == 10) control = 1;
  return control;
}

function numerico(valor){
  cad = valor.toString();
  for (var i=0; i<cad.length; i++) {
    var caracter = cad.charAt(i);
	if (caracter<"0" || caracter>"9")
	  return false;
  }
  return true;
}

// validar los campos de domiciliar
function Domiciliar() {
 var b = document.domiciliar.banco.value;
 var s = document.domiciliar.sucursal.value;
 var po = document.domiciliar.poblacionb.value;
 var pr = document.domiciliar.provinciab.value;
 var cp = document.domiciliar.cpb.value;
 
 var c1= document.domiciliar.cc1.value
 var c2= document.domiciliar.cc2.value
 var c3= document.domiciliar.cc3.value
 var c4= document.domiciliar.cc4.value
 
 var retorno = true;
 var espacios = true;
 var cont = 0;

 // Este bucle recorre la cadena para comprobar que no todo son espacios

 while (espacios && (cont < b.length)) {
    if (b.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }

 cont = 0;

 while (espacios && (cont < s.length)) {
    if (s.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }

 cont = 0;

 while (espacios && (cont < po.length)) {
    if (po.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }

 cont = 0;

 while (espacios && (cont < pr.length)) {
    if (pr.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }

 cont = 0;

 while (espacios && (cont < cp.length)) {
    if (cp.charAt(cont) != " ") {
      espacios = false;
    }
    cont++;
 }

 cont = 0;


  if (espacios) {
    alert ("No se puede dejar en blanco los campos.");
    retorno = false;
  }

  if (b.length == 0) {
    alert("El campo Banco no puede quedar vacio");
    retorno = false;
  }

  if (s.length == 0) {
    alert("El campo Sucursal no puede quedar vacio");
    retorno = false;
  }

  if (po.length == 0) {
    alert("El campo Población no puede quedar vacio");
    retorno = false;
  }

  if (pr.length == 0) {
    alert("El campo Provincia no puede quedar vacio");
    retorno = false;
  }

  if (cp.length == 0) {
    alert("El campo C.P. no puede quedar vacio");
    retorno = false;
  }
  
  // validar CCC
  
  if (c1 == ""  || c2 == "" || c3 == "" || c4 == "") {
  		alert("Por favor, introduzca los datos de su cuenta");
  		retorno = false;
  }else {
  		if (c1.length != 4 || c2.length != 4 || c3.length != 2 || c4.length != 10) {
      		 alert("Por favor, introduzca correctamente los datos de su cuenta no están completos");
      		 retorno = false;
	    }else {
    		 if (!numerico(c1) || !numerico(c2) || !numerico(c3) || !numerico(c4)) {
        		alert("Por favor, introduzca correctamente los datos de su cuenta no son numericos");
        		retorno = false;
      		}else {
        		if (!(obtenerDigito("00" + c1 + c2) == parseInt(c3.charAt(0))) || !(obtenerDigito(c4) == parseInt(c3.charAt(1)))) {
          			alert("Los dígitos de control no se corresponden con los demás números de la cuenta");
          			retorno = false;
	    		}else{
          			retorno = true;
	    		}
      		}
    	}
  }
     return retorno;
}




// abrir ventana


function nuevaVentana(imagen, tabla) {
    ventana=window.open(' ','NuevaVentana','width=400,height=300');
    ventana.opener=self;
    ventana.document.write("<html><head>\n<script>function refrescar(){\n self.close(); \n }</script>\n</head><body>\n<center>\n<font size=2 face=arial>Escriba la nueva descripci&oacute;n para la imagen</font><br><br>\n");
    ventana.document.write("<img src=almacen/" + imagen + " width='90' height='90'><br><br>\n");
    ventana.document.write("<FORM NAME='notas' method=post action='modules.php?name=miscelanea&op=img'>\n");
    ventana.document.write("<input type=hidden name='tabla' value='"+ tabla +"'>\n");
    ventana.document.write("<input type=hidden name='imagen' value='"+ imagen +"'>\n");
    ventana.document.write("<input type=text name='des' size=40><br><br>\n");
    ventana.document.write("<INPUT TYPE='submit' VALUE='Actualizar'>&nbsp;<input type=button value='Cerrar' onclick=refrescar()><br><br>\n");
    ventana.document.write("<font size=2 face=arial>La modificaci&oacute;n se ver&aacute; reflejada al refrescar la p&aacute;gina</font>\n");
    ventana.document.write("</FORM></center>\n");
    ventana.document.write("</body></html>\n");
             
    ventana.document.close();
}
          
function nuevaVentanaURL(url, tabla) {
    ventana=window.open(' ','NuevaVentana','width=400,height=200');
    ventana.opener=self;
    ventana.document.write("<html><head>\n<script>function refrescar(){\n self.close(); \n }</script>\n</head><body>\n<center>\n<font size=2 face=arial>Escriba la nueva descripci&oacute;n para la URL</font><br><br>\n");
    ventana.document.write("<b>" + url + "</b><br><br>\n");
    ventana.document.write("<FORM NAME='notas' method=post action='modules.php?name=miscelanea&op=url'>\n");
    ventana.document.write("<input type=hidden name='tabla' value='"+ tabla +"'>\n");
    ventana.document.write("<input type=hidden name='local' value='"+ url +"'>\n");
    ventana.document.write("<input type=text name='des' size=40><br><br>\n");
    ventana.document.write("<INPUT TYPE='submit' VALUE='Actualizar'>&nbsp;<input type=button value='Cerrar' onclick=refrescar()><br><br>\n");
    ventana.document.write("<font size=2 face=arial>La modificaci&oacute;n se ver&aacute; reflejada al refrescar la p&aacute;gina</font>\n");
	ventana.document.write("</FORM></center>\n");
    ventana.document.write("</body></html>\n");

    ventana.document.close();
}

function nuevaVentanaARC(arc, tabla) {
    ventana=window.open(' ','NuevaVentana','width=400,height=200');
    ventana.opener=self;
    ventana.document.write("<html><head>\n<script type='text/javascript'>function refrescar(){\n self.close(); \n }</script>\n</head><body>\n<center>\n<font size=2 face=arial>Escriba la nueva descripci&oacute;n para el Archivo</font><br><br>\n");
    ventana.document.write("<b>" + arc + "</b><br /><br />\n");
    ventana.document.write("<FORM NAME='notas' method='post' action='modules.php?name=miscelanea&op=arc'>\n");
    ventana.document.write("<input type='hidden' name='tabla' value='"+ tabla +"' />\n");
    ventana.document.write("<input type='hidden' name='nombre' value='"+ arc +"' />\n");
    ventana.document.write("<input type='text' name='des' size=40 /><br /><br />\n");
    ventana.document.write("<INPUT TYPE='submit' VALUE='Actualizar'>&nbsp;<input type=button value='Cerrar' onclick='refrescar()'><br/><br/>\n");
    ventana.document.write("<p class='texto_noticia'>La modificaci&oacute;n se ver&aacute; reflejada al refrescar la p&aacute;gina</p>\n");
	ventana.document.write("</FORM></center>\n");
    ventana.document.write("</body></html>\n");

    ventana.document.close();
}

function abrir(direccion, pantallacompleta, herramientas, direcciones, estado, barramenu, barrascroll, cambiatamano, ancho, alto, sustituir){
    var izquierda = (screen.availWidth - ancho) / 2;
    var arriba = (screen.availHeight - alto) / 2;
    var opciones = "fullscreen=" + pantallacompleta +
                 ",toolbar=" + herramientas +
                 ",location=" + direcciones +
                 ",status=" + estado +
                 ",menubar=" + barramenu +
                 ",scrollbars=" + barrascroll +
                 ",resizable=" + cambiatamano +
                 ",width=" + ancho +
                 ",height=" + alto +
                 ",left=" + izquierda +
                 ",top=" + arriba;
    var ventana = window.open(direccion,"ventana",opciones,sustituir);
}

