
schedule("window", logoAnimationInit); 




function logoAnimationInit()
{
	var animation = document.getElementById("animation");
	if (null != animation)
	{
	    var animationUl = animation.getElementsByTagName("ul")[0];
	    var lis = animationUl.getElementsByTagName("li");
    	
	    animationUl.pixelLength = 0;
    	
	    for (var i = 0; i < lis.length; i++)
	    {
		    animationUl.pixelLength += lis[i].clientWidth;
	    }
    	
	    if (animationUl.pixelLength > animation.clientWidth)
	    {	
		    attachEventListener(animationUl, "mouseover", mouseoverAnimation, false);
		    attachEventListener(animationUl, "mouseout", mouseoutAnimation, false);
    		
		    var items = lis.length;
    		
		    for (var i = 0; i < items; i++)
		    {
			    animationUl.appendChild(lis[i].cloneNode(true));
		    }
    	
		    startAnimation();
	    }
    }
	return true;
};




function mouseoverAnimation()
{
	clearTimeout(this.timer);
	
	return true;
};




function mouseoutAnimation(event)
{
	if (typeof event == "undefined")
	{
		event = window.event;
	}
	
	if (typeof event.relatedTarget != "undefined")
	{
		var related = event.relatedTarget;
	}
	else
	{
		var related = event.toElement;
	}
	
	if (!isDescendantNode(related, this))
	{
		startAnimation();
	}
	
	return true;
};




function startAnimation()
{
	var increment = 2;
	
	var animation = document.getElementById("animation");
	var animationUl = animation.getElementsByTagName("ul")[0];
	
	if (animationUl.style.marginLeft == "")
	{
		animationUl.style.marginLeft = "0";
	}
	
	var currX = parseInt(animationUl.style.marginLeft, 10);
	
	if (currX < -animationUl.pixelLength)
	{
		currX = 0;
	}
	
	animationUl.style.marginLeft = currX - increment + "px";
	
	animationUl.timer = setTimeout("startAnimation()", 50);
	
	return true;
};
function getChildrenByTagName(target, tagName)
{
	var children = target.childNodes;
	var matching = new Array();
	
	if (children != null)
	{
		for (var i = 0; i < children.length; i++)
		{
			if (children[i].nodeName.toLowerCase() == tagName)
			{
				matching[matching.length] = children[i];
			}
		}
	}
	
	return matching;
};




function isDescendantNode(descendant, ancestor)
{
    if (null != descendant)
    {
	    while (descendant.parentNode != null && descendant.parentNode.nodeName.toLowerCase() != "#document")
	    {
		    if (descendant.parentNode == ancestor)
		    {
			    return true;
		    }
		    else
		    {
			    descendant = descendant.parentNode;
		    }
	    }
	}
	return false;
};




function attachEventListener(target, eventType, functionRef, capture)
{
	if (typeof target.addEventListener != "undefined")
	{
		target.addEventListener(eventType, functionRef, capture);
	}
	else if (typeof target.attachEvent != "undefined")
	{
		var functionString = eventType + functionRef;
		target["e" + functionString] = functionRef;
        
		target[functionString] = function(event)
		{
			if(typeof event == "undefined")
			{
				event = window.event
			};

			target["e" + functionString](event);
        };
        
		target.attachEvent("on" + eventType, target[functionString]);
	}
	else
	{
		eventType = "on" + eventType;

		if (typeof target[eventType] == "function")
		{
			var oldListener = target[eventType];

			target[eventType] = function()
			{
				oldListener();

				return functionRef();
			}
		}
		else
		{
			target[eventType] = functionRef;
		}
	}

	return true;
};
function schedule(objectID, functionCall, iteration)
{
	if (iteration == null)
	{
		iteration = 0;
	}
	
	if (objectID == "window")
	{
		var oldonload = window.onload;
		
		if (typeof window.onload != "function")
		{
			window.onload = functionCall;
		}
		else
		{
			window.onload = function()
			{
				oldonload();
				functionCall();
			}
		}
	}
	else if (document.getElementById(objectID))
	{
		functionCall();
	}
	else if (iteration < 300)
	{
		setTimeout(function(){schedule(objectID, functionCall, iteration + 1)}, 10);
	}
	
	return true;
}