// JavaScript for auto-linking of comments


function makeCommentLinks() {
	if( document.getElementById ) {
		if (comments = document.getElementById('page-comments')) {
			while (node = comments.getElementsByTagName("DD")[0]) {
				// We're removing the first node each time through, so the next one will always be first!
				var links = node.getElementsByTagName('A');
				for( var i=0; i<links.length; i++ ) {
					if( links[i].rev == 'comment' ) {
						addEvent(links[i],'click',closeComment);
						links[i].removeAttribute('href');
						var newText = document.createTextNode('close this comment');
						links[i].removeChild(links[i].firstChild);
						links[i].appendChild(newText);
					}
				}
				/*
				var newLink = document.createElement('A');
				var newText = document.createTextNode('close this comment');
				var newSpan = document.createElement('SPAN');
				newLink.appendChild(newSpan);
				newLink.appendChild(newText);
				addEvent(newLink,'click',closeComment);
				var newPara = document.createElement('P');
				newPara.className = 'closePopup';
				newPara.appendChild(newLink);
				node.appendChild(newPara);				
				*/
				
				document.body.appendChild(node);
				node.style.display = "none";
				node.style.position = "absolute";
				node.className = "popup";
			}
			comments.style.display = "none";

			anchors = document.getElementsByTagName("A");
			for (i=0;i<anchors.length;i++) {
				if (anchors[i].rel == "comment") {
					if (href = anchors[i].href) {
						// Only apply actions to links with hrefs, i.e. links to valid comments terms
						defId = href.substring(href.indexOf('#') + 1);
						if (document.getElementById(defId)) {
							addEvent(anchors[i],'mouseover',showComment);
							//addEvent(anchors[i],'mouseout',hideComment);
						}
					}
				}
			}
		}
	}
}






