﻿function ValidateCombo() {
    var form = getObjForm("RegistrationForm");
    var m_array = new Array(3);
    var i, j;
    var check;
    var obj;

    //-----------------------------------
    // Market / Application
    //-----------------------------------
    check = true
    for (i = 1; i < 3; i++) {
        m_array[i] = "";
        obj = eval("form.USREG_00_Market_Level" + i + "_1")
        if (obj) {
            if (document.layers)
                m_array[i] = m_array[i] + obj.value;
            else
                m_array[i] = m_array[i] + obj[obj.selectedIndex].value;
        }
        // check if at least one market / application is selected
        if (m_array[i] != "")
            check = false;

        // check if a market / application has been selected two times
        for (j = i - 1; j > 0; j--) {
            if (m_array[i] == m_array[j] && m_array[i] != "") {
                alert("You have entered several times the same market / application.");
                return true;
            }
        }
    }
    if (check) {
        alert("Please choose at least one market / application.");
        form.USREG_00_Market_Level1_1.focus();
        return true;
    }

    //-----------------------------------
    // Adhesive / Sealant
    //-----------------------------------
    check = true
    for (i = 1; i < 3; i++) {
        m_array[i] = "";
        obj = eval("form.USREG_00_AdhesiveSealant_Level" + i + "_1")
        if (obj) {
            if (document.layers)
                m_array[i] = m_array[i] + obj.value;
            else
                m_array[i] = m_array[i] + obj[obj.selectedIndex].value;
        }
        // check if at least one adhesive / sealant is selected
        if (m_array[i] != "")
            check = false;

        // check if a adhesive / sealant has been selected two times
        for (j = i - 1; j > 0; j--) {
            if (m_array[i] == m_array[j] && m_array[i] != "") {
                alert("You have entered several times the same adhesive / sealant.");
                return true;
            }
        }
    }
    if (check) {
        alert("Please choose at least one adhesive / sealant.");
        form.USREG_00_AdhesiveSealant_Level1_1.focus();
        return true;
    }

    //-----------------------------------
    // Polymer
    //-----------------------------------
    check = true
    for (i = 1; i < 3; i++) {
        m_array[i] = "";
        for (j = 1; j < 6; j++) {
            obj = eval("form.USREG_00_Polymer_Level" + i + "_" + j)
            if (obj) {
                if (document.layers)
                    m_array[i] = m_array[i] + obj.value;
                else
                    m_array[i] = m_array[i] + obj[obj.selectedIndex].value;
            }
        }
        // check if at least one polymer is selected
        if (m_array[i] != "")
            check = false;

        // check if a A&S has been selected two times
        for (j = i - 1; j > 0; j--) {
            if (m_array[i] == m_array[j] && m_array[i] != "") {
                alert("You have entered several times the same polymer.");
                return true;
            }
        }
    }
    if (check) {
        alert("Please choose at least one polymer.");
        form.USREG_00_Polymer_Level1_1.focus();
        return true;
    }

    //-----------------------------------
    // Specific Questions
    //-----------------------------------
    if (USREG_00_Activity.selectedIndex == 1 || USREG_00_Activity.selectedIndex == 2) {
//        for (i = 0; i < form.length; i++) {
//            if (form[i].type == "radio" && form[i].name.indexOf("USREG_00_DifferentiatedProducts") != -1 && form[i].checked) {
//                return false;
//            }
//        }
//        alert("Please tell us if you have differentiated products or unique solutions.");
//        return true;

        // Technology Focus
        if (isNull(USREG_00_TechnologyFocus.value)) {
            alert("Please specify your main product / technology focus.");
            USREG_00_TechnologyFocus.focus();
            return true;
        }
        // Main Role
        if (USREG_00_MainRole.selectedIndex == 0) {
            alert("Please specify your main role.");
            USREG_00_MainRole.focus();
            return true;
        }
        // Technology Differentiation
        if (USREG_00_TechnologyDifferentiation.selectedIndex == 0) {
            alert("Please specify how differentiated is the product or technology you focus on.");
            USREG_00_TechnologyDifferentiation.focus();
            return true;
        }
        // Market Reach
        if (USREG_00_MarketReach.selectedIndex == 0) {
            alert("Please specify your current reach at your target markets.");
            USREG_00_MarketReach.focus();
            return true;
        }
        // Project dynamic
        if (USREG_00_ProjectDynamic.selectedIndex == 0) {
            alert("Please specify your current project dynamic.");
            USREG_00_ProjectDynamic.focus();
            return true;
        }
    }
}

