var xmlHttp

function toggleLayer(whichLayer){  
var elem, vis;  
if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;  
// if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
function toggleLayerDiv(whichLayer,divRef){  
var elem, vis;
var d = document.getElementById(divRef);
var posY = parseInt(d.offsetTop);
posY = posY + 500;
var posX = parseInt(document.body.offsetWidth);
if (posX < 900)
	posX = 15;
else
	posX = (posX / 2) - 450;


if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;  
// if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  	vis.top = posY + "px";
	vis.left = posX + "px";
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';

}
function colocarDiv(id,divRef){
	var k = document.getElementById(id);
	var d = document.getElementById(divRef);
	var posY = parseInt(d.offsetTop);
	var posX = parseInt(document.body.offsetWidth/4);
	if(posY>250) {
		posY = 200;
		k.style.width = posX*2;
	}
	else {
		posY = parseInt(d.offsetTop) + 21;
		posX = d.offsetLeft;
		k.style.width = "900px";
	}
	k.style.top = posY + "px";
	k.style.left = posX + "px";
	k.style.display = "block";
}

function hideLayer( whichLayer ){  
var elem, vis;  
if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;  

	vis.display = 'none';
}

function showLayer( whichLayer ){  
var elem, vis;  
if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;  

	vis.display = 'block';
}
/*
*Esta libreria es una libreria AJAX creada por Javier Mellado con la inestimable
*colaboracion de Beatriz Gonzalez.
*y descargada del portal AJAX Hispano http://www.ajaxhispano.com
*contacto javiermellado@gmail.com
*
*Puede ser utilizada, pasada, modificada pero no olvides mantener
*el espiritu del software libre y respeta GNU-GPL
*/

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'){
         ajax.open ('POST', url, true);
         ajax.onreadystatechange = function() {
         if (ajax.readyState==1) {
                          capaContenedora.innerHTML="Cargando.......";
         }
         else if (ajax.readyState==4){
                   if(ajax.status==200)
                   {
                        document.getElementById(capa).innerHTML=ajax.responseText;
                   }
                   else if(ajax.status==404)
                                             {

                            capaContenedora.innerHTML = "La direccion no 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="Cargando.......";
         }
         else if (ajax.readyState==4){
                   if(ajax.status==200){
                                             document.getElementById(capa).innerHTML=ajax.responseText;
                   }
                   else if(ajax.status==404)
                                             {

                            capaContenedora.innerHTML = "La direccion no existe";
                                             }
                                             else
                                             {
                            capaContenedora.innerHTML = "Error: ".ajax.status;
                                             }
                                    }
                  }
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         ajax.send(null);
         return
}
} 

function getDoc(str1, str2, doFunc, id) {
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!"); 
  return;
  } 
    //xmlhttp=new XMLHttpRequest()
var url="msgEst.asp";
url=url+"?tt="+str1;
url=url+"&ttd="+str2;
url=url+"&sID="+Math.random();

    xmlHttp.onreadystatechange= function() { 
        if (xmlHttp.readyState==4)
            if (xmlHttp.status==200)
                doFunc(xmlHttp, id);
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function getURL(str1, doFunc, id) {
	//toggleLayer(id);
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null) {
  alert ("Your browser does not support AJAX!"); 
  return;
  } 
    //xmlhttp=new XMLHttpRequest()
var url=str1;

//values=getValues(str1);
//var impresion = unescape(values["impresion"]);
//var ver = unescape(values["ver"]);
//var numrep = unescape(values["numrep"]);

url=url+"&sID="+Math.random();
    xmlHttp.onreadystatechange= function() { 
        if (xmlHttp.readyState==4)
            if (xmlHttp.status==200)
                doFunc(xmlHttp, id);
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

function writeHTML(req, id) {
	var k = document.getElementById(id);
	//toggleLayer(id);
	k.innerHTML = req.responseText;
}


function GetXmlHttpObject() {
var xmlHttp=null;
try {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e) {
  // Internet Explorer
  try {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e) {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}