/*
*Esta libreria es una libreria AJAX 
*Puede ser utilizada, pasada, modificada pero no olvides mantener 
*el espiritu del software libre y respeta GNU-GPL
*/
function desaparece(){		setTimeout( "cleanmsg()",5000);}	
function ocultar(x){
	if(document.getElementById(x).style.display == 'none')
	{
		document.getElementById(x).style.display = 'block'
	}
	else
	{
		document.getElementById(x).style.display = 'none'
	}
}

function cerrar(x)
{
	document.getElementById(x).innerHTML = "";
}

function ocultar2(url,capa,valores,metodo)
{
	var capaContenedora = document.getElementById(capa);
	capaContenedora.innerHTML = "<div align='right'>[<a style='cursor:pointer' onClick="+ '"' +"RAjax('"+ url +"','" + capa + "','" + valores + "','" + metodo + "')" + '""' +">Mostrar</a>]&nbsp;&nbsp;&nbsp;&nbsp;</div>"
}
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 minirest(x)
{
	if(document.getElementById(x).style.height=="20px")
		document.getElementById(x).style.height="600px";
	else
		document.getElementById(x).style.height="20px";
}


function RAjax (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'){
		ajax.open ('POST', url , true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
				capaContenedora.innerHTML="<img src='imagenes/cargando.gif'> Cargando...";
		 	}else 
				if (ajax.readyState==4){
					if(ajax.status==200){
						capaContenedora.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 + "?" + valores, true); //	alert(url + "?" + valores);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
				capaContenedora.innerHTML="<img src='imagenes/cargando.gif'> Cargando...";
	 		}else 
				if (ajax.readyState==4){
					if(ajax.status==200){ 
			 			capaContenedora.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;
	}
}

function limpiar(x)
{
	x.value = "";
}
function limpiar_bus(x)
{
	document.getElementById('txtbusq').style.background= 'none';
}

function llena_bus()
{
	var det = document.getElementById('txtbusq');
	if(det.value=='')
	{
		det.style.background = 'url(imagenes/busq_img.gif)';
	}
}