function unhighlightElement(element) {
  if (element != null && element.parentNode != null) {
    if (element.parentNode.className.indexOf(' inputs-line-selected') > 0) {
      element.parentNode.className = element.parentNode.className.replace(' inputs-line-selected' , '');
    }  
  }
}

function highlightElement(element) {
  if (element != null && element.parentNode != null) {
    element.parentNode.className += ' inputs-line-selected';
  }
}

function highlightWrapper(wrapperID) {
  wrapperElement = document.getElementById(wrapperID);
  if (wrapperElement != null) {
    wrapperElement.className +=' inputs-line-selected';
  }
}

function unhighlightWrapper(elementID) {
  wrapperElement = document.getElementById(elementID);
  if (wrapperElement.className.indexOf(' inputs-line-selected') > 0) {
    wrapperElement.className = wrapperElement.className.replace(' inputs-line-selected' , '');
  }
}

function hideHighlight(element)
{
  if (element.className != null && element.className.indexOf(' inputs-line-selected') > 0) {
    element.className = element.className.replace(' inputs-line-selected' , '');
  }
  if (element.childNodes != null) {
    for (var i = 0; i < element.childNodes.length; i++) {
      hideHighlight(element.childNodes[i]);
    }
  }
}

function addFCKOnFocusEvent(textAreaId, containerID, wrapperID)
{
  window.setTimeout(function() {
    try {
      if (FCKeditorAPI != null)
      {  
        var editorInstance = FCKeditorAPI.GetInstance(textAreaId) ; 
        if (editorInstance != null) {
          
          editorInstance.Events.AttachEvent( 'OnFocus', function() {highlightWrapper(wrapperID); } ) ;
          editorInstance.Events.AttachEvent( 'OnBlur', function() { unhighlightWrapper(wrapperID); } ) ;
          editorInstance.Events.AttachEvent( 'OnFocus', function() { var sender = document.getElementById(wrapperID);ChangeHideInputValue(sender , "1"); } ) ;
          //editorInstance.Events.AttachEvent( 'OnKeyDown', function() { var sender = document.getElementById(wrapperID);ChangeHideInputValue(sender , "1"); } ) ;
          //editorInstance.addEventListener('focus',function() { var sender = document.getElementById(wrapperID);ChangeHideInputValue(sender , "1"); } ,false)

        }
      }          
    }
    catch (exc) {
      textAreaElement = document.getElementById(textAreaId);
      if (textAreaElement != null) {
        textAreaElement.onfocus = function () {highlight(textAreaElement)};
      }
    }
  }, 300);
}
