/*
********************
* Style functions
********************
*/

var _debug = false;

function replaceContentWithImage(dHeader) {
	if (_debug) {
		alert("replacing header content: " + dHeader.id);
	}

	var dContent = dHeader.firstChild;

	if (_debug) {
		alert("content: " + dContent.nodeValue);
	}

	var xImg = document.createElement("img");
	xImg.setAttribute("src", _ProjectRoot_ + "images/" + dHeader.id + ".gif");
	xImg.setAttribute("alt", dContent.nodeValue);

	dHeader.replaceChild(xImg, dContent);
}

function processMenuHeaders(dDiv) {
	if (_debug) {
		alert("started: " + dDiv);
	}
	if (dDiv) {
		var dChild = dDiv.firstChild;
		var re = new RegExp("m_.*");
		while(dChild) {
			if (dChild.tagName && dChild.tagName == 'H3' && dChild.id.search(re) == 0) {
				replaceContentWithImage(dChild);
			}
			dChild = dChild.nextSibling;
		}
	}
}

function addLinkToTop(dHeader) {
	if (_debug) {
		alert("adding top link: " + dHeader.id);
	}

	var xLink = document.createElement("a");
	xLink.setAttribute("class", "topLink");

	xLink.setAttribute("href", "#pageTop");
	xLink.setAttribute("alt", "top");
	xLink.setAttribute("title", "go to top");

	// hack for internet explorer 6:
	xLink.className = "topLink";
	// end hack

	var xImg = document.createElement("img");
	xImg.setAttribute("src", _ProjectRoot_ + "images/icon_top.gif");

	xLink.appendChild(xImg);

	dHeader.insertBefore(xLink, dHeader.firstChild);
}

function processContentHeaders() {
	var dDiv = document.getElementById("content");
	if (_debug) {
		alert("started: " + dDiv);
	}
	if (dDiv) {
		var dChild = dDiv.firstChild;
		while(dChild) {
			if (dChild.tagName && dChild.tagName == "H2") {
				addLinkToTop(dChild);
			}
			dChild = dChild.nextSibling;
		}
	}
}
