function verifycaptcha(codigo){

  var cod=codigo.value;
  document.getElementById("aviso").innerHTML = "";
  
  if (typeof jQuery === 'undefined') {    
    /* jQuery no esta definido */  
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      if ( this.responseText == 0 ) {
            document.getElementById("aviso").style.color = "#D8000C";
            document.getElementById("aviso").style.backgroundColor = "#FFBABA";
            document.getElementById("aviso").innerHTML = "El codigo ingresado no coincide, haz click sobre el codigo para generar otro";
            document.getElementById("myButton").style.visibility = "hidden";
      } else {
            document.getElementById("aviso").style.color = "#4F8A10";
            document.getElementById("aviso").style.backgroundColor = "#DFF2BF";
            document.getElementById("aviso").innerHTML = "El codigo ingresado coincide, puedes adjuntar tu CV";
            document.getElementById("myButton").style.visibility = "visible";
      }
    }
  };
  xhttp.open("POST", "modelo/vercaptcha.php?cod="+cod, true);
  xhttp.send();


  } else {
  
    /*  jQuery esta definido  */
    $.ajax({ url: 'modelo/vercaptcha.php?cod='+cod,
         data: {action: 'test'},
         type: 'post',
         success: function(output) {
         if ( output == 0 ) {
            $("#your_code_ok").html('<img id="theImg" src="img/no1.png" width="19" height="19" />'); 
            $("#myButton").hide();
         } else {
              $("#your_code_ok").html('<img id="theImg" src="img/ok1.png" width="19" height="19" />'); 
            $("#myButton").show();
         }
       }
    });
  }
}

function verifyname(){
  var value=$.trim($("#your_name").val());

  if(value.length>0){
    $("#your_name_ok").html('<img id="theImg" src="img/ok1.png" width="19" height="19" />'); 
  } 
  else {
     $("#your_name_ok").html('<img id="theImg" src="img/no1.png" width="19" height="19" />');
  }

}

function verifyemail(){
  var value=$.trim($("#your_email").val());

  if(validateEmail(value)){
    $("#your_email_ok").html('<img id="theImg" src="img/ok1.png" width="19" height="19" />');
  } 
  else {
     $("#your_email_ok").html('<img id="theImg" src="img/no1.png" width="19" height="19" />');
  }

}

function verifymessage(){
  var value=$.trim($("#your_message").val());

  if(value.length>0){
    $("#your_message_ok").html('<img id="theImg" src="img/ok1.png" width="19" height="19" />'); 
  } 
  else {
     $("#your_message_ok").html('<img id="theImg" src="img/no1.png" width="19" height="19" />');
  }

}

function validateEmail(email) {
    var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
}