function getCodeInput() {
    var a = new Array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q',
                      'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7',
                      '8', '9');
    
    code = '';
    for (i = 0; i < 5; i++) {
        r = Math.floor(Math.random() * 32);
        code += a[r];
    }
    
    input = '<input type="text" id="code2" name="code2" value="' + code + '" readonly="readonly" style="background: #000;" />';
    document.write(input);
}

function doSubmit() {
    first = document.getElementById('first').value;
    last = document.getElementById('last').value;
    email = document.getElementById('email').value;
    email2 = document.getElementById('email2').value;
    code = document.getElementById('code').value;
    code2 = document.getElementById('code2').value;
    
    errmsg = '';

    if (first.length < 1)
        errmsg += "Please enter your first name\n";
    if (last.length < 1)
        errmsg += "Please enter your last name\n";
    if (email.length < 6 || email.indexOf('@') < 1)
        errmsg += "Please enter a valid email address\n";
    if (email != email2)
        errmsg += "Your email address did not match the confirmation address\n";
    if (code.toUpperCase() != code2)
        errmsg += "The code you entered did not match the code on the screen\n";

    if (errmsg.length > 0) {
        alert(errmsg);
    } else {
        document.getElementById('contact_form').action = 'contact.php';
        document.getElementById('contact_form').submit();
        //alert('submitting...');
    }
}

function resetStyles(){
/*
    unGoogle('INPUT');
    unGoogle('SELECT');
    //document.getElementById('code2').style.backgroundColor = '#000';
*/
}


function unGoogle(eleType){
    var t=document.getElementsByTagName(eleType);
    //alert("type = " + eleType + ", n = " + t.length);
    for(var i=0;i<t.length;i++){
        t[i].attachEvent('onpropertychange',resetCSS);
        //t[i].style.backgroundColor='';
    }
}


function resetCSS(){
    var s=event.srcElement.style;
    var id=event.srcElement.id;
    alert("id = " + id);
    if(s.backgroundColor!='#515151'&&id!='code2') {
        alert("resetting " + id);
        s.backgroundColor='#515151';
    }
} 