	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 submitForm(){
		var contenedorMensaje = document.getElementById('mensajeError'); 
		var objAjax = nuevoAjax();
		objAjax.open("POST","/insRegistro.php",true);
		objAjax.onreadystatechange = function() {
			if (objAjax.readyState==4){
			 if (objAjax.status == 200){
				contenedorMensaje.innerHTML = objAjax.responseText;
			 return true;
				} else alert('Hubo un problema obteniendo los datos.');
			}
		}
		var boletin = 0;
		if(document.formulariRegistro.boletin.checked) boletin=1;
    var lLegal = 0;  
    if(document.formulariRegistro.legal.checked) lLegal=1;
		objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    
    var lParam="txUsuario="+escape(document.getElementById('txUsuario').value);
    lParam+="&txMail="+escape(document.getElementById('txMail').value);
    lParam+="&txPass="+escape(document.getElementById('txPass').value);
    lParam+="&txPass2="+escape(document.getElementById('txPass2').value);
    lParam+="&txinfousuario="+escape(document.getElementById('txinfousuario').value);
    lParam+="&boletin="+escape(boletin);
    lParam+="&legal="+escape(lLegal);
    
		objAjax.send(lParam);	
	}
	
	function resetPass(){
    var contenedorMensaje = document.getElementById('mensajeLostPass');
    var objAjax = nuevoAjax();
		objAjax.open("POST","/envioPassReset.php",true);
    objAjax.onreadystatechange = function() {
  		if (objAjax.readyState==4){
  		 if (objAjax.status == 200){
  			contenedorMensaje.innerHTML = objAjax.responseText;
  		 return true;
  			} else alert('Hubo un problema obteniendo los datos.');
  		}
  	}
  	objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    var lParam="emailLostPass="+escape(document.getElementById('emailLostPass').value);
		objAjax.send(lParam);
    
  }
	
	function updateForm(){
    var contenedorMensaje = document.getElementById('mensajeError'); 
		var objAjax = nuevoAjax();
		objAjax.open("POST","/updUsuario.php",true);
		objAjax.onreadystatechange = function() {
			if (objAjax.readyState==4){
			 if (objAjax.status == 200){
				contenedorMensaje.innerHTML = objAjax.responseText;
			 return true;
				} else alert('Hubo un problema obteniendo los datos.');
			}
		}
		var boletin = 0;
		if(document.formulariRegistro.boletin.checked)
		  boletin=1;
		objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    
    var lParam="txUsuario="+escape(document.getElementById('txUsuario').value);
    lParam+="&txMail1="+escape(document.getElementById('txEmailNew1').value);
    lParam+="&txMail2="+escape(document.getElementById('txEmailNew2').value);
    lParam+="&txPassAnt="+escape(document.getElementById('txPassOld').value);
    lParam+="&txPass="+escape(document.getElementById('txPassNew').value);
    lParam+="&txPass2="+escape(document.getElementById('txPassNew2').value);    
    lParam+="&txinfousuario="+escape(document.getElementById('txinfousuario').value);
    lParam+="&adsense_usuario="+escape(document.getElementById('cod_adsense_usuario').value);
    lParam+="&adsense_canal="+escape(document.getElementById('cod_adsense_canal').value);
    lParam+="&boletin="+escape(boletin);
    objAjax.send(lParam);               
  }
	
	function submitFormLogin(){
		var contenedorMensaje = document.getElementById('mensajeIdentificacion'); 
		var objAjax = nuevoAjax();
		objAjax.open("POST","/logIn.php",true);
		objAjax.onreadystatechange = function() {
			if (objAjax.readyState==4){
			 if (objAjax.status == 200){
				contenedorMensaje.innerHTML = objAjax.responseText;
        // Obtener nombre usuario del span#nombreusuario del HTML obtenido y hacer una llamada a función que actualiza barra de sesión
        var lNombreUsuario = document.getElementById('nombreusuario').textContent;
        actualizaBarraSesion(lNombreUsuario);
			 return true;
				} else alert('Hubo un problema obteniendo los datos.');
			}
		}
		objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    var lParam="txLogin="+escape(document.getElementById('txLogin').value);
    lParam+="&txPass="+escape(document.getElementById('txPassId').value);
		objAjax.send(lParam);
    	
	}
	
	function validaUploadVideo(){
	 var contenedorMensaje = document.getElementById('mensajeErrorUpload');
	 if (document.getElementById('titulo_up').value == ""){
      contenedorMensaje.innerHTML = "Debe introducir el titulo";
      return 0;
   }
   if (document.getElementById('descripcion_up').value == ""){
      contenedorMensaje.innerHTML = "Debe introducir una descripción";
      return 0;
   }
   if (document.getElementById('tags_up').value == ""){
      contenedorMensaje.innerHTML = "Debe introducir algún tag";
      return 0;
   }
   var lBoton=document.getElementById('enviar');
   if(lBoton){
    lBoton.disabled=true;
   }
   document.getElementById('formulariUpload').submit();
	}
	
	function valida_formulario(){
		var ajax=nuevoAjax();
		var mensaje = document.getElementById('mensajeEnvio');
		var Formulario = document.getElementById('formulari');
		var cadenaFormulario = "";
		var sepCampos = "";
		for (var i=0; i <= Formulario.elements.length-1;i++) {
			cadenaFormulario += sepCampos+Formulario.elements[i].name+'='+encodeURI(Formulario.elements[i].value);
	         sepCampos="&";
		}
		ajax.open("GET","http://www.manicomic.com/envio_recomendacion.php?"+cadenaFormulario,true);
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				if (ajax.status == 200){
					mensaje.innerHTML = ajax.responseText;
					return true;
				} else alert('Hubo un problema obteniendo los datos.');

	 		}
			return false;
		}
		ajax.send(null)
		Formulario.elements[0].value = "";
		Formulario.elements[1].value = "";
	}
	
	star_on = new Image;
	star_on.src = "http://www.manicomic.com/images/estrella_on_16.png";
	star_off = new Image;
	star_off.src = "http://www.manicomic.com/images/estrella_off_16.png";	

	function coloreaStar(numStar){
		var i;
		for (i=1;i<=numStar;i++){
			document.images['star'+i].src = star_on.src; 
		}	
	}
	
	function descoloreaStar(){
		var j;
		for (j=1;j<=5;j++){
			document.images['star'+j].src = star_off.src; 
		}
	}
	function votaNoticia(puntos,noticia,ip){
    var mensajeVotar = document.getElementById('mensajeVotar'); 
    var ajax=nuevoAjax();
    ajax.open("POST","/insVoto.php",true);
		ajax.onreadystatechange = function() {
			if (ajax.readyState==4){
			 if (ajax.status == 200){
				mensajeVotar.innerHTML = ajax.responseText;
			 return true;
				} else alert('Hubo un problema obteniendo los datos.');
			}
			return false;
			}
      ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		  ajax.send("puntos="+puntos+"&idnoticia="+noticia+"&ip="+ip);
  }
  
  function mostrarOcultar(capa){
    if (document.getElementById(capa).style.display == "none"){
      document.getElementById(capa).style.display = "block";
    } else {
      document.getElementById(capa).style.display = "none";
    }
  }
  
  function cargaNoticias(pPag){
		var contenedorNoticias = document.getElementById('todasNoticias');
		var objAjax = nuevoAjax();
		
		if(pPag != null && pPag > 0)
			objAjax.open("POST","/cargaNoticias.php?pag="+pPag,true);
		else
			objAjax.open("POST","/cargaNoticias.php",true);			
    objAjax.onreadystatechange = function() {
			if (objAjax.readyState==4){
			 if (objAjax.status==200){
			   document.getElementById('text_visitados').style.color = "#EA9D4B";
			   document.getElementById('text_visitados').style.fontWeight = "normal";
				 document.getElementById('text_recientes').style.color = "#000";
				 document.getElementById('text_recientes').style.fontWeight = "bold";
				 document.getElementById('text_votados').style.color = "#EA9D4B";
			   document.getElementById('text_votados').style.fontWeight = "normal";
         contenedorNoticias.innerHTML = objAjax.responseText;
			 return true;
				} else alert('Hubo un problema obteniendo los datos.');
			}
		}
		objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		objAjax.send("ajax=1");	
	}
	
	function cargaMasVisitados(pPag){
		var contenedorNoticias = document.getElementById('todasNoticias');
		var objAjax = nuevoAjax();
		objAjax.open("POST","/cargaMasVisitados.php?pag=" + pPag,true);
    objAjax.onreadystatechange = function() {
			if (objAjax.readyState==4){
			 if (objAjax.status==200){
			   document.getElementById('text_visitados').style.color = "#000";
			   document.getElementById('text_visitados').style.fontWeight = "bold";
				 document.getElementById('text_recientes').style.color = "#EA9D4B";
				 document.getElementById('text_recientes').style.fontWeight = "normal";
				 document.getElementById('text_votados').style.color = "#EA9D4B";
			   document.getElementById('text_votados').style.fontWeight = "normal";
         contenedorNoticias.innerHTML = objAjax.responseText;
			 return true;
				} else alert('Hubo un problema obteniendo los datos.');
			}
		}
		objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		objAjax.send("ajax=1");	
	}
	
	function cargaMasVotados(pPag){
		var contenedorNoticias = document.getElementById('todasNoticias');
		var objAjax = nuevoAjax();
		objAjax.open("POST","/cargaMasVotados.php?pag=" + pPag,true);
    objAjax.onreadystatechange = function() {
			if (objAjax.readyState==4){
			 if (objAjax.status==200){
			   document.getElementById('text_visitados').style.color = "#EA9D4B";
			   document.getElementById('text_visitados').style.fontWeight = "normal";
				 document.getElementById('text_recientes').style.color = "#EA9D4B";
				 document.getElementById('text_recientes').style.fontWeight = "normal";
				 document.getElementById('text_votados').style.color = "#000";
			   document.getElementById('text_votados').style.fontWeight = "bold";
         contenedorNoticias.innerHTML = objAjax.responseText;
			 return true;
				} else alert('Hubo un problema obteniendo los datos.');
			}
		}
		objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
		objAjax.send("ajax=1");	
	}
	
	function insertaComentario(){
    var contenedorMensaje = document.getElementById('mensajeErrorComentario'); 
		var objAjax = nuevoAjax();
		objAjax.open("POST","/insComentario.php",true);
		objAjax.onreadystatechange = function() {
			if (objAjax.readyState==4){
			 if (objAjax.status == 200){
				contenedorMensaje.innerHTML = objAjax.responseText;
			 return true;
				} else alert('Hubo un problema obteniendo los datos.');
			}
		}
		objAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    var lParam="txComentario="+escape(document.getElementById('txComentario').value);
    lParam+="&idNoticia="+escape(document.getElementById('idNoticia').value);
    lParam+="&usuario="+escape(document.getElementById('txUsuario').value);
		objAjax.send(lParam);
  
  }
