function cancelBubble(e)
{
  if (window.event)
  {
    window.event.cancelBubble = true;
  }
  if (e && e.stopPropagation)
  {
    e.stopPropagation();
  }
}

function cancelDefault(e)
{
  if (window.event && window.event.returnValue)
  {
    window.event.returnValue = false;
  }
  if (e && e.preventDefault)
  {
    e.preventDefault();
  }
}

function cancelAll(e)
{
  cancelBubble(e);
  cancelDefault(e);
}

/****************************************************************************
*** ShortCut Enter Key Handler functions
****************************************************************************/
function checkEnterHotKey(linkId, e)
{
	
    //CO-10538 - McElheron - IE uses global events but firefox needs them passed explicitly
    var e = e || event;
   //Handle Enter key being pressed for panel
   if (e.keyCode == 13 || e.which == 13) 
   {
      if(!e.altKey && !e.ctrlKey && !e.shiftKey)
      {
        var target = e.target || e.srcElement;
        if(!checkForClickableActiveElements(target, target.tagName.toLowerCase()))
        {
           // apply any UI formatting before firing hotkey
           forceFormatting(target); 
           
           cancelAll(document.getElementById(linkId));
           handleClick(document.getElementById(linkId))
        }
      }
   }
   return;
}

function checkForClickableActiveElements(target,tagName)
{
    if(tagName == "input")
    {
        //remove document.activeElement as it is IE proprietary
        //if(document.activeElement.type == "button" || 
        //   document.activeElement.type == "image" || 
        //   document.activeElement.type == "submit" || 
        //   document.activeElement.type == "reset")
        
        if(target.type == "button" ||
           target.type == "image" ||
           target.type == "submit" ||
           target.type == "reset")
        {
           return true;
        }
        return false;
    }
    if(tagName == "a" || tagName == "img" || tagName == "button" || tagName == "textarea")
        return true;
    return false;
}

