﻿//----------------------------------------------------------
// CascadingDropDownList Complement
//----------------------------------------------------------

function bindDropDownList(e, targetDropDownList) {
    var key = this.value;
    var allOptions = targetDropDownList.allOptions;
    var option;
    var newOption;
    targetDropDownList.options.length = 0;

    for (var i = 0; i < allOptions.length; i++) {
        option = allOptions[i];
        if (option.key == key) {
            if (targetDropDownList.options.length == 0) addFirstRow(e, targetDropDownList);
            newOption = new Option(option.text, option.value);
            targetDropDownList.options.add(newOption);
        }
    }

    targetDropDownList.disabled = (targetDropDownList.options.length==0);
    
}

function addFirstRow(e, targetDropDownList) {
    newOption = new Option(targetDropDownList.firstRowText, 0);
    targetDropDownList.options.add(newOption);
}

function ToggleFS(obj) {  childs = $(obj).parent().children("div");   childs.toggle("fast") }


function InternalMenuDisplayGo(id, length) {
    for (var i = 1; i < length + 1; i++) {
        if (id == i)
        { $(document.getElementById('Menu' + i).className="Selected"); $(document.getElementById('Text' + i)).show('fast'); }
        else
        { $(document.getElementById('Menu' + i).className = "Item"); $(document.getElementById('Text' + i)).hide('fast'); }
    }
}

function AutoFillTbDate(object,defaultCentury) {
    if ((object.value.length == 2) && (window.event.keyCode > 8)) {object.value = object.value + '/'; }
    if ((object.value.length == 5) && (window.event.keyCode > 8)) { object.value = object.value + '/' + defaultCentury; }
    if ((object.value.length > 10) && (window.event.keyCode > 8)) { object.value = object.value.substring(0,10);}
}
function AutoFillTbDateTime(object, defaultCentury) {
    if ((object.value.length == 2) && (window.event.keyCode > 8)) { object.value = object.value + '/'; }
    if ((object.value.length == 5) && (window.event.keyCode > 8)) { object.value = object.value + '/' + defaultCentury; }
    if ((object.value.length == 10) && (window.event.keyCode > 8)) { object.value = object.value + ' '; }
    if ((object.value.length == 13) && (window.event.keyCode > 8)) { object.value = object.value + ':'; }
    if ((object.value.length > 16) && (window.event.keyCode > 8)) { object.value = object.value.substring(0, 16); }
}
