// Programmed by Aaron Landerkin
// Bruce Clay, Inc. 2008

//This JS file will produce two random numbers, and add them together as a basic test of user vs. bot in our forms on the website.
var rand1, rand2;
rand1 = Math.floor(Math.random()*10);
rand2 = Math.floor(Math.random()*10);
function formChallenge() {
    //add the field to fill out the challenge
    document.write('To avoid spam: What is ' + rand1 + ' + ' + rand2 + '? ');
    document.write('<input type="text" name="formChallenge" />');
    
    //modify the value for the answer field
    var elem = document.getElementById('challengeAnswer');
    elem.value = rand1 + rand2;
}
function checkChallenge(value,form) {
    var result = rand1 + rand2;
    if(value == result) {
        document.getElementById(form).submit();
    }
    else {
        alert("Your answer is wrong, please try again.");
        return false;
    }
}


