﻿// These are Andy Anderson's commonly used JavaScripts

function assignIDs()	// sets href, id for marked anchors, by using their content ..., sans spaces
						// Form one: creates a link only: <a href="#">...</a>
						// Form two: creates a link and a target: <a name="#" href="#">...</a>
{
				// window.alert('Staring Test');
	with (document)	// referenced children: anchors
		for (var a = 0; a < anchors.length; a++)	// Checks each anchor for one of the forms above
			with (anchors[a])	// referenced children: href, childNodes, id
			{
				var hashIndex = href.lastIndexOf('#');
				if (hashIndex == -1)	// No hashes present
					continue;
				var hashA = href.substr(hashIndex);
				if (hashA != '#')	// Not one of my markers
					continue;
				for (var n = 0; n < childNodes.length; n++)	// Should only be one node, a text node, but just in case...
					if (childNodes[n].nodeType == 3) // Node.TEXT_NODE
					{
						var newname = childNodes[n].data.split(' ').join('');	// Remove spaces
						if (name == '#')	// Make it a target as well as a link.
							id = newname;	// Use ID because Internet Explorer 6 & 7 won't reference changed names.
						href = href.substring(0, hashIndex + 1) + newname;
						break;	
					}
				// window.alert('Found one! ' + newname);
			}
}
