
	// dom.js
	
	// Create, manipulate and delete nodes from the DOM hierarchy
	// Copyright © Marco Lehmann 2007
	


	// general delete functions

	function deleteNode(node) {
	  	node.parentNode.removeChild(node);
	}
	
	function deleteAllNodes(node, exc) {
		var start = node.childNodes.length - 1;
		for (var i=start; i>=0; i--) {
			var nname = node.childNodes[i].nodeName.toLowerCase();
			if (nname != exc) node.removeChild(node.childNodes[i]);
		}
	}

	
	// text node functions
	
	function createText(node, val) {
	  	var textNode = document.createTextNode(val);
	  	node.appendChild(textNode);
	}
	
	function modifyText(node, val) {
	  	node.nodeValue = val;
	}
	
	
	// head node functions
	
	function createHeading(node, ht, val) {
		var elem = document.createElement(ht);
		var textNode = document.createTextNode(val);
		elem.appendChild(textNode);
		node.appendChild(elem);
	}
	
	function modifyHeading(node, val) {
		node.childNodes[0].nodeValue = val;
	}
	
	
	// strong node functions
	
	function createStrong(node, val) {
		var elem = document.createElement("strong");
		var textNode = document.createTextNode(val);
		elem.appendChild(textNode);
		node.appendChild(elem);
	}
	
	function modifyStrong(node, val) {
		node.childNodes[0].nodeValue = val;
	}
	
	
	// image node functions
	
	function createImage(node, isrc, iwidth, iheight, ialt, ititle) {
		var elem = document.createElement("img");
		var attr = document.createAttribute("src");
		attr.nodeValue = isrc;
		elem.setAttributeNode(attr);
		attr = document.createAttribute("width");
		attr.nodeValue = iwidth;
		elem.setAttributeNode(attr);
		attr = document.createAttribute("height");
		attr.nodeValue = iheight;
		elem.setAttributeNode(attr);
		attr = document.createAttribute("alt");
		attr.nodeValue = ialt;
		elem.setAttributeNode(attr);
		attr = document.createAttribute("title");
		attr.nodeValue = ititle;
		elem.setAttributeNode(attr);
		node.appendChild(elem);
	}
	
	function modifyImage(node, aname, aval) {
		node.setAttribute(aname, aval);
	}
	
	
	// link node functions
	
	function createLink(node, ahref, aalt, atitle, aonclick) {
		var elem = document.createElement("a");
		var attr = document.createAttribute("href");
		attr.nodeValue = ahref;
		elem.setAttributeNode(attr);
		attr = document.createAttribute("alt");
		attr.nodeValue = aalt;
		elem.setAttributeNode(attr);
		attr = document.createAttribute("title");
		attr.nodeValue = atitle;
		elem.setAttributeNode(attr);
		attr = document.createAttribute("onclick");
		attr.nodeValue = aonclick;
		elem.setAttributeNode(attr);
		node.appendChild(elem);
	}
	
	function modifyLink(node, aname, aval) {
		node.setAttribute(aname, aval);
	}
	
	
	// break node functions
	
	function createBreak(node) {
		var elem = document.createElement("br");
		node.appendChild(elem);
	}
	
	
	// div node functions
	
	function createDiv(node, did, dclass) {
		var elem = document.createElement("div");
		var attr = document.createAttribute("id");
		attr.nodeValue = did;
		elem.setAttributeNode(attr);
		elem.className = dclass;
		node.appendChild(elem);
	}
	
	
	// span node functions
	
	function createSpan(node, sclass) {
		var elem = document.createElement("span");
		elem.className = sclass;
		node.appendChild(elem);
	}
	
	function modifySpan(node, sclass) {
		node.className = sclass;
	}
	
