function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  	//if (lyr && lyr.css) lyr.css.display = "block";
	if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) {
  	//lyr.css.display = "none";
	lyr.css.visibility = "hidden";
  }
}

function abrir(pagina,frame,capa) {
	
	window.frames[frame].location = pagina
	showLayer(capa);
}


function Cerrar(capa) {
	hideLayer(capa);
}

function pasafecha(dia,mes,anio) {
	
	window.open('../index2.php?nuevo_mes='+mes+'&nuevo_ano='+anio+'&dia='+dia, '_self');
	Cerrar('Layer2');
}

function pasafecha2(dia,mes,anio) {
	
	passIt = document.getElementById? parent.document.getElementById('fecha_publicacion'): document.all? parent.document.all['fecha_publicacion']: null;
	if (passIt && typeof passIt.innerHTML != "undefined" ) {

		passIt.value = anio + "-" + mes + "-" + dia;

	}
	Cerrar('Layer2');
}

function pasafecha3(dia,mes,anio) {
	
	passIt = document.getElementById? parent.document.getElementById('fecha_publicacion2'): document.all? parent.document.all['fecha_publicacion2']: null;
	if (passIt && typeof passIt.innerHTML != "undefined" ) {

		passIt.value = anio + "-" + mes + "-" + dia;

	}
	Cerrar('Layer2');
}

function buscar() {
	var el = (document.getElementById)? document.getElementById('busqueda'): (document.all)? document.all['busqueda']: (document.layers)? document.layers['busqueda']: null;
	window.open('modulosphp/buscador.php?busqueda='+el.value, '_self');
}

function buscar2() {
	var el = (document.getElementById)? document.getElementById('busqueda'): (document.all)? document.all['busqueda']: (document.layers)? document.layers['busqueda']: null;
	window.open('buscador.php?busqueda='+el.value, '_self');
}

function buscar3() {
	var el = (document.getElementById)? document.getElementById('busqueda'): (document.all)? document.all['busqueda']: (document.layers)? document.layers['busqueda']: null;
	window.open('../buscador.php?busqueda='+el.value, '_self');
}

function creaAjax(){
  var objetoAjax=false;
  try {
   /*Para navegadores distintos a internet explorer*/
   objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
     /*Para explorer*/
     objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
     } 
     catch (E) {
     objetoAjax = false;
   }
  }

  if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
   objetoAjax = new XMLHttpRequest();
  }
  return objetoAjax;
}

function FAjax (url,capa,valores,metodo)
{
   
   var ajax=creaAjax();
   var capaContenedora = document.getElementById(capa);

/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
 if(metodo.toUpperCase()=='POST'){
        document.write="hola pepe";
    ajax.open ('POST', url, true);
    ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
                 capaContenedora.innerHTML='<div align=' + '"center"' +'><img src=../images/carga2.gif>Cargando informaci&oacute;n...</div>';
         }
         else if (ajax.readyState==4){
            if(ajax.status==200)
            {
                 document.getElementById(capa).innerHTML=ajax.responseText; 
            }
            else if(ajax.status==404)
                 {

                     capaContenedora.innerHTML = "La direccion existe";
                 }
             else
                 {
                     capaContenedora.innerHTML = "Error: ".ajax.status;
                 }
        }
    }
    ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    ajax.send(valores);
    return;
}
/*Creamos y ejecutamos la instancia si el metodo elegido es GET*/
if (metodo.toUpperCase()=='GET'){

    ajax.open ('GET', url, true);
    ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
                 capaContenedora.innerHTML='<div align=' + '"center"' +'><img src=../images/carga2.gif>Cargando informaci&oacute;n...</div>';
         }
         else if (ajax.readyState==4){
            if(ajax.status==200){ 
                 document.getElementById(capa).innerHTML=ajax.responseText; 
            }
            else if(ajax.status==404)
                 {

                     capaContenedora.innerHTML = "La direccion existe";
                 }
                 else
                 {
                     capaContenedora.innerHTML = "Error: ".ajax.status;
                 }
        }
    }
    ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    ajax.send(null);
    return
}
}