function typeOf(value) {
    var s = typeof value;
    if (s === 'object') {
        if (value) {
            if (typeof value.length === 'number' &&
                    !(value.propertyIsEnumerable('length')) &&
                    typeof value.splice === 'function') {
                s = 'array';
            }
        } else {
            s = 'null';
        }
    }
    return s;
}

function isEmpty(o) {
    var i, v;
    if (this.typeOf(o) === 'object') {
        for (i in o) {
            v = o[i];
            if (v !== undefined && this.typeOf(v) !== 'function') {
                return false;
            }
        }
    }
    return true;
}

/*
Disables a button for 3 seconds. Adds timer that counts down from 3 onto the button.
*/
function buttonTimer(button) {
     button.attr('disabled', true);
     var label = button.attr('value');
     button.attr('value',  label + ' (3)');
     setTimeout(function() { button.attr('value',  label + ' (2)'); }, 1500);
     setTimeout(function() { button.attr('value', label + ' (1)'); }, 3000);
     setTimeout(function() {
        button.attr('value', label);
        button.attr('disabled', false); 
     }, 4500);
}

