var ContentHeight;
var TimeToSlide = 250.0;

var openAccordion = '';
function runAccordion(rowid, container, id) {
	if(rowid == 1) {
		if(id == "ourFunds") {ContentHeight = 380;}
		else {ContentHeight = 580;}
	}
	if(rowid == 2) {
		if(id == "ourFunds") {ContentHeight = 380;}
		else {ContentHeight = 350;}
	}
	if(rowid == 3) {ContentHeight = 260;}
	
	
	if(container == "table") {
		titles = document.getElementsByTagName("td");
	} else {
		titles = document.getElementsByTagName("div");
	}		
		
		for (x=0; x< titles.length; x++) {
			if(titles[x].className == "accordionTitleActive" && titles[x].id != "row" + rowid) {
				titles[x].className = "accordionTitle";
			}
		}
	
	var headerRow = document.getElementById("row" + rowid);
	headerRow.className = (headerRow.className == "accordionTitle") ? "accordionTitleActive" : "accordionTitle";
		
	var nID = "Accordion" + rowid + "Content";
	if(openAccordion == nID) {
		nID = '';
	}  
	setTimeout("animate(" 
	+ new Date().getTime() + "," + TimeToSlide + ",'" 
	+ openAccordion + "','" + nID + "','" + container + "')", 33);
	
	openAccordion = nID;
}

function animate(lastTick, timeLeft, closingId, openingId, container) {  
	var curTick = new Date().getTime();
	var elapsedTicks = curTick - lastTick;
	
	var opening = (openingId == '') ? null : document.getElementById(openingId);
	var closing = (closingId == '') ? null : document.getElementById(closingId);
	
	if(timeLeft <= elapsedTicks) {
		if(opening != null) {
			opening.style.height = ContentHeight + 'px';
		}
		
		if(closing != null) {
			closing.style.display = 'none';
			closing.style.height = '0px';
		}
		return;
	}
	
	timeLeft -= elapsedTicks;
	var newClosedHeight = Math.round((timeLeft/TimeToSlide) * ContentHeight);
	
	if(opening != null) {
		if(container == "table") {
			var openingStyle = (navigator.appName == "Microsoft Internet Explorer") ? "block" : "table-row";
			
			
			if(opening.style.display != openingStyle) {
				opening.style.display = openingStyle;
			}		
		}
		
		if (container == "div") {
			if(opening.style.display != 'block') {
				opening.style.display = 'block';
			}
		}
		opening.style.height =  (ContentHeight - newClosedHeight) + 'px';
	}
	
	if(closing != null) {
		closing.style.height = newClosedHeight + 'px';
	}
	
	setTimeout("animate(" + curTick + "," + timeLeft + ",'" + closingId + "','" + openingId + "')", 33);
}
