//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// EcSys.js
// ABW BW 6.0
// Client System Script
// Copyright (c) 2006-2009 Richcorp Technology
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Variables
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

// Submit flag

Subflg = false;                                                                                                               // submit flag

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Test function
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function test()
{
  alert("Test");
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Force upper case text function
// 1. This function only works on the text field after moving the keyboard or mouse to another field (*)
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function setuprcas(Fldobj)
{
  Fldobj.value = Fldobj.value.toUpperCase();                                                                                  // set field value to upper case
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Force lower case text function
// 1. This function only works on the text field after moving the keyboard or mouse to another field (*)
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function setlowcas(Fldobj)
{
  Fldobj.value = Fldobj.value.toLowerCase();                                                                                  // set field value to lower case
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Set field background colour
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function setbakclr(Fldobj, Clrstr)
{
  Fldobj.style.backgroundColor = Clrstr;                                                                                      // set field background colour
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Submit form button event
// 1. Subfnc = submit finalization function (optional)
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function subfrmbtnevt(Subfnc)
{
  if (!Subflg)                                                                                                                // submit flag not set?
  {
    if (Subfnc != null)
    {
      if (!Subfnc()) return false;                                                                                            // submit function specified?
    }
    Subflg = true;                                                                                                            // set submit flag
    return true;                                                                                                              // return ok to submit
  }
  else
  {
    return false;                                                                                                             // return no submit
  }
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Disable enter key on form
// 1. Subfnc = submit finalization function (optional) (*)
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function disent(Keyevt)
{
  if (window.event)
    key = window.event.keyCode;                                                                                               // IE
  else
    key = Keyevt.which;                                                                                                       // firefox

  if (key == 13)                                                                                                              // return key?
    return false;                                                                                                             // block action
  else
    return true;                                                                                                              // propagate action
}

document.onkeypress = disent;                                                                                                 // set on keypress event
