var conexion1;
//---------------------------- COLAPSAR / DESCOLAPSAR --------------------------------------

function publicar(){
	publicarVisible = document.getElementById('publicarVisible').value;
	
	if (publicarVisible == 0){
		document.getElementById('publicar').style.display = 'block';  
		document.getElementById('publicarVisible').value = '1';
	} else {
		document.getElementById('publicar').style.display = 'none';  
		document.getElementById('publicarVisible').value = '0';
	}
}

function compartir(){
	compartirVisible = document.getElementById('compartirVisible').value;
	
	if (compartirVisible == 0){
		document.getElementById('compartir').style.display = 'block';  
		document.getElementById('compartirVisible').value = '1';
	} else {
		document.getElementById('compartir').style.display = 'none';  
		document.getElementById('compartirVisible').value = '0';
	}
}

//---------------------------- CARGAR COMENTARIO -------------------------------------------

function cargarComentario(){
	var nombre = document.getElementById("nombre").value;
	var email = document.getElementById("email").value;
	var comentario = document.getElementById("comentario").value;
	var video = document.getElementById("video").value;
	
	conexion1 = crearXMLHttpRequest();
    conexion1.onreadystatechange = procesarComentario;
	conexion1.open('GET','/ajax.php?a=cargarComentario&video='+video+'&nombre='+nombre+'&email='+email+'&comentario='+comentario, true);
    conexion1.send(null);
}

function procesarComentario(){
	if (conexion1.readyState == 4){ 
		document.getElementById("campoMensaje").innerHTML = "";
		document.getElementById('mensaje').style.display = 'block';  
	}
	if (conexion1.readyState == 1){
		document.getElementById("campoMensaje").innerHTML = "<img src='/imagenes/ajax-loader.gif' /> Procesando";
	}
}

//---------------------------- XML HTTP REQUEST ----------------------------------------

function crearXMLHttpRequest(){
  var xmlHttp=null;
  if (window.ActiveXObject) 
    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  else 
    if (window.XMLHttpRequest) 
      xmlHttp = new XMLHttpRequest();
  return xmlHttp;
}

function objetoAjax(){
	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;
}