function nuevoAjax()
{ 
    /* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
    lo que se puede copiar tal como esta aqui */
    var xmlhttp=false; 
    try 
    { 
        // Creacion del objeto AJAX para navegadores no IE
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    }
    catch(e)
    { 
        try
        { 
            // Creacion del objet AJAX para IE 
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        catch(E) { xmlhttp=false; }
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 

    return xmlhttp; 
}
function validateEmailv2(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
if(email.length <= 0)
{
return true;
}
var splitted = email.match("^(.+)@(.+)$");
if(splitted == null) return false;
if(splitted[1] != null )
{
var regexp_user=/^\"?[\w-_\.]*\"?$/;
if(splitted[1].match(regexp_user) == null) return false;
}
if(splitted[2] != null)
{
var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
if(splitted[2].match(regexp_domain) == null) 
{
var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
if(splitted[2].match(regexp_ip) == null) return false;
}// if
return true;
}
return false;
}
function validacion(){    
var accs=1;


	if (document.formulario.nombre_envia.value=="" & accs!=0){
		alert("Debes ingresar tu nombre.");
		document.formulario.nombre_envia.focus();  
		accs=0;
		}	
	if (document.formulario.email_envia.value=="" & accs!=0){
		alert("Debes ingresar tu email.");
		document.formulario.email_envia.focus();  
		accs=0;
		}	
	if(!validateEmailv2(document.formulario.email_envia.value) & accs!=0){
		alert("Debes ingresar Email correcto.");
		document.formulario.email_envia.focus();  
		accs=0;
		}  
	if (document.formulario.nombre_recibe.value=="" & accs!=0){
		alert("Debes ingresar el nombre del destinatario.");
		document.formulario.nombre_recibe.focus();  
		accs=0;
		}
	if (document.formulario.email_recibe.value=="" & accs!=0){
		alert("Debes ingresar el email del destinatario.");
		document.formulario.email_recibe.focus();  
		accs=0;
		}
	if(!validateEmailv2(document.formulario.email_recibe.value) & accs!=0){
		alert("Debes ingresar Email correcto.");
		document.formulario.email_recibe.focus();  
		accs=0;
		}  
	if (document.formulario.code.value=="" & accs!=0){
		alert("Debes ingresar el codigo de seguridad.");
		document.formulario.code.focus();  
		accs=0;
		}
 

	if (accs==1) { document.formulario.submit(); }
	}
	
function votar(idpostal){
    ajax=nuevoAjax();
    ajax.open("GET", "/ajaxvotar.php?idpostal="+idpostal+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    {  if (ajax.readyState==4) { document.getElementById("votar").innerHTML=ajax.responseText;  }  }
    ajax.send(null);       
  }