
 function CheckContactForm() {

    var cform = document.contact;

    var required_fields = new Array("firstname", "lastname", "company", "phone", "email", "reemail", "total_prop", "total_unit");
    var required_fields_title = new Array("First Name", "Last Name", "Company Name", "Phone", "E-mail", "Re-type E-mail", "Total Number of Properties", "Total Number of Units");

    var no_fill_fields = new Array();
    var j = 0;
 
    for (var i = 0; i < required_fields.length; i++) {

        element = cform.elements[required_fields[i]];
        if (element.value == "") {

           no_fill_fields[j++] = required_fields_title[i]; 
           element.style.backgroundColor = "#FFEFF0";

        } else {

           element.style.backgroundColor = "";
        }
    }

    if (no_fill_fields.length > 0) {

        ShowWarningBox("Please complete the required fields indicated below.");
        return false;
    }

    if (!CheckEmail(cform.elements["email"].value)) {

        cform.elements["email"].style.backgroundColor = "#FFEFF0";
        ShowWarningBox("The e-mail address you entered appears invalid.");
        return false;        

    } else {

        cform.elements["email"].style.backgroundColor = "";
    }

    if (cform.elements["email"].value != cform.elements["reemail"].value) {

        cform.elements["reemail"].style.backgroundColor = "#FFEFF0";
        ShowWarningBox("Please check that your e-mail addresses match.");
        return false;

    } else {

        cform.elements["reemail"].style.backgroundColor = "";
    }

    HideWarningBox();
    return true;

 }

 function ShowWarningBox($warning) {

    with (document.getElementById("warning")) {

        innerHTML = $warning;
        style.display = "block";
    }
 }

 function HideWarningBox() {

    with (document.getElementById("warning")) {

        innerHTML = "";
        style.display = "none";
    }
 }

function CheckEmail(email) {

  emailTest = "^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$"; 
  var regex = new RegExp(emailTest); 
  
  result = (!regex.test(email)) ? false : true;
  return result;
}


function newWindow(url, name, w, h)
{
 var win = window.open(url,'name', 'width=' + w + ', height=' + h + ', ' + 'location=no, menubar=no, ' +'status=no, toolbar=no, scrollbars=yes, resizable=no');
 win.resizeTo(w, h);
 win.focus();
}

