﻿function AutoFocus(nameOfTextBoxToCheck, nameOfTextBoxToFocus) {   
    var textBoxToCheck
    var textBoxToFocus
    // Get a list if textboxes
    var _textBoxes = document.getElementsByTagName("input");
    // Loop through all textboxes
    for (var i = 0; i < _textBoxes.length; i++) {
        // Get a reference to the first part of the phone number
        if (_textBoxes[i].id.indexOf(nameOfTextBoxToCheck) > -1) {
            textBoxToCheck = document.getElementById(_textBoxes[i].id);
        }
        // Get a reference to the second part of the phone number
        if (_textBoxes[i].id.indexOf(nameOfTextBoxToFocus) > -1) {
            textBoxToFocus = document.getElementById(_textBoxes[i].id);
        }
    }

    // If the length if the first part is 3
    if (textBoxToCheck.value.length == 3) {
        textBoxToFocus.focus();
    }
}

function submitForEnterPress(e) {

    //alert(e);
    //define any varible
    var KeyPress

    //if which property of event object is supported
    if (e && e.which) {
        e = e
        //character code is contained in NN4's which property
        KeyPress = e.which
    }
    else {
        e = event
        KeyPress = e.keyCode
    }
    //alert(KeyPress);
    //13 is the key code of enter key
    if (KeyPress == 13) {
        //frmLogin is the name of form
        document.frmLogin.submit()
        return false
    }
    else {
        return true
    }
}  
