function tabOnEnter()

{	

	// First, handdle short-cut key navigation using Back Space or Alt + Arrow keys... The only reason why this is done here

	// is because we experience problems...when at the last field of a form, insteaed of simply tabbing, it would both tab

	// and submit the form to be saved. Having this code here takes care of that problem.

	specialKeyPressed();



	var keyPressed = window.event.keyCode;

	if(keyPressed == 13)

	{

		if(!blnIsClickable)

		{

			if(strNextType != "")

			{

				var top = currentField.form.elements.length;

				for(x = currentField.tabIndex; x < top; x++)

				{

					if(currentField == currentField.form.elements[x])

					{

						for(y = x+1; y < top; y++)

						{

							if((currentField.form.elements[y].type == strNextType ||

								currentField.form.elements[y].type == "button") &&

							   currentField.form.elements[y].disabled == false && 

							   currentField.form.elements[y].readOnly == false)

							{

								currentField.form.elements[y].focus();

								return false;

							}

						}

					}

				}

			}

			else

			{

				var top = currentField.form.elements.length;

				for(x = currentField.tabIndex; x < top; x++)

				{

					if(currentField == currentField.form.elements[x])

					{

						// Give focus to next field...If last item, give focus to first...

						if(currentField.form.elements.length > x+intSkip)

						{

							// First check to see if the next field is disabled or not...

							if(currentField.form.elements[x+intSkip].disabled != true && 

							   currentField.form.elements[x+intSkip].type != 'hidden' &&

							   currentField.form.elements[x+intSkip].readOnly != true)

							{

								try

								{

									currentField.form.elements[x+intSkip].focus();

								}

								catch(error)

								{

									// Skip to next field if there is an error...

									setCurrentField(currentField.form.elements[x+intSkip]);

									tabOnEnter();

								}

							}

							else

							{

								// Skip if next field is disabled...

								setCurrentField(currentField.form.elements[x+intSkip]);

								tabOnEnter();

							}

						}

						else

						{

							// Go back to first item...

							focusFirstField(currentField.form);

						}

						// Return false to prevent the 'ENTER' effect...

						return false;

					}

				}

			}

		}

	}

}
/*******************************************************************/

/* Functions used to simulate a [TAB] when [ENTER] is pressed...

   tabOnEnter function is automatically added to document.onKeyDown event

   IN: form input object          USAGE: onFocus="setCurrentField(this)" 

   AUTHOR: Team Ryan and Victor   DATE: 11/18/2003 */

/* UPDATE: USAGE: onFocus="setCurrentField(this[, true])"

   The optional true parameter is used for button objects that should be clickable

   This bypasses the standard action of focusing on the next object, and

   instead performs a click() on the button is question.

   AUTHOR: Lincoln and Victor     DATE: 11/19/2003 */	

document.onkeydown = tabOnEnter; // work together to analyze keystrokes	



currentField = null;

intSkip = null;

blnIsClickable = false;

strNextType = "";

function setCurrentField()

{

	// if the field being passed is already the currentField, reset the error variables

	// attempted to fix bug #317 by VSANCHEZ and RGEESAMA and related to bug 139...


	currentField = arguments[0];

	

	// If this is a text box or a text area, select it as well...

	if((currentField.type == 'text' || currentField.type == 'textarea') && currentField.disabled == false && currentField.readOnly == false)

	{

		currentField.select();

	}

	

	if(arguments[2] != null)

	{

		intSkip = arguments[2];

	}

	else

	{

		intSkip = 1;

	}

	

	if(arguments[1] != null)

	{

		blnIsClickable = arguments[1];

	}

	else

	{

		blnIsClickable = false;

	}

	

	if(arguments[3] != null)

	{

		strNextType = arguments[3];

	}

	else

	{

		strNextType = "";

	}

}



function setTabIndexes()

{	

	var top = document.forms[0].elements.length;

	var theForm = document.forms[0];		

	for(x = 0; x < top; x++)

	{

		theForm.elements[x].tabIndex = x;

	}	

}	

// Author: Victor Sanchez

// Date: January 9, 2004

// The following code is used to prevent the user from navigating the browser using special key-combitations...

function specialKeyPressed() 

{		

   // For debugging, these values are displayed in the status bar...

   //self.status="" + "shiftKey="+ event.shiftKey + ", altKey="  + event.altKey+ ", ctrlKey=" + event.ctrlKey + ", keyPressed=" + event.keyCode; 

	

	// Prevent page navigation using special key combitations...

	/* 

		keyCode == 8 - Means that the "Back Space" key was pressed which can navigate backwards if no input fields selected...

		altKey == true and event.keyCode == 37, 39 - Alt + [right or left]Arrow key which can be used to navigate...

	*/

	var strEmptyString = "Cannot use short-cut navigation.";

	if(event.altKey == true && (event.keyCode == 37 || event.keyCode == 39))

	{

		window.event.returnValue = false;

	}

	

	// Handle "Back Space" key-stroke...

	if(event.keyCode == 8)

	{

		if(document.forms.length > 0 && currentField != null && 

		   (currentField.type == "text" || currentField.type == "textarea" || currentField.type == "password") &&

		   currentField.style.readOnly == false)

		//Added condition to only "press" backspace if the currentField type is text, textarea, or password.  This was done because it was allowing backspace to be

		//pressed when a select box was highlighted.  See bug #0000147.

		{

			currentField.focus();

		}

		else

		{

			event.keyCode = null;  // Prevent backwards navigation...

		}

	}
}