﻿// transform <enter> into <tab>
window.onload = function () {

    var textfields = document.getElementsByTagName('input');

    for (var i = 0, count = textfields.length; i < count; i++) {
        if (textfields[i].type == 'text') {
            textfields[i].onkeypress = function (e) {
                if (!e) var e = window.event;
                if (e.keyCode == 13) {

                    var curr = this.nextSibling;
                    var type;

                    do {
                        type = (curr.nodeName).toLowerCase();

                        if (type == 'input' || type == 'select' || type == 'textarea' || type == 'button') {
                            curr.focus();
                            break;
                        }
                    } while (curr = curr.nextSibling)

                    return false;
                }
            }
        }
    }
}
