function InitialControls() {
    valueChanged();
    var ListBox = wijmo.Control.getControl("#lbListBox");
    selectedIndexChanged(ListBox);
}

// Input Date & Time valueChanged event handler
function valueChanged(sender) {
    if (document.getElementById("iditInputDate") && document.getElementById("iditInputTime") && document.getElementById("iditSelectedValue")) {
        var inputDate = wijmo.Control.getControl("#iditInputDate");
        var inputTime = wijmo.Control.getControl("#iditInputTime");
        // get new date from the two controls using Wijmo utility functions
        var val = wijmo.DateTime.fromDateTime(inputDate.value, inputTime.value);
        // format and display the new date
        document.getElementById('iditSelectedValue').innerHTML = wijmo.Globalize.format(val, 'MMM dd, yyyy h:mm:ss tt');
    }
}

//selectedIndexChanged event handler
function selectedIndexChanged(sender) {
    //set selectedIndex and selectedValue text
    if (document.getElementById("lbListBox") && document.getElementById("lbSelIdx") && document.getElementById("lbSelVal")) {//if (document.readyState === "complete") {
        document.getElementById('lbSelIdx').innerHTML = sender.selectedIndex;
        document.getElementById('lbSelVal').innerHTML = sender.selectedValue;
    }
}

// InputMask valueChanged event handler
function MaskvalueChanged(sender) {
    var customMaskTrial = wijmo.Control.getControl("#imCustomTrial");
    customMaskTrial.mask = sender.value;
    customMaskTrial.hostElement.title = 'Mask: ' + (sender.value || 'N/A');
}

function itemClicked(sender) {
    alert('You\'ve selected option ' + sender.selectedIndex + ' from the ' + sender.header + ' menu!');
}

function execute(arg) {
    var inputNumber = wijmo.Control.getControl("#mInputNumber");

    // convert argument to Number
    arg = wijmo.changeType(arg, wijmo.DataType.Number);

    // check if the conversion was successful
    if (wijmo.isNumber(arg)) {

        // update the value
        inputNumber.value += arg;
    }
}

function canExecute(arg) {
    var inputNumber = wijmo.Control.getControl("#mInputNumber");

    // convert argument to Number
    arg = wijmo.changeType(arg, wijmo.DataType.Number);

    // check if the conversion was successful
    if (wijmo.isNumber(arg)) {
        var val = inputNumber.value + arg;

        // check if the value is valid
        return val >= 0 && val <= 1;
    }

    return false;
}