

var gSidebarItemCount = 0;
var gSecondaryLinkCount = 0;

var selectedColor = "#cee7ca";
var unselectedColor = "#f2714e";
var selectedSecondaryLinkColor = "#f49473";
var unselectedSecondaryLinkColor = "transparent";
var selectedBGColor = "#f2714e";
var unselectedBGColor = "transparent";

function showPhoto(id) {
	var element = document.getElementById("photo");
	element.src = photos[id-1];
}	

function highlightPage(id) {
	document.getElementById("menu" + id).style.backgroundColor = selectedBGColor;
	document.getElementById("a" + id).style.color = selectedColor;
}

function dehighlightPage(id) {
	document.getElementById("nav" + id).style.backgroundColor = unselectedBGColor;
	document.getElementById("a" + id).style.color = unselectedColor;
}

function highlightSecondaryLink(id) {
	if (gSecondaryLinkCount > 0 && id) {
		document.getElementById("secondary" + id).style.backgroundColor = selectedSecondaryLinkColor;
	}
}

function dehighlightSecondaryLink(id) {
	if (gSecondaryLinkCount > 0 && id) {
		document.getElementById("secondary" + id).style.backgroundColor = unselectedSecondaryLinkColor;
	}
}	

function highlightSideBarItem(id) {
	document.getElementById("sidebar" + id).className = "selected";
}

function dehighlightSideBarItem(id) {
	document.getElementById("sidebar" + id).className = "";
}

function deselectAllSideBar() {
	for (i=1; i<=gSidebarItemCount;  i++ )
	{
		dehighlightSideBarItem(i);
	}
	if (gSecondaryLinkCount > 0) {
		for (i=1; i<=gSecondaryLinkCount;  i++ )
		{
			dehighlightSecondaryLink(i);
		}
	}
}

function selectSidebarItem(id, photoID, secondaryLinkID) {
	deselectAllSideBar();
	highlightSideBarItem(id);
	highlightSecondaryLink(secondaryLinkID);
	showPhoto(photoID);
}

function showPage(id) {
	deselectAllPages();
	highlightPage(id);
	showPageImage(id);
}

function initializePage(id, sidebarItemCount, secondaryLinkCount) {
	gSidebarItemCount = sidebarItemCount;
	highlightPage(id);
	if (sidebarItemCount != '0')
	{
		selectSidebarItem(1,1);
	}
	if (secondaryLinkCount > 0) {
		gSecondaryLinkCount = secondaryLinkCount;
		highlightSecondaryLink('1');
	}
}

function log(message) {
	var element = document.getElementById("log");
	if (element) {
		element.innerHTML +=  "<br>" + message;
	}
}



