//==============================
// default.js
/// <summary>
/// Default script file to include to all pages.<BR/>
/// Alexey Oleynik<BR/>
/// ProLogic Corporation<BR/>
/// 12/12/2005
/// </summary>
//==============================
//Revision History
//Date        Author          Description
//12/12/2005  Alexey Oleynik  Created
//12/13/2005  Alexey Oleynik  Check control for enabled and visible before focusing in the setFocusedControl.
//==============================

//------------------------------------------------------------------------------
/// <summary>
/// Imitates button click.<BR/>
/// Alexey Oleynik<BR/>
/// ProLogic Corporation<BR/>
/// 12/12/2005
/// </summary>
/// <param name="buttonId">ID of the button</param>
//==============================
//Revision History
//Date        Author          Description
//12/12/2005  Alexey Oleynik  Created
//==============================
function pressButton(buttonId)
{
  var key = window.event.keyCode; 
  if (key == 13 && ! window.event.altKey && ! window.event.shiftKey && ! window.event.ctrlKey) 
  {
    window.event.returnValue = false; 
    window.event.cancelBubble = true;
    var button = getDomObject(buttonId);
    if (button != null) 
    {
      button.click();      
    }
  }
}
//------------------------------------------------------------------------------
// <summary>
/// Finds DOM object by ID.<BR/>
/// Alexey Oleynik<BR/>
/// ProLogic Corporation<BR/>
/// 12/12/2005
/// </summary>
/// <param name="id">ID of the DOM object</param>
/// <returns>DOM object with the given ID</returns>
//==============================
//Revision History
//Date        Author          Description
//12/12/2005  Alexey Oleynik  Created
//==============================
function getDomObject(id)
{
  var obj = document.getElementById(id);
  return obj;
}
//------------------------------------------------------------------------------
/// <summary>
/// Sets given control as focused.<BR/>
/// Alexey Oleynik<BR/>
/// ProLogic Corporation<BR/>
/// 12/12/2005
/// </summary>
/// <param name="controlId">ID of the control</param>
//==============================
//Revision History
//Date        Author          Description
//12/12/2005  Alexey Oleynik  Created
//01/06/2005  Alexey Oleynik  Check for enabled was added
//==============================
function setFocusedControl(controlId) 
{ 
	var ctrl = getDomObject(controlId); 
	if (ctrl != null)
	{ 
	    if(ctrl.enabled || !ctrl.disabled)
	    {
			  ctrl.focus(); 
			}
	} 
}
//------------------------------------------------------------------------------
