﻿function validate_required(field, alerttxt) {
    with (field) {
        if (value == null || value == "") {
            alert(alerttxt); return false;
        }
        else {
            return true;
        }
    }
}

function validate(thisform) {
    with (thisform) {
        if (validate_required(name, "Please provide first name.") == false)
        { name.focus(); return false; }
        if (validate_required(last, "Please provide last name.") == false)
        { last.focus(); return false; }
        if (validate_required(add, "Please provide address.") == false)
        { add.focus(); return false; }
        if (validate_required(city, "Please provide city.") == false)
        { city.focus(); return false; }
        if (validate_required(state, "Please provide state.") == false)
        { state.focus(); return false; }
        if (validate_required(zip, "Please provide zip.") == false)
        { zip.focus(); return false; }
        if (validate_required(phone, "Please provide phone.") == false)
        { phone.focus(); return false; }
        if (validate_required(email, "Please provide email.") == false)
        { email.focus(); return false; }
        if (validate_required(seeking_name, "Please provide Name of person needing service.") == false)
        { seeking_name.focus(); return false; }
        if (validate_required(seeking, "Please provide Seeking Information Regarding..") == false)
        { seeking.focus(); return false; }
        if (validate_required(relationship, "Please provide Relationship to you.") == false)
        { relationship.focus(); return false; }               
    }
}
function validate_option1(form) {

    if (form.telephone_number.value.length == 0) {
        alert("Please enter a telephone number.");
        form.telephone_number.select();
        form.telephone_number.focus();
        return false;
    }

    if (form.telephone_number.value.length < 7) {
        alert("Please enter all seven digits of your telephone number.");
        form.telephone_number.select();
        form.telephone_number.focus();
        return false;
    }

    index = form.best_day.selectedIndex;
    var dayValue = form.best_day.options[index].value;

    if (dayValue.length < 1) {
        alert("Please select a day.");
        form.best_day.focus();
        return false;
    }

    if (form.best_time.value.length < 1) {
        alert("Please enter a time you can be reached.");
        form.best_time.select();
        form.best_time.focus();
        return false;
    }

    return true;
}


function validate_option2(form) {
    if (form.email.value.length == 0) {
        alert("Please enter an email address.");
        form.email.select();
        form.email.focus();
        return false;
    }
    if (!isValidEmail(form.email.value)) {
        alert("Please enter a valid email address.");
        form.email.select();
        form.email.focus();
        return false;
    }

    return true;
}

function validate_option3(form) {

    if (form.specific_information.value.length < 10) {
        alert("Please enter enough information so we may contact you.");
        form.specific_information.select();
        form.specific_information.focus();
        return false;
    }

    return true;
}


function isValidEmail(str) {
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function showPrivacy() {
    var ndoc;
    var astr;
    aPopUp = window.open(' ', 'Privacy', 'toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=350,height=300,top=400,left=500');
    ndoc = aPopUp.document;
    astr = '<HTML><HEAD><BR><TITLE>Privacy Statement</TITLE></HEAD><BODY BGCOLOR="#FFFFCC">';
    astr = astr + "<center>We respect the privacy of all visitors to our site. Although various forms within our site require you to provide us with personal identification information such as your name, ";
    astr = astr + "phone number and email address, please rest assured that we will not redistribute this information to any outside source or third party.<br><br>";
    astr = astr + "The information you supply us with on this site is used solely for the purpose of helping you find a new apartment home. ";
    astr = astr + "We value your interest in our communities and we value your privacy.";
    astr = astr + "</center>";
    astr = astr + "<br><center><input type=submit name=btnY value=' Close ' ";
    astr = astr + "onClick='self.close();'></center>";
    astr = astr + '</HTML>';
    ndoc.write(astr);
    ndoc.close();
    self.aNoteWin = aPopUp;
    aPopUp.focus();
    return (true);
}
//spam fix
function submitConactForm() {
    // Change the form action to the real submission page
    document.getElementById('contact_form').action = "/includes/process_form.asp";
    // Submit the form
    document.getElementById('contact_form').submit();
}

