function objetoAjax() {
  var xmlHttp;
  try 
  {
  	xmlHttp=new XMLHttpRequest();
    return xmlHttp;
  } 
  catch (e) 
  {
		try 
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			return xmlHttp;
		} 
		catch (e) 
		{
			try 
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				return xmlHttp;
			}
			catch (e) 
			{
				alert("Tu navegador no soporta AJAX!");
				return false;
			}
		}
	}
}

function cargaPagina(_pagina,capa,variable1,variable2) {
    var ajax;
    ajax = objetoAjax();
	ajax.open("POST", _pagina, true);
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1){
			document.getElementById(capa).innerHTML = " Aguarde por favor...";
		}
		if (ajax.readyState == 4) {
			document.getElementById(capa).innerHTML=ajax.responseText; 
		}
	}
	ajax.send("variable1="+variable1+"&variable2="+variable2);
} 

function mostrarDiv(divflotante) 
{
	div = document.getElementById(divflotante);
	div.style.display = '';
}

function cerrarDiv(divflotante) 
{
	div = document.getElementById(divflotante);
	div.style.display='none';
}

function mostrarDivPagina(divflotante,_pagina,capa,variable1,variable2){
	mostrarDiv(divflotante);
	cargaPagina(_pagina,capa,variable1,variable2);
}


function mostrarCuerpo(_pagina,variable1){
	cargaPagina(_pagina,'cuerpo',variable1,'b');
}

function mostrarPage(_pagina){
	cargaPagina(_pagina,'conte','a','b');
}

function mostrarNoticias(variable1){
	cargaPagina('uva.noticia.php','cuerpo',variable1,'b');
}

function deseleccionar_todo(form){
   for (i=0;i<document.form.elements.length;i++)
      if(document.form.elements[i].type == "checkbox")
         document.form.elements[i].checked=0
} 

function seleccionar_todo(form){
   for (i=0;i<document.form.elements.length;i++)
      if(document.form.elements[i].type == "checkbox")
         document.form.elements[i].checked=1
} 

/*
Añadido por Carlos Eduardo Piñán Indacochea
*/

function cargarNoticia1(iddestino,id){
	if(document.getElementById(iddestino)!=undefined){
		var destino=document.getElementById(iddestino);	
		var ajax = objetoAjax();
		ajax.open("POST", "panelcontrol/procesos.php", true);		
		ajax.onreadystatechange = function() 		{
			if (ajax.readyState == 4) {
				destino.innerHTML=ajax.responseText; 
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	
		ajax.send("ev=5"+"&id="+id);		
	}	
}

function cargarListadoNoticiasOpc1(iddestino){
	if(document.getElementById(iddestino)!=undefined){
		var destino=document.getElementById(iddestino);	
		var ajax = objetoAjax();
		ajax.open("POST", "panelcontrol/procesos.php", true);		
		ajax.onreadystatechange = function() 		{
			if (ajax.readyState == 4) {
				destino.innerHTML=ajax.responseText; 
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	
		ajax.send("ev=8");		
	}	
}
/*
Añadido por Zoila Cumpa

*/
function open_popup(URL)
{

               my_window = window.open(URL,"mywindow","scrollbars=1,statusbar=0,menubar=0,resizable=0,fullscreen=no,location=no, width=600,height=430");
               my_window.focus();
       
}
function open_popup2(URL,X,Y)
{
               my_window = window.open(URL,"mywindow","scrollbars=1,statusbar=0,menubar=0,resizable=0,fullscreen=no,location=no, width="+X+",height="+Y);
               my_window.focus();
}
function close_popup()
{
  if(false == my_window.closed) 
  {
         my_window.close ();
  }
  else
  {
         alert('Window already closed!');
  }
}

