// 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 video_anterior(cod_video, num_video, tot_video) 
{  
	var aleatorio=Math.random();
	
	var cod_video = cod_video;
	var num_video = num_video;
	var tot_video = tot_video;
	
	if(num_video == 1)
		num_video = tot_video;
	else
		num_video = num_video-1;
	
	var url = "video_sig_ant.php?";
	var params = "cod_video="+cod_video+"&num_video="+num_video+"&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 video_siguiente( cod_video, num_video, tot_video) 
{  
	var aleatorio=Math.random();
	
	var cod_video = cod_video;
	var num_video = num_video;
	var tot_video =tot_video;
	
	if(num_video == tot_video)
		num_video = 1;
	else
		num_video = num_video+1;
	
	var url = "video_sig_ant.php?";
	var params = "cod_video="+cod_video+"&num_video="+num_video+"&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_vid(cod_video , cod_usu) {
	  
	var aleatorio=Math.random();
		
	var comentario = document.getElementById('com_vid_label'+cod_video).value;
	var fecha = document.getElementById('fech_vid').value;
		
	var cod_video = cod_video;
	var cod_usu = cod_usu;		
	
	var url = "anyadir_comentario_video.php?";
	var params = "cod_video="+cod_video+"&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('comentario').innerHTML = http.responseText;
		}
	}
	http.send(params);		
}

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


