// On page load..
var currentHighlight = null;

function highlightSticky(row) {
	if (currentHighlight != null) {
		closeRoleDetails(currentHighlight);
	}

	currentHighlight = row;
	openRoleDetails(currentHighlight);
}

function highlightSlippery(row) {
	if (row != currentHighlight) {
		row.style.background = '#e9e8e8';
	}
}

function unhighlightSlippery(row) {
	if (row != currentHighlight) {
		row.style.background = 'white';
	}
}



function openRoleDetails(row) {
	row.style.background = 'silver';
	row.nextSibling.className = 'roleDetail displayOn';
}

function closeRoleDetails(row) {
	row.style.background = 'white';
	row.nextSibling.className = 'roleDetail displayOff';
}


// Changed from styles to classNames here so we can override the
//   the visibility for printing.  Styles were forcing precedence.
function toggleContainer(containerId) {
	document.getElementById('LeadRolesContainer').className = 'container displayOff';
	document.getElementById('OtherRolesContainer').className = 'container displayOff';
	document.getElementById('PreProductionRolesContainer').className = 'container displayOff';

	document.getElementById(containerId).className = 'container displayOn';
}

function getKey(keyStroke) {
	var keyCode = (window.event) ? event.keyCode : keyStroke.which;
	var keyString = String.fromCharCode(keyCode).toLowerCase();

	if (keyCode = 32) {
		if (currentHighlight.nextSibling.nextSibling) {
			highlightSticky(currentHighlight.nextSibling.nextSibling);
		}
	}
}

document.onkeypress = getKey;
toggleContainer('LeadRolesContainer');

