function word_span() 
{
	// Do nothing if the script won't run
	if (!document.getElementById) return	

	// Get the text content of the page heading
	var page_head = document.getElementById("page_head");

	// If page_head is not present
	if (page_head == null) return

	// We can safely assume that the firstChild is a textNode
	var txt = page_head.firstChild;
	
	// But we need to check if the lastChild is not a textNode
	var last = page_head.lastChild;
	
	// Load the words of the heading into an array
	var words = txt.nodeValue.split(" ");
	
	// For each word 
	for (var w = 0; w < words.length; w++) 
	{
		// Check that the 'word' in question isn't just down to a trailing word space
		// ...or a double word space
		if (words[w] != "")
		{
			// Create a new textNode containing the word and a trailing word space
			new_txt = document.createTextNode(words[w] + " "); 
			// Create a new span element to contain it
			new_span = document.createElement("span");
			// Place the corresponding new textNode within it
			new_span.appendChild(new_txt);

			if (w == 0)
			{
				// If this is the firstChild, replace it
				page_head.replaceChild(new_span,txt);
			}
			else
			{
				if (last.nodeType == 3)
				{
					page_head.insertBefore(new_span,new_span.nextSibling);
				}
				else // if lastChild is not a textNode
				{
					page_head.insertBefore(new_span,last);
				}
			}
		}
	}
	
}

window.onload = word_span;
