function nuevoAjax(){
	var xmlhttp=false;
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch(E){
			xmlhttp = false;
		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	
	return xmlhttp;
}

function contenido_catego(categoria, seccion){
	resul = document.getElementById('resulta');
	ajax=nuevoAjax();
	ajax.open("POST", "../congadmin/publish/funciones/funajax.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("op=1&categoria="+categoria+"&seccion="+seccion);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			resul.innerHTML=ajax.responseText;
		}
	}
}


function buscatego(seccion){
	dato = document.getElementById('describe');
	resul = document.getElementById('resulta');
	ajax=nuevoAjax();
	ajax.open("POST", "../congadmin/publish/funciones/funajax.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("op=2&texto="+dato.value+"&seccion="+seccion);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			resul.innerHTML=ajax.responseText;
		}
	}
}

function cancelar(){
	self.location="?#categorias";
}



function busca_sesion(){

//	alert("Algo");	
	anoxx=document.getElementById('anosele');
	peri=document.getElementById('periodo');
	resul = document.getElementById('resulta');
//	alert(anoxx.value+" Periodo "+peri.value);
	ajax=nuevoAjax();
	ajax.open("POST", "../congadmin/publish/funciones/funajax.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("op=3&ano="+anoxx.value+"&periodo="+peri.value);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			resul.innerHTML=ajax.responseText;
		}
	}
}


function busca_comision(){
	anoxx=document.getElementById('anosele');
	peri=document.getElementById('periodo');
	resul = document.getElementById('resulta');
//	alert(anoxx.value+" Periodo "+peri.value);
	ajax=nuevoAjax();
	ajax.open("POST", "../congadmin/publish/funciones/funajax.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("op=4&ano="+anoxx.value+"&periodo="+peri.value);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			resul.innerHTML=ajax.responseText;
		}
	}
}


function busca_acuerdos(){
	anoxx=document.getElementById('anosele');
	peri=document.getElementById('periodo');
	resul = document.getElementById('resulta');
//	alert(anoxx.value+" Periodo "+peri.value);
	ajax=nuevoAjax();
	ajax.open("POST", "../congadmin/publish/funciones/funajax.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("op=5&ano="+anoxx.value+"&periodo="+peri.value);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			resul.innerHTML=ajax.responseText;
		}
	}
}

function busca_decyley(){
	anoxx=document.getElementById('anosele');
	peri=document.getElementById('periodo');
	resul = document.getElementById('resulta');
//	alert(anoxx.value+" Periodo "+peri.value);
	ajax=nuevoAjax();
	ajax.open("POST", "../congadmin/publish/funciones/funajax.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("op=6&ano="+anoxx.value+"&periodo="+peri.value);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			resul.innerHTML=ajax.responseText;
		}
	}
}


function contenido_inicias(categoria, seccion){
	resul = document.getElementById('resulta');
	ajax=nuevoAjax();
	ajax.open("POST", "../congadmin/publish/funciones/funajax.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("op=7&categoria="+categoria+"&seccion="+seccion);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			resul.innerHTML=ajax.responseText;
		}
	}
}


function busca_inisdir(){
	envisxx=document.getElementById('envi');
	stast=document.getElementById('stat');
	categos=document.getElementById('catego');
	seccio=document.getElementById('secci');
	resul = document.getElementById('resultainis');
//	alert(envisxx.value+" y el estatus es "+stast.value)
	ajax=nuevoAjax();
	ajax.open("POST", "../congadmin/publish/funciones/funajax.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("op=8&enviada="+envisxx.value+"&status="+stast.value+"&seccion="+seccio.value+"&categoria="+categos.value);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			resul.innerHTML=ajax.responseText;
		}
	}
}

var pagina=1;
var total=3;


function siguiente(){
	resul = document.getElementById('boles');
//	alert(envisxx.value+" y el estatus es "+stast.value)
	pagina=pagina+1;
	if(pagina>total) {
		pagina=1;
	}
	ajax=nuevoAjax();
	ajax.open("POST", "../congadmin/publish/funciones/funajax2.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("op=1&cual="+pagina);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			resul.innerHTML=ajax.responseText;
		}
	}
	document.getElementById('paginas').innerHTML=pagina+"/"+total;
}

function anterior(){
	resul = document.getElementById('boles');
//	alert(envisxx.value+" y el estatus es "+stast.value)
	pagina=pagina-1;
	if(pagina<=0) {
		pagina=total;
	}
	ajax=nuevoAjax();
	ajax.open("POST", "../congadmin/publish/funciones/funajax2.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("op=1&cual="+pagina);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			resul.innerHTML=ajax.responseText;
		}
	}
	document.getElementById('paginas').innerHTML=pagina+"/"+total;
}


function vota(){
	var valor=valida();
	if(valor!=0){
		resul = document.getElementById('encuesta');
		ajax=nuevoAjax();
		ajax.open("POST", "../congadmin/publish/funciones/funajax2.php",true);
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send("op=2&item="+valor);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				resul.innerHTML=ajax.responseText;
			}
		}
	}
}

var autor;
var comenta;
var foro;
var correo;

function comentario(){
	autor=document.getElementById('autorid').value;
	comenta=document.getElementById('comentaid').value;
	foro=document.getElementById('foroid').value;
	correo=document.getElementById('mailid').value;
	if(comenta.length>=1000){
		alert("El limite de caracteres es de 1000")	
	}else{
		ajax=nuevoAjax();
		ajax.open("POST", "../congadmin/publish/funciones/funajax2.php",true);
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
//		alert(comenta);
		ajax.send("op=3&autor="+autor+"&comenta="+comenta+"&foro="+foro+"&correo="+correo);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				resul.innerHTML=ajax.responseText;
			}
		}
		alert("Tu comentario ha sido enviado, gracias");
		document.getElementById('autorid').value="";
		document.getElementById('comentaid').value="";
		document.getElementById('mailid').value="";
	}
}

function caracteres(){
	comenta=document.getElementById('comentaid');
	if(comenta.value.length>=1000){
		alert("El limite de caracteres es de 1000")	
	}
}

function valida() {
    var valor= 0;
	var total=document.radioForm.opcionen.length;
	for(i=0;i<total;i++){
        if (eval("document.radioForm.opcionen["+i+"].checked") == true)
		{
			valor=document.radioForm.opcionen[i].value;
		}
	}
	return valor;
}




function cseccion(){
	var periodico=document.getElementById('peri_sele');
	resul = document.getElementById('secciones');
	ajax=nuevoAjax();
	ajax.open("POST", "funciones/funajax.php",true);
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax.send("op=3&periodico="+periodico.value);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			resul.innerHTML=ajax.responseText;
		}
	}
}



function fotoguarda(form){
	alert(form.value);
}

function ventana(URL, w, h){
   window.open(URL,"Ventana1","width="+w+",height="+h+",scrollbars=YES,location =no,toolbar=no")
}

function ventanaSecundaria (URL,w,h){
   window.open(URL,"ventana1","width="+w+",height="+h+",scrollbars=YES,location =no,toolbar=no")
}


var secs
var timerID = null
var timerRunning = false
var delay = 1000

function inicianotas()
{
    // Set the length of the timer, in seconds
    secs = 8
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
		//  alert("Ahora cambia");
		siguiente();
	    secs = 8
	    StartTheTimer()
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}
