// browser detection
var browser = new Browser();

function Browser()
{
	this.Win32 = (navigator.platform == "Win32");
	this.FiltersAndBehaviors = /MSIE ((5\.5)|[6789])/.test(navigator.userAgent) && this.Win32;
	this.Gecko = /Gecko/.test(navigator.userAgent);
	this.Ie =  /MSIE [456789]/.test(navigator.userAgent);
	this.CSS2 = this.FiltersAndBehaviors && this.Gecko;
	this.Mac = /mac/.test(navigator.userAgent.toLowerCase());
}


// get generic object
function utilGetObject(objName)
{
	var obj; 
	if (typeof(objName) == "object")
	{
		obj = objName;
	}
	else
	{
		if (browser.Gecko||browser.Ie)
		{
			obj = document.getElementById(objName);
		}
		else
		{
			obj = null;
		}
	}
	return obj;
}

function GetRealLeft(obj)
{
	var result = obj.offsetLeft;
	var parent = obj.offsetParent;
	while (parent != null)
	{
		result += parent.offsetLeft;
		parent = parent.offsetParent;
	}
	if(browser.Ie&&browser.Mac)
	{
		result += parseInt(document.body.leftMargin);
	}
	return result;
}

function GetRealTop(obj)
{
	var result = obj.offsetTop;
	var parent = obj.offsetParent;
	while (parent != null)
	{
		result += parent.offsetTop;
		parent = parent.offsetParent;
	}
	if(browser.Ie&&browser.Mac)
	{
		result += parseInt(document.body.topMargin);
	}
	return result;
}

function DisplayChildLinks()
{
	obj = document.getElementById("ChildLinks");
	obj.style.display = "block";
}

function DisplayParents(obj, parentList)
	{
		if (obj)
		{
			/*
			if (obj.nodeName == "FORM")
			{
				return 0;
			}
			*/
			DisplayParents(obj.parentElement, obj.nodeName+'('+obj.id+')->'+parentList);
		}
		else {
			alert(parentList);
		}
		return 0;
	}
	
function Rotator(parentObj)
{
	if (typeof(parentObj) == "string")
	{	
		parentObj = document.getElementById(parentObj);	
	}
		
	this.current = getFirstChildElement(parentObj);;
	
	this.rotatorId = initialize(this);
	
	this.start = function(delay)
	{
		this.delay = delay;
		scheduleNextRotate(this.rotatorId, delay);	
	}

	Rotator.prototype.rotate = function(rotatorId)
	{
		var rotator = getRotator(rotatorId);
		if (rotator)
		{
			hide(rotator.current);
			rotator.current = getNextSiblingElement(rotator.current);
			show(rotator.current);
			scheduleNextRotate(rotatorId, rotator.delay);
		}
	}
	
	function scheduleNextRotate(rotatorId, delay)
	{
		window.setTimeout("Rotator.prototype.rotate(" + rotatorId + ")", delay);
	}
	
	function CanNotBeRotated(obj)
	{
		return (obj && (obj.nodeType == 3 || obj.tagName == "SCRIPT"));
	}
	
	function getFirstChildElement(obj)
	{
		var firstChild = obj.firstChild;
		while(CanNotBeRotated(firstChild))
		{
			firstChild = firstChild.nextSibling;
		}
		return firstChild;
	}
	
	function getNextSiblingElement(obj)
	{
		var nextSibling = obj.nextSibling;
		while(CanNotBeRotated(nextSibling))
		{
			nextSibling = nextSibling.nextSibling;
		}
		return (nextSibling ? nextSibling : getFirstChildElement(obj.parentNode));
	}
	
	function hide(obj)
	{
		if (obj.style)
		{
			obj.style.display = "none";
		}
	}
	
	function show(obj)
	{
		if (obj.style)
		{
			obj.style.display = "block";
		}
	}
	
	function getRotator(rotatorId)
	{
		return (Rotator.prototype.rotators ? Rotator.prototype.rotators[rotatorId] : null);
	}
	
	function initialize(rotator, parentObj)
	{
		var hiddenChild = getNextSiblingElement(rotator.current);								
		while(hiddenChild)
		{
			hide(hiddenChild);
			hiddenChild = hiddenChild.nextSibling;
		}
		if (!Rotator.prototype.rotators)
		{
			Rotator.prototype.rotators = new Array();
		}
		var rotatorId = Rotator.prototype.rotators.length;
		Rotator.prototype.rotators[rotatorId] = rotator;
		return rotatorId;
	}
}