// JavaScript Document

function objetus() {
			 try {
					 objeto = new ActiveXObject("Msxml2.XMLHTTP");
			} catch ( e) {
					 try {
							 objeto= new ActiveXObject (" Microsoft.XMLHTTP");
					 } catch (E) {
							  objeto= false;
					}
			}
			if (! objeto && typeof XMLHttpRequest!= 'undefined') {
					 objeto = new XMLHttpRequest();
			}
			return objeto;
}

/* funciones para cambiar de video (video.php) */

function activ_anterior(cod_muro, num_activ, tot_activ) 
{  
	var aleatorio=Math.random();
	
	var cod_muro = cod_muro;
	var num_activ = num_activ;
	var tot_activ = tot_activ;
	
	if(num_activ == 1)
		num_activ = tot_activ;
	else
		num_activ = num_activ-1;
	
	var url = "actividad_sig_ant.php?";
	var params = "cod_muro="+cod_muro+"&num_activ="+num_activ+"&nocache="+aleatorio+"";
	var http = objetus();
	
	http.open("GET", url+params, true);
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
	//http.setRequestHeader("Content-length", params.length);
	//http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() 
	{//Call a function when the state changes.
		if (http.readyState == 1) { // Cargando...
			//document.getElementById("flecha-dia-menos").style.display ='none';
			//document.getElementById("flecha-dia-mas").style.display ='none';
			//document.getElementById("texto_dia_horario").style.display ='none';
			//document.getElementById("loadingdiv").style.display ='block';
		}
		if(http.readyState == 4 && http.status == 200) {	
			document.getElementById('contenido-videos-albumes').innerHTML = http.responseText;
		}
	};
	http.send(null);
}

function activ_siguiente( cod_muro, num_activ, tot_activ) 
{  
	var aleatorio=Math.random();
	
	var cod_muro = cod_muro;
	var num_activ = num_activ;
	var tot_activ =tot_activ;
	
	if(num_activ == tot_activ)
		num_activ = 1;
	else
		num_activ = num_activ+1;
	
	var url = "actividad_sig_ant.php?";
	var params = "cod_muro="+cod_muro+"&num_activ="+num_activ+"&nocache="+aleatorio+"";
	var http = objetus();
	
	http.open("GET", url+params, true);
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
	//http.setRequestHeader("Content-length", params.length);
	//http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() 
	{//Call a function when the state changes.
		if (http.readyState == 1) { // Cargando...
			//document.getElementById("flecha-dia-menos").style.display ='none';
			//document.getElementById("flecha-dia-mas").style.display ='none';
			//document.getElementById("texto_dia_horario").style.display ='none';
			//document.getElementById("loadingdiv").style.display ='block';
		}
		if(http.readyState == 4 && http.status == 200) {	
			document.getElementById('contenido-videos-albumes').innerHTML = http.responseText;
		}
	};
	http.send(null);
}

	/* funciones borrar/guardar comentarios */

function guardar_comentario_activ(cod_muro , cod_usu) {
	  
	var aleatorio=Math.random();
		
	var comentario = document.getElementById('com_activ_label'+cod_muro).value;
	var fecha = document.getElementById('fech_activ').value;
		
	var cod_muro = cod_muro;
	var cod_usu = cod_usu;		
	
	var url = "anyadir_comentario_activ.php?";
	var params = "cod_muro="+cod_muro+"&fecha="+fecha+"&cod_usu="+cod_usu+"&comentario="+comentario+"&nocache="+aleatorio+"";
		
	var http = objetus();
	http.open("POST", url, true);
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
	//http.setRequestHeader("Content-length", params.length);
	//http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() 
	{//Call a function when the state changes.
		if (http.readyState == 1) { // Cargando...
			/*document.getElementById("flecha-dia-menos-aqua").style.display ='none';
			document.getElementById("flecha-dia-mas-aqua").style.display ='none';
			document.getElementById("texto_dia_horario-aqua").style.display ='none';
			document.getElementById("loadingdiv").style.display ='block';*/	
		}
		if(http.readyState == 4 && http.status == 200) {
			document.getElementById('comentarios').innerHTML = http.responseText;
		}
	};
	http.send(params);		
}

function borrar_comentario_activ(cod_coment, cod_muro, cod_usu )
{
	var aleatorio=Math.random();
		
	var cod_coment = cod_coment;
	var cod_muro = cod_muro;
	var cod_usu = cod_usu;
	
	var url = "borrar_comentario_activ.php?";
	var params = "cod_muro="+cod_muro+"&cod_coment="+cod_coment+"&cod_usu="+cod_usu+"&nocache="+aleatorio+"";
	
	var http = objetus();
	http.open("POST", url, true);
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
	//http.setRequestHeader("Content-length", params.length);
	//http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() 
	{//Call a function when the state changes.
		if (http.readyState == 1) { // Cargando...
			/*document.getElementById("flecha-dia-menos-aqua").style.display ='none';
			document.getElementById("flecha-dia-mas-aqua").style.display ='none';
			document.getElementById("texto_dia_horario-aqua").style.display ='none';
			document.getElementById("loadingdiv").style.display ='block';*/
		}
		if(http.readyState == 4 && http.status == 200) {
			document.getElementById('comentarios').innerHTML = http.responseText;
				
		}
	};
	http.send(params);		
}


/* funcion participar en actividad */

function participar(cod_muro, cod_usu) {
	var aleatorio=Math.random();
	
	var condi =document.getElementById("asistir").value;
	var cod_muro = cod_muro;
	var cod_usu = cod_usu;
	if (condi == 0)
	{
	alert('elija una opcion');
	return;
	}
	var url = "guardar_asistencia.php?";
	var params = "cod_muro="+cod_muro+"&cod_usu="+cod_usu+"&condi="+condi+"&nocache="+aleatorio+"";
	var http = objetus();

	http.open("GET", url+params, true);
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", 'application/x-www-form-urlencoded');
	//http.setRequestHeader("Content-length", params.length);
	//http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function() 
	{//Call a function when the state changes.
		if (http.readyState == 1) { // Cargando...
			document.getElementById("load").style.display ='block';
		}
		if(http.readyState == 4 && http.status == 200) {	
			document.getElementById('participar').innerHTML = http.responseText;
			
			document.getElementById("fin").style.display = 'block';
			setTimeout ("document.getElementById('fin').style.display = 'none';", 2000);
			document.getElementById("load").style.display = 'none';
			
		}
	};
	http.send(null);
}

