function validar(url,divi,cadena)
{ 
  if(document.getElementById("usuario").value.length=="") 
	{
		alert("Debe Introducir su Usuario");
		document.getElementById("usuario").focus();
	} 
	else if(document.getElementById("clave").value.length=="")
	{ 
	  alert("Debe Introducir su Clave");
	  document.getElementById("clave").focus();
	}
	else
	{
     var  datos = cadena;
     var divi="#"+divi;
     $.ajax
     (
     {
  	    async:true,
  	    url: url,
  	    type: 'POST',
  	    dataType: 'html',
  	    data: datos,	
  	    cache: false,
  	    success: function(respuesta)
  	    {
         $(divi).html(respuesta);
  	    }
     }
     );
   }
}	 

function ir(fo)
{
  if(document.getElementById("usuario").value.length=="") 
	{
		alert("Debe Introducir su Usuario");
		document.getElementById("usuario").focus();
		return(false);
	} 
	else if(document.getElementById("clave").value.length=="")
	{ 
	  alert("Debe Introducir su Clave");
	  document.getElementById("clave").focus();
	  return(false);
	}
	else
	{
	  //document.us.submit();
	  return(true); 
	}
}

function salir()
{
  window.close();
}

var micierre = false;
var fue_unload = false;
var even = null; 
 
function ConfirmarCierre()
{
    if (window.ActiveXObject){ //para evento en iexplore
        if (event.clientY < 0){ 
            setTimeout('micierre = false', 100);
            micierre = true; 
         }
    } 
    else if (window.XMLHttpRequest){
        //alert ('estamos en firefox'); 
        if(!even){ 
            setTimeout('micierre = false', 100);
            micierre = true;
        } 
        else fue_unload = true;
    } 
} 

function ManejadorCierre()
{ 
    if (micierre == true){
        //alert ('llamo a startRequest');
     var div="respuesta";      
     var  datos = "hola"; 
     var div="#"+div;
     var url="terminar"; 
     $.ajax 
     (
     { 
  	    async:true, 
  	    url: url,
  	    type: 'POST',
  	    dataType: 'html',
  	    data: datos,	
  	    cache: false,
  	    success: function(respuesta)
  	    {
         $(div).html(respuesta);
  	    }
     } 
     ); 
    } 
}

function valor()
{
  var publi=document.getElementById('publicado').checked;
  if(publi)
  {
    document.getElementById('publicado').value=1;
  }
  else
  {
    document.getElementById('publicado').value=0; 
  } 
}

function valor2()
{
  var pri=document.getElementById('principal').checked;
  if(pri)
  {
    document.getElementById('principal').value=1;
    document.getElementById('posicion').disabled=true;  
  }
  else
  {
    document.getElementById('principal').value=0; 
    document.getElementById('posicion').disabled=false; 
  } 
}

function ven(url)  
{  
  var opcionescur="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=750, height=400, top=10, left=10";              
  ventana=window.open(url,"",opcionescur);
}

function saltar(url,divi)
{
   var  datos ="";
   var div="#"+div;
     $.ajax
     (
     {
  	    async:true,
  	    url: url,
  	    type: 'POST',
  	    dataType: 'html',
  	    data: datos,	
  	    cache: false,
  	    success:function llegada(msg)
       { 
         window.opener.document.getElementById(divi).innerHTML=msg;   
         window.close();
         window.opener.setTimeout('location.reload()',100);  
       }
     }
     );
}

function editarizquierda(url,divi,noti) 
{
     var divi="#"+divi; 
     var datos=noti;  
     $.ajax
     (
     {
  	    async:true,
  	    url: url,
  	    type: 'POST',
  	    dataType: 'html',
  	    data: datos,	
  	    cache: false,
  	    success:function(respuesta)
  	    { 
         $(divi).html(respuesta);
  	    }
     }
     );
}

function noticia(divi,url,noti)
{
     var divi="#"+divi; 
     var datos=noti;  
     $.ajax
     (
     {
  	    async:true,
  	    url: url,
  	    type: 'POST',
  	    dataType: 'html',
  	    data: datos,	
  	    cache: false,
  	    success:function(respuesta)
  	    { 
         $(divi).html(respuesta);
  	    }
     }
     );
}

function galeria(url,divi)  
{ 
  var divi="#"+divi; 
  $(document).ready(function()
  { 
    $("div#"+divi).hide().load(url).fadeIn("slow");   
  });  
} 

function gallery(url,divi)
{
     var divi="#"+divi;
     nombre=document.getElementById('galeri').value; 
     var datos="nom="+nombre;  
     if(nombre=="")
     {
       alert("Debe introducir un nombre para la galeria"); 
     }
     else
     {  
       $.ajax
       (
       {
  	    async:true,
  	    url: url,
  	    type: 'POST',
  	    dataType: 'html',
  	    data: datos,	
  	    cache: false,
  	    success:function(respuesta)
  	    { 
         $(divi).html(respuesta);
  	    }
       }
       );
    }
}

function funcion() 
{  
  var ojo=0; 
  var ext=0; 
  var opci=0; 
  ojo=document.getElementById('archi').value;  
  opci=ojo.lastIndexOf(".");
  ext=ojo.substr(opci+1,3); 
  var dispo="jpg,gif,png,bmp,jpeg";
  if(ext=="jpg" || ext=="gif" || ext=="png" || ext=="bmp" || ext=="jpeg" || ext=="JPG" || ext=="JPEG" ||ext=="GIF" || ext=="PNG" || ext=="BMP")
  /*if(ext=="GIF" || ext=="gif")*/ 
	{ 
	  document.getElementById('envia').style.visibility='hidden';
	  document.getElementById('descri').style.visibility='hidden';
	  document.getElementById('archivos').style.visibility='hidden';
	  document.getElementById('texto').style.visibility='hidden'; 
	  document.getElementById('texto1').style.visibility='hidden';
     document.getElementById('texto2').style.visibility='hidden';
	  document.getElementById('posici').style.visibility='hidden'; 
     document.getElementById('lim').style.visibility='visible';
	  return (true); 
   } 
	else
	{ 
	  alert ("Solo se pueden cargar archivos con extension "+dispo);  
	  document.formu.reset(); 
	  return (false);
	}	 
} 

function limpia()
{
    document.formu.reset();
    document.getElementById('envia').style.visibility='visible';
    document.getElementById('descri').style.visibility='visible';
	 document.getElementById('archivos').style.visibility='visible'; 
	 document.getElementById('texto').style.visibility='visible';
	 document.getElementById('texto1').style.visibility='visible';
	 document.getElementById('texto2').style.visibility='visible';
	  document.getElementById('posici').style.visibility='visible';
    document.getElementById('lim').style.visibility='hidden';
}

function eliminar(url,divi,gale) 
{
     var pregunta=confirm("¿Realmente desea eliminar la imagen?");
     if(pregunta)
     {
       var divi="#"+divi;
       var nom=document.getElementById('nom').value;
       var datos="gale="+gale+"&"+"nom="+nom;      
       $.ajax
       (
       {
  	      async:true,
  	      url: url,
  	      type: 'POST',
  	      dataType: 'html',
  	      data: datos,	
  	      cache: false,
  	      success:function(respuesta)
  	      { 
           $(divi).html(respuesta);
  	      }
       }
       );
     }  
}

function eli(url,divi,gale,nom)  
{
     var pregunta=confirm("¿Realmente desea eliminar la imagen?");
     if(pregunta)
     {
       var divi="#"+divi;
       var datos="gale="+gale+"&"+"nom="+nom;        
       $.ajax
       (
       {
  	      async:true,
  	      url: url,
  	      type: 'POST',
  	      dataType: 'html',
  	      data: datos,	
  	      cache: false,
  	      success:function(respuesta)
  	      { 
           $(divi).html(respuesta);
  	      }
       }
       );
     }  
}

function descri(url,divi) 
{
     var divi="#"+divi;
     var galeria=document.getElementById('gale').value;
     var descripcion=document.getElementById('descripcion').value; 
     var posicion=document.getElementById('posici').value;
     var datos="galeria="+galeria+"&"+"descripcion="+descripcion+"&"+"posicion="+posicion;      
     $.ajax
     (
     {
  	    async:true,
  	    url: url,
  	    type: 'POST',
  	    dataType: 'html',
  	    data: datos,	
  	    cache: false,
  	    success:function(respuesta)
  	    { 
         $(divi).html(respuesta);
  	    }
     }
     );
}

function descripcion(url,divi,cadena)
{
  var datos=cadena;
  var divi="#"+divi;
  $.ajax
     (
     {
  	    async:true,
  	    url: url,
  	    type: 'POST',
  	    dataType: 'html',
  	    data: datos,	
  	    cache: false,
  	    success:function(respuesta)
  	    { 
         $(divi).html(respuesta);
  	    }
     }
     );
}

function venta(url)  
{  
  var opcionescur="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=450, height=200, top=350, left=350";              
  ventana=window.open(url,"",opcionescur);
}

function imprimir(que,que2,que3,que4) 
{ 
  var ventana = window.open("","","");
  var conatel="COMISION NACIONAL DE TELECOMUNICACIONES | www.conatel.gob.ve";
  var contenido = "<html><body onload='window.print();window.close();'>";
  contenido = document.getElementById(que3).innerHTML + conatel + contenido + document.getElementById(que).innerHTML + document.getElementById(que2).innerHTML +"</body></html>"; 
  ventana.document.open();  
  ventana.document.write(contenido);
  ventana.document.close();
}

function viernes(url,gale,divi)
{
  var divi="#"+divi;
  var datos="galeria="+gale;        
  $.ajax
  (
  {
    async:true,
    url: url,
    type: 'POST',
    dataType: 'html',
    data: datos,	
    cache: false,
    success:function(respuesta)
    { 
      $(divi).html(respuesta);
    }
  }
  );
}

function validar_busqueda(url,divi)
/*function validar_busqueda()*/
{
	if((document.getElementById('fecha1').value=="" && document.getElementById('fecha2').value!="") || (document.getElementById('fecha2').value=="" && document.getElementById('fecha1').value!=""))
	{
		alert("Estimado Usuario:\nPara realizar búsqueda por fechas, debe especificar ambas fechas del intervalo deseado.");	
	} 
	else if(document.getElementById('fecha1').value=="" && document.getElementById('fecha2').value=="" && document.getElementById('busc').value=="")
	{
	  alert("Debe agregar algun criterio de busqueda");
	}
	else 
	{
	  /*document.getElementById('uno').value=document.getElementById('desde').value;  
	  document.getElementById('dos').value=document.getElementById('hasta').value;  
	  document.getElementById('tres').value=document.getElementById('busc').value;  
	  document.getElementById('cuatro').value=document.getElementById('reg_totales').value;  
	  document.bus.submit();*/
		
		var divi="#"+divi;
		var fecha1=document.getElementById('fecha1').value;
		var fecha2=document.getElementById('fecha2').value;
		var palabra=document.getElementById('busc').value; 
		var cantidad=document.getElementById('reg_totales').value;
		
      var datos="fecha1="+fecha1+"&"+"fecha2="+fecha2+"&"+"palabra="+palabra+"&"+"cantidad="+cantidad; 
             
      $.ajax 
      (
      { 
        async:true,
        url: url,
        type: 'POST',
        dataType: 'html',
        data: datos,	 
        cache: false,
        success:function(respuesta)
        {  
          $(divi).html(respuesta);
        }
      } 
      );
   }
}

function busqueda_edicion(url,divi)
/*function validar_busqueda()*/
{
	if(document.getElementById('busc').value=="")
	{
	  alert("Debe ingresar una palabra para realizar la busqueda");
	}
	else 
	{
	   var divi="#"+divi;
		var palabra=document.getElementById('busc').value; 
		var cantidad=document.getElementById('reg_totales').value;
		
      var datos="palabra="+palabra+"&"+"cantidad="+cantidad; 
             
      $.ajax 
      (
      { 
        async:true,
        url: url,
        type: 'POST',
        dataType: 'html',
        data: datos,	 
        cache: false,
        success:function(respuesta)
        {  
          $(divi).html(respuesta);
        }
      } 
      );
   }
}

function radio()
{
  document.getElementById('reg_totales').value=5;
}

function radio2()
{
  document.getElementById('reg_totales').value=10;
}

function radio3()
{
  document.getElementById('reg_totales').value=15; 
}

function prueba(url,divi,cadena)
{
  var divi="#"+divi;
  var datos=cadena; 
             
      $.ajax 
      (
      { 
        async:true,
        url: url,
        type: 'POST',
        dataType: 'html',
        data: datos,	 
        cache: false,
        success:function(respuesta)
        {  
          $(divi).html(respuesta);
        }
      } 
      );
}

function cambiando()
{
   window.close();
   window.opener.setTimeout('location.reload()',100);  
}
