// 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 fotos (contenido_album_fotos.php) */

function foto_anterior(cod_album, cod_foto, num_foto, tot_fotos) 
{  
	var aleatorio=Math.random();
	
	var cod_album = cod_album;
	var cod_foto = cod_foto;
	var num_foto = num_foto;
	var tot_fotos = tot_fotos;
	var quien = 0;
	
	if(num_foto == 1)
		num_foto = tot_fotos;
	else
		num_foto = num_foto-1;
	
	var url = "foto_sig_ant.php?";
	var params = "cod_album="+cod_album+"&cod_foto="+cod_foto+"&num_foto="+num_foto+"&quien="+quien+"&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 foto_siguiente(cod_album, cod_foto, num_foto, tot_fotos) 
{  
	var aleatorio=Math.random();
	
	var cod_album = cod_album;
	var cod_foto = cod_foto;
	var num_foto = num_foto;
	var tot_fotos =tot_fotos;
	var quien =1;
	if(num_foto == tot_fotos)
		num_foto = 1;
	else
		num_foto =num_foto+1;
	
	var url = "foto_sig_ant.php?";
	var params = "cod_album="+cod_album+"&cod_foto="+cod_foto+"&num_foto="+num_foto+"&quien="+quien+"&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 para comentarios de fotos (album_fotos.php) */

function guardar_comentario_foto(cod_foto, cod_usu, cod_album) {
	  
	var aleatorio=Math.random();
		
	var comentario = document.getElementById('com_foto_label'+cod_foto).value;
	var fecha = document.getElementById('fech_foto').value;
	
	var cod_album =cod_album;
	var cod_foto = cod_foto;
	var cod_usu = cod_usu;		
	
	var url = "anyadir_comentario_foto.php?";
	var params = "cod_foto="+cod_foto+"&cod_album="+cod_album+"&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-fotos').innerHTML = http.responseText;
		}
	};
	http.send(params);		
}

function borrar_comentario_foto(cod_coment, cod_foto, cod_usu, cod_album )
{
	var aleatorio=Math.random();
		
	var cod_coment = cod_coment;
	var cod_video = cod_foto;
	var cod_album =cod_album;
	var cod_usu = cod_usu;
	
	var url = "borrar_comentario_foto.php?";
	var params = "cod_foto="+cod_foto+"&cod_album="+cod_album+"&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-fotos').innerHTML = http.responseText;		
		}
	};
	http.send(params);		
}



