﻿//// Do not add this event method to Result (see similar function in ResultScript.js), ActionChoice (not needed) and FinalClosing (not needed) pages!
//function keypressHandler(e) {
//    alert("1");
//    if (document.selection) { // IE
//        if (e.which == 13) {
//            alert("2");
//            $(this).blur();
//            $("#Weiter").focus().click();
//        }
//    }
//}

// Do not add this event method to the following sites:
// - Result (see similar function in ResultScript.js), 
// - ActionChoice (not usable, because having there two "Weiter" buttons) 
// and 
// - FinalClosing (dicided not to use it there to prevent closing a contract by clicking return key)!
function keypressHandler(e) {
    //alert("in keypressHandler");
    var forceSubmit = isReturnKeyPressed(e);
    if (forceSubmit) {
        if (($('#loginFrameWrapper').is(":visible")) || ($('#resetFrameWrapper').is(":visible"))) {
            if ($('#resetFrameWrapper').is(":visible")) {
                $("#weiterreset").focus().click();
            }
            else {
                $("#loginpopup").focus().click();
            }
        }
        else{
            $("#Weiter").focus().click();
        }
    }
}

// Only called from FinalClosingView
// Needed because otherwise would be jumped back to last Closing site!
function suppressReturnKey(e) {
    var srcEl = e.srcElement ? e.srcElement : e.target; 
    switch (srcEl.id) {                     // allow <return> keypress in ...
        case 'Data_Remarks_From_Customer':  // textarea field
        case 'previousButton':              // back button
        case 'Weiter':                      // and forward button
            return true;
    }
   
    var suppressSubmit = isReturnKeyPressed(e);
    //alert("suppress = " + suppressSubmit);
    if (suppressSubmit) {
        //alert("suppress submit");
        return false;
    }
    return true; 
}

function isReturnKeyPressed(e) {
    var code = (e.keyCode ? e.keyCode : e.which);
    if (code == 13)
        return true;
    return false;
}
