var bCancel = false;

    function validateAccountProfileForm(form) {
        if (bCancel) {
            return true;
        } else {
            var formValidationResult;
            formValidationResult = validateRequired(form) && checkChildrenAges();
            return (formValidationResult == 1);
        }
    }

    function AccountProfileForm_required () {
     this.a0 = new Array("accountProfileForm.heightFeetOrMeter", "•  Height", new Function ("varName", " return this[varName];"));
     this.a1 = new Array("accountProfileForm.heightUnit", "•  Height unit", new Function ("varName", " return this[varName];"));
     this.a2 = new Array("accountProfileForm.weight", "•  Weight", new Function ("varName", " return this[varName];"));
     this.a3 = new Array("accountProfileForm.weightUnit", "•  Weight unit", new Function ("varName", " return this[varName];"));
     this.a4 = new Array("accountProfileForm.maritalStatus", "•  Marital Status", new Function ("varName", " return this[varName];"));
     this.a5 = new Array("accountProfileForm.smokes", "•  Smoking habits", new Function ("varName", " return this[varName];"));
     this.a6 = new Array("accountProfileForm.drinks", "•  Drinking habits", new Function ("varName", " return this[varName];"));
     this.a7 = new Array("accountProfileForm.education", "•  Education", new Function ("varName", " return this[varName];"));
     this.a8 = new Array("accountProfileForm.religion", "•  Religion", new Function ("varName", " return this[varName];"));
     this.a9 = new Array("accountProfileForm.children", "•  Children under age of 18", new Function("varName", " return this[varName];"));
     this.a10 = new Array("accountProfileForm.adultChildren", "•  Adult Children", new Function("varName", " return this[varName];"));
    }

function heightUnitChanged()
{
    var heightUnit = document.getElementsByName("accountProfileForm.heightUnit")[0];
    var unit = heightUnit.options[heightUnit.selectedIndex];
    var inchLabel = document.getElementById("inchLabel");
    var cmLabel = document.getElementById("cmLabel");

    if (unit.value == "ft")
    {
        inchLabel.style.visibility = "visible";
        cmLabel.style.visibility = "hidden";
    }
    else if (unit.value == "m")
    {
        inchLabel.style.visibility = "hidden";
        cmLabel.style.visibility = "visible";
    }
    else
    {
        inchLabel.style.visibility = "hidden";
        cmLabel.style.visibility = "hidden";
    }
}

function checkChildrenAges() {
    var children = document.getElementsByName("accountProfileForm.children")[0];
    var childrenDob = document.getElementsByName("accountProfileForm.childrenDob")[0];

    if (children.value == "" && childrenDob.value == "") {
        var selItem = children.options[children.selectedIndex];
        if(selItem.value != "" && selItem.value != 0) {
            if(childrenDob.value == "") {
                alert("Please specify children ages, who are under 18. Ex. 2-3");
            }
            return false;
        }
        else {
            return true;
        }
    }
    return true;    
}
