// If you wish to use this script for non-commercial purposes, please extend the author the courtesy of crediting him and
// providing a link to his site - http://www.markeverett.com

// Unauthorised use of this script for commercial purposes is prohibited.
// Please contact the author at mark AT markeverett D0T com to request authorisation.

// In all cases this work remains the copyrighted property of Mark Everett

// _______________________________________________________________

// Title : Link-text style animator v1.2
// Author : Mark Everett
// Website : www.markeverett.com
// Copyright © Mark Everett 2004 all rights reserved
// _______________________________________________________________



function linkAniInit () {
	for (var i = 0; i < document.links.length; i ++) {
		if (document.links[i].className == "animated_link") {
			var n = document.links[i];
			var c = n.childNodes;
			n.setAttribute("id", "animated_link_" + i);
			n.onmouseover = animateLink;
 			n.onmouseout = resetLink;
			if (c.length == 1 && c[0].nodeType == 3 /* Node.TEXT_NODE */) {
				var splitText = c[0].data.split("");
				for (var j = 0; j < splitText.length; j ++) {
					spanTag = document.createElement("span");
/*'   THE FOLLOWING COMMENTED-OUT LINE WILL REPLACE A SPACE WITH A UNICODE NON-BREAKING SPACE   */
/*    CODE REMOVED PENDING SOME RESEARCH ON THE PORTABILITY OF UNICODE CHARACTER CODES    */
//					splitText[j] = splitText[j].replace(" ","\u00A0");
					spanTag.appendChild(document.createTextNode(splitText[j]));
					if (j == 0) {
						n.replaceChild(spanTag, c[0]);
					}
					else {
						n.appendChild(spanTag);
					}
				}
			}
		}
	}
}

// THE FOLLOWING COMMENTED-OUT INTERFACES HAVE BEEN PLACED ON THE CALLING PAGE
// animateLink.speed = 10;
// resetLink.speed = 18;


function animateLink (theElement) {
	if (!theElement || !theElement.id) {
		n = this;
	}
	else {
		n = theElement;
	}
	if (!n.loopCount) {
		n.loopCount = 0;
	}
	if (n.loopCount >= n.childNodes.length) {
		n.loopCount = n.childNodes.length - 1;
		clearInterval(n.upTimer);
		return;
	}
	if (n.loopCount < 0) {
		n.loopCount = 0;
	}
	clearInterval(n.downTimer);
	n.childNodes[n.loopCount].style.textDecoration = "underline";
	n.childNodes[n.loopCount].style.color = "#665d54";
	
	
	
	
	
	if (n.parentNode.parentNode.id == "b3ta_right_content" || n.parentNode.parentNode.parentNode.id == "b3ta_right_content") {
		n.childNodes[n.loopCount].style.color = "#4d435c";
	} else if (n.parentNode.className == "copyright_text") {
		n.childNodes[n.loopCount].style.color = "#576654";	
	} else {
		n.childNodes[n.loopCount].style.color = "#665d54";	
	}
	
	
	
	
	n.loopCount ++;
	clearInterval(n.upTimer);
	n.upTimer = setInterval("animateLink(document.getElementById('" + n.getAttribute("id") + "'))", animateLink.speed);
}

function resetLink (theElement) {
	if (!theElement || !theElement.id) {
		n = this;
	}
	else {
		n = theElement;
	}
	if (n.loopCount < 0) {
		n.loopCount = 0;
		clearInterval(n.downTimer);
		return;
	}
	if (n.loopCount >= n.childNodes.length) {
		n.loopCount = n.childNodes.length - 1;
	}
	clearInterval(n.upTimer);
	n.childNodes[n.loopCount].style.textDecoration = "none";
	
	
	if (n.parentNode.parentNode.id == "b3ta_right_content" || n.parentNode.parentNode.parentNode.id == "b3ta_right_content") {
		n.childNodes[n.loopCount].style.color = "#a096ad";
	} else if (n.parentNode.className == "copyright_text") {
		n.childNodes[n.loopCount].style.color = "#789970";	
	} else {
		n.childNodes[n.loopCount].style.color = "#998470";	
	}
	
	n.loopCount --;
	clearInterval(n.downTimer);
	n.downTimer = setInterval("resetLink(document.getElementById('" + n.getAttribute("id") + "'))", resetLink.speed);
}

