// JavaScript Document
// ****************** seccion AJAX  ***********************
function handleHttpResponse() {
    if (http.readyState == 4) {
       if (http.status == 200) {
//          if (http.responseText.indexOf('invalid') == -1) {
             // Armamos un array, usando la coma para separar elementos
             results = unescape(http.responseText);
			 cadenafinal=results.replace(/\+/gi," ")
			 document.getElementById(IDobj).innerHTML = cadenafinal;
             enProceso = false;
//          }
       }
    }
}

function getHTTPObject()
{
  var xmlhttp;
  if (!xmlhttp)
  {
   
	if(window.XMLHttpRequest)
	{
			try
			{
				xmlhttp = new XMLHttpRequest();
			}
			catch(e)
			{
					alert("mensaje error 1.1")
					xmlhttp = false;
			}
// branch for IE/Windows ActiveX version
	}
	else if(window.ActiveXObject)
	{
			   try
			   {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			  }
			  catch(e)
			  {
				try
				{
				  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch(e)
				{
				alert("mensaje de error 1.2")
				  xmlhttp = false;
				}
			}
	}
	   
 }
return xmlhttp;
}
//*********************** FIN SECCION AJAX ***************************
//********************************************************************

//*********************** FUNCIONES GENERALES ************************
function busca_noticias() {  //BUSCADOR DE NOTICIAS
    if (!enProceso && http) {
	   var opc="";
	   var ord="";
	   var cad="";
	   var rand_no = Math.random();
	   rand_no=0;
	   Obj="seccion_noticias";
	   objTmp=Obj;
	   if (document.frm_buscanoti.chk_titulos.checked) {
	   	opc=opc + "Titulo";
		}
	   if (document.frm_buscanoti.chk_noticias.checked) {
	   	opc=opc + " Nota";
		}
	   if (!(opc == "")){
		   IDobj=Obj;
		   param= document.frm_buscanoti.txt_busca.value;
		   if (param !=""){
			   cad=document.frm_buscanoti.txt_busca.value;
			   if (cad.length > 2){
	//			   document.getElementById(Obj).innerHTML ="Buscando...";
				   document.getElementById(Obj).innerHTML ="<div align='center'><span>Buscando... <img src='grafs/wait.gif' /></span></div>";
				   var valor = escape(document.getElementById(Obj).value);
				   var url = "aspbusqueda.asp?txtBusca=" + document.frm_buscanoti.txt_busca.value + "&oDonde=" + opc + "&NH12=" + rand_no;
				   CadUltSec=url;
				   http.open("GET", url, true);
				   http.onreadystatechange = handleHttpResponse;
				   enProceso = true;
				   http.send(null);
			   }else{
				   alert("Debe ingresar por lo menos 3 caracteres a buscar");
			   };
			} else {
				alert("Debe Ingresar un texto a buscar.")
			};
	   } else {
			alert("Debe seleccionar una opción de búsqueda.")
	   };
    };
};

function ver_noticia(ID){
	window.open ("preview_diag.asp?ID=" + ID + "&TAM=700","Noticia","width=750,height=500;toolbar=0,menubar=0,resizable=1,scrollbars=1").focus();
};
//function busca_noticias(){
//	document.getElementById("seccion_noticias").innerHTML="Buscando";
//};
//********************* SECCION VARIABLES *********************
var objTmp
var IDobj="";
var enProceso = false; // lo usamos para ver si hay un proceso activo
var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest

	