
function addMyCustomLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    }
    else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function toggleCode(id) {
  var dCode = document.getElementById("divCode" + id.toString());
  if (dCode) {
    if (dCode.style.display && typeof dCode.style.display == 'string' && dCode.style.display == 'block')
      dCode.style.display = 'none';
    else
      dCode.style.display = 'block';
  }
  return false;
}

function doesElementTagNameMatch(el,checkTagName) {  
  return el.tagName && typeof el.tagName != 'undefined' && el.tagName.toLowerCase() == checkTagName.toLowerCase();
}

function hideNotifyNewComments() {
  var oNotify = document.getElementById('cbNotify');
  if (oNotify) {
    var oLabel;
    var oNextSibling = oNotify.nextSibling;
    var oRemoveElement;
    var oRemoveElement2;
    while (oNextSibling && !oLabel) {
      if (doesElementTagNameMatch(oNextSibling, 'label')) {
        if (oNextSibling.innerHTML && oNextSibling.innerHTML.toLowerCase().indexOf('notify') != -1) {
            
            var oLabel = oNextSibling;
            
            if (oLabel.nextSibling && doesElementTagNameMatch(oLabel.nextSibling, 'br')) {
              oRemoveElement = oLabel.nextSibling;
              if (oRemoveElement.nextSibling && doesElementTagNameMatch(oRemoveElement.nextSibling, 'br')) {
                oRemoveElement2 = oRemoveElement.nextSibling;
              }
            }
            break;
        }
      }      
      oNextSibling = oNextSibling.nextSibling;
    }
    oNotify.style.display = 'none';
    if (oLabel) {
      oLabel.style.display = 'none';
    }
    if (oRemoveElement) {
      oRemoveElement.parentNode.removeChild(oRemoveElement);
    }
    if (oRemoveElement2) {
      oRemoveElement2.parentNode.removeChild(oRemoveElement2);
    }
  }  
}

function addBreakOnSearchPage() {
  var oSearchPage = document.getElementById('searchpage');
  if (oSearchPage) {
    var oIncludeComment = document.getElementById('comment');
    if (oIncludeComment && doesElementTagNameMatch(oIncludeComment, 'input')) {
      var oBreak = document.createElement('br');
      oIncludeComment.parentNode.insertBefore(oBreak, oIncludeComment);
    }
  }
}

addMyCustomLoadEvent(hideNotifyNewComments);
addMyCustomLoadEvent(addBreakOnSearchPage);
