

//~ if (document.images) {//~ homeon = new Image(72, 27);//~ homeon.src = "picts/homeON.gif"//~ homeoff = new Image(72, 27);//~ homeoff.src = "picts/homeOFF.gif"//~ }
function img_act(imgName) {    if (document.images) {    imgOn = eval(imgName + "on.src");    document [imgName].src = imgOn;    }}

function img_inact(imgName) {
    if (document.images) {    imgOff = eval(imgName + "off.src");    document [imgName].src = imgOff;    }}

function over_button(id){
    var button = document.getElementById(id);
    button.style.background = "url(../picts/buttonon.gif)";
}
function out_button(id){
    var button = document.getElementById(id);
    button.style.background = "url(../picts/button.gif)";
}

function check_form(form_name){
    var error = 0;
    var first_name = document.getElementById('first_name').value;
    var last_name = document.getElementById('last_name').value;
    var email = document.getElementById('email').value;
    var phone_num = document.getElementById('phone_num').value;
    var address = document.getElementById('address').value;
    var city = document.getElementById('city').value;
    var state = document.getElementById('state').value;
    var zip = document.getElementById('zip').value;
    if (first_name.length <= 0 || hasNumbers(first_name)){
        alert("Invalid First Name");
        error = 1;
    }
    if (last_name.length <= 0 || hasNumbers(last_name)){
        alert("Invalid Last Name");
        error = 1;
    }
    if (invalid_email(email)){
        alert("Invalid e-mail address");
        error = 1;
    }
    if (invalid_phone_num(phone_num)){
        alert("Invalid phone number\nPlease include 10 digits");
        error = 1;
    }
    if (zip.length != 5 || !hasNumbers(zip)){ //only checks length and for at least one number
        alert("Invalid zip code");
        error = 1;
    }
    if (state == "??"){ //only checks length and for at least one number
        alert("Please select State");
        error = 1;
    }
    if (error == 0){
        eval("document." + form_name + ".submit();");
    }
}
function hasNumbers(str)
{
    return /\d/.test(str);
}
function invalid_email(email){
    if( (email.indexOf("@") > 0) 
            && (email.length > email.indexOf(".") + 2)
            && (email.indexOf(" ") < 0) 
            && (email.length > 5)){
        return false;
    }
    else return true;
}
function invalid_phone_num(phone_num){
    var num_of_numbers = 0;
    //~ alert(phone_num.substring(i,i+1));
    for (var i = 0; i < phone_num.length; i++){
        if (hasNumbers(phone_num.substring(i,i+1))) num_of_numbers++;
    }
    if ( num_of_numbers < 10 ){
        return true;
    }
    else return false;
}