function FindElement(sId) {
	var o = null;
	if (document.getElementById)
		o = document.getElementById(sId);
	if(!o && document.all)
		o = document.all[sId];
	if(!o && document.layers)
		o = document.layers[sId];
	return o;
}
function GetAbsoluteX(o) {
	var x     = o.offsetLeft;
	var oTemp = o.offsetParent;
	while (oTemp != null) {
		x     += oTemp.offsetLeft;
		oTemp  = oTemp.offsetParent;
	}	
	return x;
}

function GetAbsoluteY(o) {
	var y     = o.offsetTop;
	var oTemp = o.offsetParent;
	while (oTemp != null) {
		y     += oTemp.offsetTop;
		oTemp  = oTemp.offsetParent;
	}
	return y;
}

var g_oInfoCloseTimer    = null;
var g_oInfoPositionTimer = null;
function PositionInfo(o) {
	var oBox = document.getElementById("infoBox");
	if (oBox) {
		var y = GetAbsoluteY(oBox) - oBox.clientHeight;
		var x = GetAbsoluteX(oBox) - 10;
		oBox.style.filter     = "alpha(opacity: 100)"
		oBox.style.opacity    = "1.0";
		oBox.style.mozOpacity = "1.0";
		oBox.style.top        = y + "px";
		oBox.style.left       = x + "px";
	}
}
function ShowInfo(o) {
	if (g_oInfoCloseTimer) {
		clearTimeout(g_oInfoCloseTimer);
		g_oInfoCloseTimer = null;
	}
	var oBox = FindElement("infoBox");
	if (oBox) {
		if (o) {
			oBox.innerHTML     = o.alt + "<span class=\"infoBoxArrow\"/>";
			oBox.style.display = "block";
			oBox.style.top     = (GetAbsoluteY(o) - oBox.clientHeight - 6) + "px";
			oBox.style.left    = (GetAbsoluteX(o) - 24) + "px";

		}
	}
}
function HideInfoTimed() {
	var oBox = FindElement("infoBox");
	if (oBox) {
		oBox.innerHTML = "";
		oBox.style.display = "none";
	}
}
function HideInfo() {
	if (g_oInfoCloseTimer) {
		clearTimeout(g_oInfoCloseTimer);
		g_oInfoCloseTimer = null;
	}
	g_oInfoCloseTimer = setTimeout("HideInfoTimed()", 400);
}

var g_oAccord     = null;
var g_oAccordPrev = null;

function Accord(sId) {
	this.m_sId               = sId;
	this.m_oItem             = FindElement("accordItem" + sId);
	this.m_oContentContainer = FindElement("accordCC" + sId);
	this.m_oContent          = FindElement("accordC" + sId);
	this.m_iContainerHeight  = 0;
	this.m_iContentHeight    = 0;
	this.m_oTimer            = null;
	this.m_iSlideDelay       = 50;
	this.m_bSliding          = false;
	this.m_bOpen             = true;
	this.m_iSlideSpeed       = 0;
	this.m_iSlideAccel       = 10;
	if (this.m_oContentContainer && this.m_oContent)
		this.Start();
}
Accord.prototype.Start = function() {
	if (this.m_oTimer) {
		clearTimeout(this.m_oTimer);
		this.m_oTimer = null;
	}
	this.m_iContainerHeight = parseInt(this.m_oContentContainer.style.height);
	if (isNaN(this.m_iContainerHeight))
		this.m_iContainerHeight = 0;
	this.m_iContentHeight = this.m_oContent.clientHeight;
	this.m_bOpen          = (this.m_iContainerHeight < this.m_iContentHeight);
	this.m_iSlideSpeed    = (this.m_bOpen) ? 30 : -30;
	this.m_bSliding       = true;
	if (this.m_oItem)
		this.m_oItem.className = (this.m_bOpen) ? "Active" : "";
	this.Slide();
}
Accord.prototype.Slide = function() {
	if (this.m_oTimer) {
		clearTimeout(this.m_oTimer);
		this.m_oTimer = null;
	}
	var iCurrentHeight = parseInt(this.m_oContentContainer.style.height);
	if (isNaN(iCurrentHeight))
		iCurrentHeight = 0;
	var iNewHeight     = iCurrentHeight + this.m_iSlideSpeed;
	if ((iNewHeight < this.m_iContentHeight && this.m_bOpen) || (iNewHeight > 0 && !this.m_bOpen)) {
		var oAccord  = this;
		var SlideInt = function() {
			oAccord.Slide();
		}
		this.m_oContentContainer.style.height = (iCurrentHeight + this.m_iSlideSpeed) + "px";
		this.m_oTimer                         = setTimeout(SlideInt, this.m_iSlideDelay);
	} else {
		this.m_bSliding                       = false;
		this.m_oContentContainer.style.height = ((this.m_bOpen) ? this.m_oContent.clientHeight : 0) + "px";
	}
}

function OpenAccord(sId) {
	if (g_oAccord && sId != g_oAccord.m_sId && g_oAccord.m_bOpen)
		g_oAccordPrev = new Accord(g_oAccord.m_sId);
	g_oAccord = new Accord(sId);
}
