//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------

//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------

var bSearchFieldChanged = false;

//--------------------------------------------------------------------------------

//--------------------------------------------------------------------------------
//	KeyPress Handler -------------------------------------------------------------
//--------------------------------------------------------------------------------

function fnKeyPress (evt)
{
	var oEvent = null, oNode = null, sValue = "", nKeyCode = 0;
	oEvent = (evt) ? evt : ((window.event) ? event : null);

	if (oEvent)
		oNode = (oEvent.target) ? oEvent.target : oEvent.srcElement;

	if (oNode)
		nKeyCode = (oEvent.charCode) ? oEvent.charCode : ((oEvent.which) ? oEvent.which : oEvent.keyCode);

 	if (nKeyCode == 13)
 	{
		if (oNode.id == "txtSearchField")
			if ((sValue = oNode.value).search (/^\s*$/) == -1)
				if ((sValue = sValue.replace (/^\s+/g, "").replace (/\s+$/g, "")).length > 2)
				{
					oNode.value = sValue;
					if (oNode.form)
					{
						oNode.form.submit ();
						return false;
					}
				}
	}

	else
		return true;

	oEvent.cancelBubble;
	return false;
}

//--------------------------------------------------------------------------------
//	For Search Form: check-up before Submit --------------------------------------
//--------------------------------------------------------------------------------

function fnCheckForSearchSubmit (evt)
{
	var oEvent = null, oNode = null, oForm = null, sValue = "";

	oEvent = (evt) ? evt : ((window.event) ? event : null);
	if (oEvent)
		oForm = (oEvent.target) ? oEvent.target : oEvent.srcElement;

	if (oNode = oForm.elements ["txtSearchField"])
		if (bSearchFieldChanged)
			if ((sValue = oNode.value).search (/^\s*$/) == -1)
				if ((sValue = sValue.replace (/^\s+/g, "").replace (/\s+$/g, "")).length > 2)
				{
					oNode.value = sValue;
					return true;
				}

	return false;
}

//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
