//	===========================================
//	
//	Menu
//	
//	===========================================

var currentTimer = null;
var lastTimerCommand = "";

function ShowSubMenu(id)
{

	if (currentTimer != null) {
		clearTimeout(currentTimer);
	} //if
	SwapMenus("menuCurrent", "menuHolder" + id);
}

function HideSubMenu(id)
{
	lastTimerCommand = "SwapMenus(\"menuCurrent\", \"menuHolder" + id + "\")";
	currentTimer = setTimeout(lastTimerCommand, 1000);
}

function SwapMenus(id1, id2)
{

	div1 = document.getElementById(id1);
	div2 = document.getElementById(id2);
	
	if (div2 != null) {
		div1.innerHTML = div2.innerHTML;
	} else {
		div1.innerHTML = "";
	}//if
}

function KillTimer()
{

	if (currentTimer != null) {
		clearTimeout(currentTimer);
	} //if

}

//	===========================================
//	
//	Carousel
//	
//	===========================================

var scrollPosition = 0;
var scrollStep = 16;
var scrollImageSize = 216;
var scrolling = false;
var scrollStepsLeft;
var scrollInterval = 10;
var scrollBoxIndex = 0;

function ScrollLeft()
{

	if (scrolling) return;
	
	if (scrollPosition < 0) {
		scrolling = true;
		scrollStepsLeft = (scrollImageSize * 3) / scrollStep;
		scrollBoxIndex--;
		Scroll(1);
	} //if
	
}

function ScrollRight()
{

	if (scrolling) return;
	
	if (scrollPosition > -scrollPositionMax) {
		scrolling = true;
		scrollStepsLeft = (scrollImageSize * 3) / scrollStep;
		scrollBoxIndex++;
		Scroll(-1);
	} //if
}

function ScrollTo(boxIndex)
{

	if (scrolling) return;
	
	UpdateScrollBoxes();	// to reset the scroll step size
	
	if (boxIndex > scrollBoxIndex) {
		scrolling = true;
		scrollStepsLeft = (scrollImageSize * 3) / scrollStep;
		scrollStep *= (boxIndex - scrollBoxIndex);
		scrollBoxIndex = boxIndex;
		Scroll(-1);
	} else {
		if (boxIndex < scrollBoxIndex) {
			scrolling = true;
			scrollStepsLeft = (scrollImageSize * 3) / scrollStep;
			scrollStep *= (scrollBoxIndex - boxIndex);
			scrollBoxIndex = boxIndex;
			Scroll(1);
		} //if
	} //if
		
}

function Scroll(direction)
{

	div = document.getElementById("carouselPeople");
	
	if (div != null) {
		scrollPosition += (direction * scrollStep);
		div.style.marginLeft = scrollPosition + "px";
	} //if
	
	scrollStepsLeft--;
	if (scrollStepsLeft > 0) {
		setTimeout("Scroll(" + direction + ")", scrollInterval);
	} else {
		scrolling = false;
		UpdateScrollBoxes();
	} //if
}

function UpdateScrollBoxes()
{

	for (i = 0; i < scrollBoxCount; i++) {
		div = document.getElementById("carouselBox" + i);
		if (div != null) {
			div.className = "carouselBox";
		} //if
	} //for
	
	div = document.getElementById("carouselBox" + scrollBoxIndex);
	if (div != null) {
		div.className = "carouselBoxSel";
	} //if

	scrollStep = 16;
}

//	===========================================
//	
//	Venues
//	
//	===========================================

function JumpToVenue()
{
sel = document.getElementById("venueSelector");

	if (sel != null) {
		url = "/investment-opportunities/the-venues/" + sel.options[sel.selectedIndex].value + ".aspx";
		location.href = url;
	} //if
}
