function voto(idn,votos) 
{
  var caja = document.getElementById("votos_"+idn);
  var texto = document.getElementById("texto_"+idn);
  var actual =  caja.innerHTML;

  var peticion_http = null;
  // Obtener la instancia del objeto XMLHttpRequest
  if(window.XMLHttpRequest) {
    peticion_http = new XMLHttpRequest();
  }
  else if(window.ActiveXObject) {
    peticion_http = new ActiveXObject("Microsoft.XMLHTTP");
  }
 
  // Preparar la funcion de respuesta
  peticion_http.onreadystatechange = muestraContenido;
 
  // Realizar peticion HTTP
  peticion_http.open('GET', '/voto.php?idn='+idn, true);
  peticion_http.send(null);
 
  function muestraContenido() 
  {
  
    if(peticion_http.readyState == 1)
    {
       caja.innerHTML="<img border=\"0\" src='/imagenes/load.gif' alt='...' />";
		
    }
	
    if(peticion_http.readyState == 4) 
    {
      if(peticion_http.status == 200) 
     {

		switch (parseInt(peticion_http.responseText))
		{
			
			case 1:
			{
				alert("Error en la votación");
				caja.innerHTML=votos;
				break;
			}
			case 2:
			{
				
				alert("Esta IP esta baneada.");
				caja.innerHTML=votos;
				break;
			}
			case 3:
			{
				alert("Esta noticia sobrepasa el número de votos anónimos permitidos");
				caja.innerHTML=votos;
				break;
			}
			case 4:
			{
				alert("Ya habías votado esta noticia :)");
				caja.innerHTML=votos;
				break;
			}
			case 5:
			{
				alert("Ya habías votado esta noticia :)");
				caja.innerHTML=votos;
				break;
			}
			case 6:
			{   
				votos = votos+1;

				document.getElementById("votos_link_"+idn).onclick = function(){voto(idn,votos);return false;};
				
				caja.innerHTML= votos;
				break;
			}
			case 7:
			{
				alert("Esta noticia tiene más de 48h. Ya no se la puede votar más.");
				caja.innerHTML=votos;
				break;
			}
		}
		
		texto.innerHTML = "Ok!";
		texto.style.fontWeight = "normal";
		document.getElementById("votos_link_"+idn).onclick = function(){alert("Ya habías votado esta noticia :)");return false;};
      }
    }
  }
}

function validacion(elementId,webId) 
{
  var actual = document.getElementById(elementId).innerHTML;
  var peticion_http = null;
  // Obtener la instancia del objeto XMLHttpRequest
  if(window.XMLHttpRequest) {
    peticion_http = new XMLHttpRequest();
  }
  else if(window.ActiveXObject) {
    peticion_http = new ActiveXObject("Microsoft.XMLHTTP");
  }
 
  // Preparar la funcion de respuesta
  peticion_http.onreadystatechange = muestraContenido;
 
  // Realizar peticion HTTP
  peticion_http.open('GET', '/validacion/'+webId, true);
  peticion_http.send(null);
 
  function muestraContenido() 
  {
  
    if(peticion_http.readyState == 1)
    {
        document.getElementById(elementId).innerHTML="<img src='/imagenes/loading.gif' alt='cargando...' />";
		
    }
    if(peticion_http.readyState == 4) 
    {
      if(peticion_http.status == 200) 
     {



        if(peticion_http.responseText == 1)
        {

            document.getElementById(elementId).innerHTML= "";


        }
        else if(peticion_http.responseText == 0)
        {

            document.getElementById(elementId).innerHTML= "Sin Validar !";
			document.getElementById("noValidadaError").style.display="block";


        }
        else if(peticion_http.responseText == -1)
        {

            document.getElementById(elementId).innerHTML= "Web no registrada";


        }
        else
        {

            document.getElementById(elementId).innerHTML= "Problemas de conexión";
			document.getElementById("problemasConexionError").style.display="block";

        }
      }
    }
  }
}







function controlVisitasPerfil(elementId,webId) 
{
  var actual = document.getElementById(elementId).innerHTML;
  var peticion_http = null;
  // Obtener la instancia del objeto XMLHttpRequest
  if(window.XMLHttpRequest) {
    peticion_http = new XMLHttpRequest();
  }
  else if(window.ActiveXObject) {
    peticion_http = new ActiveXObject("Microsoft.XMLHTTP");
  }
 
  // Preparar la funcion de respuesta
  peticion_http.onreadystatechange = muestraContenido;
 
  // Realizar peticion HTTP
  peticion_http.open('GET', '/controlVisitas/'+webId, true);
  peticion_http.send(null);
 
  function muestraContenido() 
  {
  
    if(peticion_http.readyState == 1)
    {
        document.getElementById(elementId).innerHTML="<img src='/imagenes/loading.gif' alt='cargando...' />";
		
    }
    if(peticion_http.readyState == 4) 
    {
      if(peticion_http.status == 200) 
     {

        if(peticion_http.responseText <0)
        {

            document.getElementById(elementId).innerHTML= "Error";

        }
        if(peticion_http.responseText ==0)
        {

            document.getElementById(elementId).innerHTML= actual;
        }
        if(peticion_http.responseText >0)
        {

           cuentaAtrasVisitas(peticion_http.responseText,elementId);
        }
		
      }
    }
  }
}


<!-- DEFINICIONES GLOBALES DE CONFIGURACION
var speed=1000;





//FUNCION UTILIZADA EN EL CONTENIDO DE LA PAGINA DE VISITAS

function cuentaAtrasVisitas(count,elementId)
{
	

	
		if(count>0)
		{
			

			if(count>60)
					{
						if( count>=3600)
						{
							
							var horas = (count/3600) | 0;
							var minutos =  ((count%3600) / 60 ) | 0;
							var segundos = (count%3600) % 60 ;
						}
						else
						{
							
							var horas = 0;
							var minutos=(count/60) | 0; //esto es un casting a entero
							var segundos=count%60;
						}
						/*	alert("horas  "+horas);
														alert("minutos  "+minutos);
																					alert("segundos  "+segundos);

*/
						if(segundos<10)
						{
							segundos = "0"+segundos;
						}
						if(minutos<10)
						{
							minutos = "0"+minutos;
							
							
						}							
						
								document.getElementById(elementId).innerHTML ="5links en: "+horas+":"+minutos+":"+segundos;
		

					}
					else
					{
					//document.getElementById("timer").innerHTML = "&nbsp;5links en "+count+"s";
					
							document.getElementById(elementId).innerHTML ="5links en: "+count+"s";
						
					}
					count--;
					window.setTimeout("cuentaAtrasVisitas("+count+",'"+elementId+"')",1000);			
			
			
			
			
			
			
			
			
			
		}
		else if (count <= 0)
		{
			window.location.reload(true);
		}
		
}
