//
//    this function is for the quick order entry screen
//
//    its purpose is to allow the user to simply hit enter
//    anywhere on the page and cause it to "submit" the form
//
//    it is not actually submitting the form, as the "submit" button
//    is really acting on the "onclick=" event handler to invoke
//    quickAddToCart (as the default or a different function if it is supplied), so this function does the same thing
//    when it is invoked
//
//    this function is triggered by the onkeydown= event on each field
//    that is in the form
//
//    in addition, this creen has a "dropdown" feature on the
//    sku field which gives then suggestions as to the sku they
//    are entering based on the characters they have entered so far.
//
//    as in that case they can then navigate this list of suggestions
//    and click on the want OR HIT ENTER AS WELL, you do not want that
//    "enter" to cause it to function as a "submit", so the way to prevent
//    that is to see if at the time of the "enter" if the dropdown exists
//    (as it is dynamically added to the DOM when it appears) so the way to
//    do that is to check for the "ID" that the auto suggest function creates.
//
//    The id it creates is of the form "as_" + id of the field. So check
//    if this exists in the DOM and if so, DO NOT "SUBMIT" the form
//
function enterSubmit(thisButton,e,func) {
//    alert("entering enterSubmit");
//    alert("Number of args = " + arguments.length);
    var evt = window.event || e;
//    alert("evt = " + evt);
//    alert("this = " + thisButton);
//    alert("this form name = " + thisButton.form.name);
//    alert("evt.keycode = " + evt.keyCode);
//    alert("evt.which = " + evt.which);
    if ((evt.keyCode == 13
           ||
        evt.which == 13)
            &&
      !$("as_" + thisButton.id)) {
//        alert("This id = " + thisButton.id);
//        alert("This class = " + thisButton.className);
//        alert("this tag name = " + thisButton.tagName);
//        alert("calling quickAddTOCart");
        if (typeof func == "function") {
            func(thisButton);
        }
        else {
            quickAddToCart(thisButton);
        }
        
    }
}

