// plik:	markComments.js
// wersja:	1.0 (2007-07-29)
// autor:	lukas_to@gazeta.pl www.maupa.blox.pl
// Description:	Skrypt oznacza wszystkie komentarze napisane przez autora danej notki
//		Zainspirowany przez blox.comments.js autorstwa s.z.y.m.o.n@gazeta.pl

//Konfiguracja: Możesz zmienić nazwę klasy css, którą chcesz oznaczać wpisy autorów

var authorClassName = "KomentarzAutora"; //Klasa o tej nazwie powinna być zdefiniowana w twoim arkuszu css.

function markAuthorsComments() {
  var noteAuthor = findNoteAuthor();
  var container = document.getElementById("SkomentujListaKomentarzy");
  if(!container) return;
  var comments = container.getElementsByTagName("div");
  if(!comments) return;
  for(var i=0; i<comments.length; i++) {
    if(isAuthorsComment(comments[i], noteAuthor))
      comments[i].parentNode.className += " "+authorClassName;
  }

}

function isAuthorsComment(comment, noteAuthor) {
  if(comment.className != "InfoKomentarzAuthor") return false;
   if(comment.innerHTML.indexOf(">"+noteAuthor+"<") > 0)
     return true;
  return false;
}

function findNoteAuthor() {
  var container = document.getElementById("SkomentujBox");
  if(!container) return "";
  var divs = container.getElementsByTagName("div");
  for(var i=0; i<divs.length; i++) {
    var div = divs[i];
    if(div.className == "InfoKomentowanegoWpisu") {
      var elems = div.innerHTML.split(", ");
      return elems[elems.length-1];
    }
  }
  return "";
}

if (document.getElementById('BlogSzerokaSzpalta')){markAuthorsComments();}
else {
  if (document.addEventListener) {document.addEventListener('load', markAuthorsComments, false);}
  else {if (document.attachEvent){document.attachEvent('onload', markAuthorsComments);} }
}
