﻿jQuery(document).ready(function() {
    hideUnlicensedMessage();
});

function hideUnlicensedMessage() {
    // this instance is licensed, but may be referenced from different domain.
    // so we want to hide a message.
    $("div[align='center']:contains('RUNNING UNLICENSED')").hide();

}


// -------
// allow floating numbers values to be entered only
// -------
function allowFloat(event) {
    var keyval = window.event ? window.event.keyCode : event.which;

    if (!(((keyval >= 48) && (keyval <= 57)) || (keyval == 46))) {
        // if value not digit, suppress this (code depends on browser)
        if (!window.XMLHttpRequest) {
            window.event.keyCode = null;
        }
        else if (navigator.userAgent.toLowerCase().indexOf("msie") > -1) {
            window.event.keyCode = null;
        }
        else {
            if (!((keyval == 0) || (keyval <= 8))) {
                event.preventDefault();
            }
        }
    }
}

// -------
// allow numeric values to be entered only
// -------
function allowNumber(event) {
    var keyval = window.event ? window.event.keyCode : event.which;

    if (!(keyval >= 48 && keyval <= 57)) {
        // if value not digit, suppress this (code depends on browser)
        if (!window.XMLHttpRequest) {
            window.event.keyCode = null;
        }
        else if (navigator.userAgent.toLowerCase().indexOf("msie") > -1) {
            window.event.keyCode = null;
        }
        else {
            if (!((keyval == 0) || (keyval <= 8))) {
                event.preventDefault();
            }
        }
    }
}

function isNumber(n) {
    return !isNaN(parseFloat(n)) && isFinite(n);
}

String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "");
}

String.prototype.ltrim = function () {
    return this.replace(/^\s+/, "");
}

String.prototype.rtrim = function () {
    return this.replace(/\s+$/, "");
}

function AccountMaritalStatus_OnChange() {
    if ($("select[id*='ddlMarital']").val() == 'Single') {
        $("[id*='trSpouse']").hide();
    }
    else {
        $("[id*='trSpouse']").show();

        // default last name
        var currentLastName = $("input[id$='txtSpouseLastName']").val();
        if (currentLastName != undefined && currentLastName.length == 0) {
            var lastName = $("input[id$='_txtLastName']").val();
            $("input[id$='txtSpouseLastName']").val(lastName);
        }
    }
}
