﻿
SetupMutiStepForm();

function SetupMutiStepForm() {


    if (document.getElementById("CFE_1") != null)
        document.getElementById("ctl00_btnPost").style.display = "none";

    for (var s = 0; s < 10; s++) {
        var div = document.getElementById("CFE_" + s);
        var btm = document.createElement("input");
        if (div != null) {

            btm.id = "btmNext_" + s;
            btm.onclick = function() {
                Next_Click(this);
            }
            btm.setAttribute("type", "button");
            btm.setAttribute("value", " Next");

            if (document.getElementById("CFE_" + (s + 1)) != null) {
                try { div.appendChild(btm, null); }
                catch (ex) { div.add(btm); } // IE only                    
            }
        }
        else
            break;
    }
}

function Next_Click(o) {
    var bIsValid = IFpageNext();
    if (!bIsValid) {
        document.getElementById("CFE_" + (parseInt(o.id.substring(8)) + 0)).style.display = "";
        document.getElementById("CFE_" + (parseInt(o.id.substring(8)) + 1)).style.display = "none";

    } else {


        if (window["Event_CFE_" + (parseInt(o.id.substring(8)) + 0)])
            window["Event_CFE_" + (parseInt(o.id.substring(8)) + 0)](o);

        document.getElementById("CFE_" + (parseInt(o.id.substring(8)) + 0)).style.display = "none";
        document.getElementById("CFE_" + (parseInt(o.id.substring(8)) + 1)).style.display = "";
        document.getElementById("ctl00_btnPost").style.display = "";

    }
}

function IFpageNext() {
    if (!validatePage(formPages[currentPageNumber])) {
        alert(validationErrorMessage);
        return false;
    } else {
        return true;
    }

}

