var qList = new Array(true, true, true, false, true, true, true, true);
var qListString = new Array ("q3div","q1div","q2div","qDiv_NOTE","q4div","q5div", "q6div", "qDiv_MILITARY_01");

var curQ = 0;
var lastQ = 0;
var noteIndex = 3;

function nextQ(field) {
    if(field == window.document.form1.CAPUEDUCTN_01) {
    initPrograms();
    initNote();
    } else if(field == window.document.form1.CAPPROGRAM_01) {
    initQ2();
    initNote();
    } else if(field == window.document.form1.CAPSPECIALTY_01) {
    initNote();
    }
    initState();
    return;
}

function showNextQ(field) {
    if(!validate(field)) {
        return;
    }

    if(field == window.document.form1.CAPUEDUCTN_01) {
    initPrograms();
    initNote();
    } else if(field == window.document.form1.CAPPROGRAM_01) {
    initQ2()
        hideAll();
    initNote();
    } else if(field == window.document.form1.CAPSPECIALTY_01) {
    initNote();
    }
    lastQ = curQ;
    curQ++;
    while(curQ<qList.length) {
        if(qList[curQ]) {
            hide(qListString[lastQ]);
            show(qListString[curQ]);
            return;
        }
        curQ++;
    }
    submitForm();
}

function validate(field) {
    if(field==window.document.form1.CAPUEDUCTN_01) {
        return validate_CAPUEDUCTN_01();
    } else if(field==window.document.form1.CAPPROGRAM_01) {
        return validate_CAPPROGRAM_01();
    } else if(field==window.document.form1.CAPSPECIALTY_01) {
        return validate_CAPSPECIALTY_01();
    } else if(field==window.document.form1.CAPUTODATE_YEAR_01) {
        return validate_CAPUTODATE_01();
    } else if(field==window.document.form1.CAPUTODATE_YEAR_01) {
        return validate_CAPAGE_01();
    } else if(field==window.document.form1.MILITARY_01) {
        return validate_MILITARY_01();
    } else if(field==window.document.form1.EMAIL_01) {
        return validate_EMAIL_01(window.document.form1);
    } 
    return true;
}

function hideAll() {
    i=0;
    while(i<qListString.length) {
        hide(qListString[i]);
        i++;
    }
}

function initNote() {
    var program = window.document.form1.CAPPROGRAM_01;
    if(program.options[program.selectedIndex].value == "3Online MS") {
        var field = window.document.form1.CAPSPECIALTY_01;
        var value = field.options[field.selectedIndex].value;
        if(value == "K-12 Studies in Education" || value == "Curriculum and Instruction" || value == "Leadership in Ed Admin" || value == "Reading and Literacy") {
            qList[noteIndex] = true;
            return;
        }
    }
    qList[noteIndex] = false;
}

function initPrograms() {
    var field = window.document.form1.CAPPROGRAM_01;
    var value = getFieldValueLB(field);

    var eduField = window.document.form1.CAPUEDUCTN_01;
    var eduValue = getFieldValueLB(eduField);

    field.length = 0;
    field.innerHTML = "";

    field.options[field.length] = new Option("Select a Program","");

    if(eduValue == "3 Yr Bacca Non-US" || eduValue == "1 Sem from Bach" || eduValue == "Bachelors Degree" || eduValue == "Some Graduate" ||
       eduValue == "1 Yr from Masters" || eduValue == "Masters Degree" || eduValue == "Some Doctoral" || eduValue == "All but Dissertation" || eduValue == "Doctoral Degree") {
        var btOptGroup = createOptGroup("Business and Technology");
        createAndAddOptionToOptGroup(btOptGroup, "Master of Business Administration (MBA)", "1MBA");
        createAndAddOptionToOptGroup(btOptGroup, "Master of Science (MS) in Information Technology", "2Online MS");
        createAndAddOptionToOptGroup(btOptGroup, "Master of Science (MS) in Organization and Management", "1Online MS");
        createAndAddOptionToOptGroup(btOptGroup, "Master of Science (MS) in Human Resource Management", "MS in HR");
        if(eduValue == "1 Yr from Masters" || eduValue == "Masters Degree" || eduValue == "Some Doctoral" || eduValue == "All but Dissertation" || eduValue == "Doctoral Degree") {
            createAndAddOptionToOptGroup(btOptGroup, "Doctor of Philosophy (PhD) in Information Technology", "12PhD");
            createAndAddOptionToOptGroup(btOptGroup, "Doctor of Philosophy (PhD) in Organization and Management", "1PhD");
        }
        field.appendChild(btOptGroup);
    
        var eduOptGroup = createOptGroup("Education");
        createAndAddOptionToOptGroup(eduOptGroup, "Master of Science (MS) in Education", "3Online MS");
        if(eduValue == "1 Yr from Masters" || eduValue == "Masters Degree" || eduValue == "Some Doctoral" || eduValue == "All but Dissertation" || eduValue == "Doctoral Degree") {
            createAndAddOptionToOptGroup(eduOptGroup, "Post-Master's Certificate in Education", "3MSCert");
            createAndAddOptionToOptGroup(eduOptGroup, "Post-Master's Certificate in Enrollment Management", "32MSCert");
            createAndAddOptionToOptGroup(eduOptGroup, "Doctor of Philosophy (PhD) in Education", "3PhD");
        }
        field.appendChild(eduOptGroup);
    
        var hsOptGroup = createOptGroup("Human Services");
        createAndAddOptionToOptGroup(hsOptGroup, "Master of Science (MS) in Human Services", "4Online MS");
        createAndAddOptionToOptGroup(hsOptGroup, "Master of Science (MS) in Public Safety", "42Online MS");
        if(eduValue == "1 Yr from Masters" || eduValue == "Masters Degree" || eduValue == "Some Doctoral" || eduValue == "All but Dissertation" || eduValue == "Doctoral Degree") {
            createAndAddOptionToOptGroup(hsOptGroup, "Doctor of Philosophy (PhD) in Human Services", "4PhD");
            createAndAddOptionToOptGroup(hsOptGroup, "Doctor of Philosophy (PhD) in Public Safety", "42PhD");
        }
        field.appendChild(hsOptGroup);
    
        var psyOptGroup = createOptGroup("Psychology");
        createAndAddOptionToOptGroup(psyOptGroup, "Master of Science (MS) in Psychology", "5Online MS");
        if(eduValue == "1 Yr from Masters" || eduValue == "Masters Degree" || eduValue == "Some Doctoral" || eduValue == "All but Dissertation" || eduValue == "Doctoral Degree") {
            createAndAddOptionToOptGroup(psyOptGroup, "Doctor of Philosophy (PhD) in Psychology", "5PhD");
        }
        field.appendChild(psyOptGroup);
    }

    var usOptGroup = createOptGroup("Undergraduate Studies");
    createAndAddOptionToOptGroup(usOptGroup, "Bachelor of Science (BS) in Business", "1BS");
    createAndAddOptionToOptGroup(usOptGroup, "Bachelor of Science (BS) in Information Technology", "2BS");
    field.appendChild(usOptGroup);

    selectValue(field, value);
    return;
}

function initQ2() {
    q1 = window.document.form1.CAPPROGRAM_01
    q2 = window.document.form1.CAPSPECIALTY_01
    value = q2.options[q2.selectedIndex].value
    if(q1.options[q1.selectedIndex].value == "")
    {   
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
    } else if(q1.options[q1.selectedIndex].value == "1BS") {   
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("Accounting","Accounting");
        q2.options[q2.length] = new Option("Business Administration","Business Administration");
        q2.options[q2.length] = new Option("Finance","Finance");
        q2.options[q2.length] = new Option("Human Resource Management","Human Resource Mgmt");
        q2.options[q2.length] = new Option("Management and Leadership","Management and Leadership");
        q2.options[q2.length] = new Option("Marketing","Marketing");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "1Online MS") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("General","General");
        q2.options[q2.length] = new Option("Leadership","Leadership");
        q2.options[q2.length] = new Option("MS in Org and Development - General Organizational Development","1409");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "1MBA") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("Accounting","Accounting");
        q2.options[q2.length] = new Option("Finance","Finance");
        q2.options[q2.length] = new Option("General","General Business");
        q2.options[q2.length] = new Option("Health Care Management","Health Care Management");
        q2.options[q2.length] = new Option("Information Technology Management","IT Management");
        q2.options[q2.length] = new Option("Marketing","Marketing");
        q2.options[q2.length] = new Option("Project Management","Project Management");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "1PhD") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("General","General");
        q2.options[q2.length] = new Option("Human Resource Management","Human Resource Mgmt");
        q2.options[q2.length] = new Option("Information Technology Management","IT Management");
        q2.options[q2.length] = new Option("Leadership","Leadership");
        q2.options[q2.length] = new Option("Management Education","Management Education");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "12PhD") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("Information Technology Education","IT Education");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "2BS") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("General","General");
        q2.options[q2.length] = new Option("Graphics and Multimedia","Graphics and Multimedia");
        q2.options[q2.length] = new Option("Information Assurance and Security","Information Assurance and Security");
        q2.options[q2.length] = new Option("Network Technology","Network Technology");
        q2.options[q2.length] = new Option("Project Management","Project Management");
        q2.options[q2.length] = new Option("Web Application Development","Web Application Development");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "2Online MS") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("General Information Technology","General");
        q2.options[q2.length] = new Option("Information Security","Information Security");
        q2.options[q2.length] = new Option("Network Architecture and Design","Network Architecture and Desig");
        q2.options[q2.length] = new Option("Project Management and Leadership","Project Management/Leadership");
        q2.options[q2.length] = new Option("System Design and Development","System Design and Programming");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "3Online MS") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("K-12 Studies in Education (For Licensed K-12 Teachers)","K-12 Studies in Education");
        q2.options[q2.length] = new Option("Curriculum and Instruction (For Licensed K-12 Teachers)","Curriculum and Instruction");
        q2.options[q2.length] = new Option("Enrollment Management","Enrollment Management");
        q2.options[q2.length] = new Option("Instructional Design for Online Learning","Instr. Design-Online Learning");
        q2.options[q2.length] = new Option("Leadership for Higher Education","Leadership for Higher Ed");
        q2.options[q2.length] = new Option("Leadership in Educational Administration (For Licensed K-12 Teachers)","Leadership in Ed Admin");
        q2.options[q2.length] = new Option("Postsecondary and Adult Education","Postsecondary Adult Ed");
        q2.options[q2.length] = new Option("Professional Studies in Education","Professional Studies in Ed");
        q2.options[q2.length] = new Option("Reading and Literacy (For Licensed K-12 Teachers)","Reading and Literacy");
        q2.options[q2.length] = new Option("Training and Performance Improvement","Train & Perform Improve");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "MS in HR") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("MS in Human Resource Mgmt - General","1405");
        q2.options[q2.length] = new Option("MS in Human Resource Mgmt - Human Capital Mgmt","1406");
        q2.options[q2.length] = new Option("MS in Human Resource Mgmt - Industrial and Labor","1407");
        q2.options[q2.length] = new Option("MS in Human Resource Mgmt - Legal Studies","1408");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "3PhD") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("K-12 Studies in Education (For Licensed K-12 Teachers)","K-12 Studies in Education");
        q2.options[q2.length] = new Option("Curriculum and Instruction (For Licensed K-12 Teachers)","Curriculum and Instruction");
        q2.options[q2.length] = new Option("Instructional Design for Online Learning","Instr. Design-Online Learning");
        q2.options[q2.length] = new Option("Leadership for Higher Education","Leadership for Higher Ed");
        q2.options[q2.length] = new Option("Leadership in Educational Administration","Leadership in Ed Admin");
        q2.options[q2.length] = new Option("Postsecondary and Adult Education","Postsecondary Adult Ed");
        q2.options[q2.length] = new Option("Professional Studies in Education","Professional Studies in Ed");
        q2.options[q2.length] = new Option("Training and Performance Improvement","Train & Perform Improve");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "3MSCert") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("College Teaching","College Teaching");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "32MSCert") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("Enrollment Management","Enrollment Management");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "4Online MS") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("Counseling Studies","Counseling Studies");
        q2.options[q2.length] = new Option("General Human Services","General");
        q2.options[q2.length] = new Option("Health Care Administration","Health Care Admin");
        q2.options[q2.length] = new Option("Management of Nonprofit Agencies","Management of Non-Profit");
        q2.options[q2.length] = new Option("Marital, Couple, & Family Counseling/Therapy - CACREP Accredited","MCF Counseling Therapy");
        q2.options[q2.length] = new Option("Mental Health Counseling - CACREP Accredited","Mental Health Counseling");
        q2.options[q2.length] = new Option("Social and Community Services","Social and Community Services");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "42Online MS") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("Criminal Justice","Criminal Justice");
        q2.options[q2.length] = new Option("Emergency Management","Emergency Management");
        q2.options[q2.length] = new Option("Public Safety Leadership","Public Safety Leadership");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "4PhD") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("Counseling Studies","Counseling Studies");
        q2.options[q2.length] = new Option("General Human Services","General");
        q2.options[q2.length] = new Option("Health Care Administration","Health Care Admin");
        q2.options[q2.length] = new Option("Management of Nonprofit Agencies","Management of Non-Profit");
        q2.options[q2.length] = new Option("Social and Community Services","Social and Community Services");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "42PhD") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("Criminal Justice","Criminal Justice");
        q2.options[q2.length] = new Option("Emergency Management","Emergency Management");
        q2.options[q2.length] = new Option("Public Safety Leadership","Public Safety Leadership");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "5Online MS") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("Clinical Psychology","Clinical");
        q2.options[q2.length] = new Option("Counseling Psychology","Counseling");
        q2.options[q2.length] = new Option("Educational Psychology","Educational Psychology");
        q2.options[q2.length] = new Option("General Psychology","General");
        q2.options[q2.length] = new Option("Industrial/Organizational Psychology","Industrial/Organizational");
        q2.options[q2.length] = new Option("School Psychology","School");
        q2.options[q2.length] = new Option("Sport Psychology","Sport");
        selectValue(q2,value);
    } else if (q1.options[q1.selectedIndex].value == "5PhD") {
        q2.length=0
        q2.options[q2.length] = new Option("Select One","");
        q2.options[q2.length] = new Option("Educational Psychology","Educational Psychology");
        q2.options[q2.length] = new Option("General Psychology","General");
        q2.options[q2.length] = new Option("Industrial/Organizational Psychology","Industrial/Organizational");
        selectValue(q2,value);
    } 
    return;
}

function selectValue(field, value) {
    for (var i = 0; i < field.options.length; i++) {
        if (field.options[i].value == value) {
        field.options[i].selected = true
                return;
        }
    }
    return;
}

function validate_CAPPROGRAM_01() {
    field = window.document.form1.CAPPROGRAM_01;
    value = getFieldValueLB(field)
    if(!validateIsRequired(value)) {
        alert( "Please indicate which area of study are you most interested in." );
        field.focus();
        return false;
    }
    return true;
}

function validate_CAPSPECIALTY_01() {
    field = window.document.form1.CAPSPECIALTY_01;
    value = getFieldValueLB(field)
    if(!validateIsRequired(value)) {
        alert( "Please indicate which program are you most interested in." );
        field.focus();
        return false;
    }
    return true;
}

function validate_CAPUEDUCTN_01() {
    field = window.document.form1.CAPUEDUCTN_01;
    value = getFieldValueLB(field)
    if(!validateIsRequired(value)) {
        alert( "Please indicate what the highest level of education you have completed is." );
        field.focus();
        return false;
    }
    return true;
}

function validate_CAPUTODATE_01() {
    var field1 = window.document.form1.CAPUTODATE_MONTH_01;
    var field2 = window.document.form1.CAPUTODATE_YEAR_01;
    var month = getFieldValueLB(field1);
    var year = getFieldValueLB(field2);
    if(!validateIsRequired(month)) {
        alert( "Please enter a valid date for when you plan on enrolling." );
        field1.focus();
        return false;
    }
    if(!validateIsRequired(year)) {
        alert( "Please enter a valid date for when you plan on enrolling." );
        field2.focus();
        return false;
    }

    var curDate = new Date()
    var curMonth = curDate.getMonth()+1;
    var tempYear = curDate.getYear();
    var curYear = tempYear % 100;
    curYear += (curYear < 38) ? 2000 : 1900;

    if(year<curYear) {
        alert( "Please enter a valid date for when you plan on enrolling." );
        field2.focus();
        return false;
    } else if(curYear==year && month < curMonth) {
        alert( "Please enter a valid date for when you plan on enrolling." );
        field1.focus();
        return false;
    }
    return true;
}

function validate_CAPAGE_01() {
    field = window.document.form1.CAPAGE_01;
    value = getFieldValueLB(field)
    if(!validateIsRequired(value)) {
        alert( "Please indicate age upon enrollment." );
        field.focus();
        return false;
    }
    return true;
}

function showUSStates() {
    var stateField = window.document.form1.STATE_01;
    stateField.enabled = true;
    stateField.length=0;
    stateField.options[stateField.length] = new Option("Select State","");    
    stateField.options[stateField.length] = new Option("Alabama","AL");
    stateField.options[stateField.length] = new Option("Alaska","AK");
    stateField.options[stateField.length] = new Option("American Samoa ","AS");
    stateField.options[stateField.length] = new Option("Arizona","AZ");
    stateField.options[stateField.length] = new Option("Arkansas","AR");
    stateField.options[stateField.length] = new Option("Armed Forces Americas","AA");
    stateField.options[stateField.length] = new Option("Armed Forces Canada","AE");
    stateField.options[stateField.length] = new Option("Armed Forces Europe","AE");
    stateField.options[stateField.length] = new Option("Armed Forces Middle East","AE");
    stateField.options[stateField.length] = new Option("Armed Forces Pacific","AP");
    stateField.options[stateField.length] = new Option("California","CA");
    stateField.options[stateField.length] = new Option("Colorado","CO");
    stateField.options[stateField.length] = new Option("Connecticut","CT");
    stateField.options[stateField.length] = new Option("Delaware","DE");
    stateField.options[stateField.length] = new Option("District of Columbia","DC");
    stateField.options[stateField.length] = new Option("Florida","FL");
    stateField.options[stateField.length] = new Option("Georgia","GA");
    stateField.options[stateField.length] = new Option("Guam","GU");
    stateField.options[stateField.length] = new Option("Hawaii","HI");
    stateField.options[stateField.length] = new Option("Idaho","ID");
    stateField.options[stateField.length] = new Option("Illinois","IL");
    stateField.options[stateField.length] = new Option("Indiana","IN");
    stateField.options[stateField.length] = new Option("Iowa","IA");
    stateField.options[stateField.length] = new Option("Kansas","KS");
    stateField.options[stateField.length] = new Option("Kentucky","KY");
    stateField.options[stateField.length] = new Option("Louisiana","LA");
    stateField.options[stateField.length] = new Option("Maine","ME");
    stateField.options[stateField.length] = new Option("Maryland","MD");
    stateField.options[stateField.length] = new Option("Massachusetts","MA");
    stateField.options[stateField.length] = new Option("Michigan","MI");
    stateField.options[stateField.length] = new Option("Minnesota","MN");
    stateField.options[stateField.length] = new Option("Mississippi","MS");
    stateField.options[stateField.length] = new Option("Missouri","MO");
    stateField.options[stateField.length] = new Option("Montana","MT");
    stateField.options[stateField.length] = new Option("Nebraska","NE");
    stateField.options[stateField.length] = new Option("Nevada","NV");
    stateField.options[stateField.length] = new Option("New Hampshire","NH");
    stateField.options[stateField.length] = new Option("New Jersey","NJ");
    stateField.options[stateField.length] = new Option("New Mexico","NM");
    stateField.options[stateField.length] = new Option("New York","NY");
    stateField.options[stateField.length] = new Option("North Carolina","NC");
    stateField.options[stateField.length] = new Option("North Dakota","ND");
    stateField.options[stateField.length] = new Option("Northern Mariana Islands","MP");
    stateField.options[stateField.length] = new Option("Ohio","OH");
    stateField.options[stateField.length] = new Option("Oklahoma","OK");
    stateField.options[stateField.length] = new Option("Oregon","OR");
    stateField.options[stateField.length] = new Option("Palau","PW");
    stateField.options[stateField.length] = new Option("Pennsylvania","PA");
    stateField.options[stateField.length] = new Option("Puerto Rico","PR");
    stateField.options[stateField.length] = new Option("Rhode Island","RI");
    stateField.options[stateField.length] = new Option("South Carolina","SC");
    stateField.options[stateField.length] = new Option("South Dakota","SD");
    stateField.options[stateField.length] = new Option("Tennessee","TN");
    stateField.options[stateField.length] = new Option("Texas","TX");
    stateField.options[stateField.length] = new Option("U.S. Virgin Islands","VI");
    stateField.options[stateField.length] = new Option("Utah","UT");
    stateField.options[stateField.length] = new Option("Vermont","VT");
    stateField.options[stateField.length] = new Option("Virginia","VA");
    stateField.options[stateField.length] = new Option("Washington","WA");
    stateField.options[stateField.length] = new Option("West Virginia","WV");
    stateField.options[stateField.length] = new Option("Wisconsin","WI");
    stateField.options[stateField.length] = new Option("Wyoming","WY");
}

function showCANStates() {
    var stateField = window.document.form1.STATE_01;
    stateField.enabled = true;
    stateField.length=0;
    stateField.options[stateField.length] = new Option("Select State","");
    stateField.options[stateField.length] = new Option("Alberta","AB");
    stateField.options[stateField.length] = new Option("British Columbia","BC");
    stateField.options[stateField.length] = new Option("Manitoba","MB");
    stateField.options[stateField.length] = new Option("New Brunswick","NB");
    stateField.options[stateField.length] = new Option("Newfoundland","NF");
    stateField.options[stateField.length] = new Option("Northwest Territories","NT");
    stateField.options[stateField.length] = new Option("Nova Scotia","NS");
    stateField.options[stateField.length] = new Option("Ontario","ON");
    stateField.options[stateField.length] = new Option("Prince Edward Island","PE");
    stateField.options[stateField.length] = new Option("Quebec","QC");
    stateField.options[stateField.length] = new Option("Saskatchewan","SK");
    stateField.options[stateField.length] = new Option("Yukon Territory","YT");
    }

function initState() {
	//manually setting country to USA since we've removed the question (see LDG-2395)
    var countryValue = "USA";
    var stateField = window.document.form1.STATE_01;
    var value = getFieldValueLB(stateField);
    if(countryValue == "USA") {
     showUSStates();
    } else if (countryValue == "CAN") {
        showCANStates();
    }  else {
        stateField.length=0;
    stateField.options[stateField.length] = new Option("Select State","");    
        stateField.disabled = true;
        return;
    }
    selectValue(stateField,value);
    stateField.disabled = false;
    return;
}

function validate_MILITARY_01() {
    field = window.document.form1.MILITARY_01;
    value = getFieldValueRB(field)
    if(!validateIsRequired(value)) {
        alert("Please select are you associated with the United States Military.");
        return false;
    }
    return true;
}

function sortListBox(listBoxField, defaultSelectedText) {
	var selectBox = listBoxField;
	var selectArray = new Array();

	for (i = 0; i < selectBox.length; i++) {
	    selectArray[i] = new Array();
	    selectArray[i][0] = selectBox.options[i].text;
	    selectArray[i][1] = selectBox.options[i].value;
	}

	selectArray.sort();
	
	selectBox.length = 0;
	if (defaultSelectedText && defaultSelectedText.length > 0){
		selectBox.options[selectBox.length] = new Option(defaultSelectedText, "");
	}
	
	for (j = 0; j < selectArray.length; j++) {
	    selectBox.options[selectBox.length] = new Option(selectArray[j][0], selectArray[j][1]);
	}
} 
