
function submitenter(myfield,e) {
  var keycode;
  if (window.event)
     keycode=window.event.keyCode;
  else if (e)
     keycode=e.which;
  else
    return true;

  if (keycode==13) { 
    myfield.form.submit();
    return false;
  }
  else
    return true;
}


Event.observe( window, 'load', function() {
	setFrmSubmit();
});


function setFrmSubmit() {
    if ($("modalForm")) {
        var allInputs = $("modalForm").getElementsByTagName("INPUT");
        var inpNodes = $A(allInputs);
        inpNodes.each(function(inp) { 
            var inpType = inp.getAttribute('type').toLowerCase();
            switch ( inpType ){
                case 'checkbox' :
                case 'radio' :
                case 'text' :
                case 'password' :
                    var keyUpEvent = function(e) { return submitenter(this, e); }
                    Event.observe(inp, 'keypress', keyUpEvent, false);
            }
        })
    } else {
        var pCont = $("pContent");
        var allInputs = pCont.getElementsByTagName("INPUT");
        var inpNodes = $A(allInputs);
        inpNodes.each(function(inp) { 
            var inpType = inp.getAttribute('type').toLowerCase();
            switch ( inpType ){
                case 'checkbox' :
                case 'radio' :
                case 'text' :
                case 'password' :
                    var keyUpEvent = function(e) { return submitenter(this, e); }
                    Event.observe(inp, 'keypress', keyUpEvent, false);
            }
        })
    }
}
