// Causes the admin toolbar to fade to match browser window when another app selected
window.onblur = blurToolbar;

var toolbarColors = [];

function blurToolbar() {
	getToolbarColors('mainToolbar');
	setToolbarColors('mainToolbar', '#cfcfcf', '#e2e2e2', '#878787' );
	// remove the event to stop an infinite loop!
 	window.onblur = '';
	window.onfocus = focusToolbar;
}

function focusToolbar() {
	setToolbarColors('mainToolbar', toolbarColors[0], toolbarColors[1], toolbarColors[2] );
	 // remove the event to stop an infinite loop!
	window.onfocus = '';
	window.onblur = blurToolbar;
}

function setToolbarColors(elementId, backgroundColor, borderTopColor, borderBottomColor) {
	toolbar = document.getElementById(elementId);
	toolbar.style.backgroundColor = backgroundColor;
	toolbar.style.borderTopColor = borderTopColor;
	toolbar.style.borderBottomColor = borderBottomColor;
}
	
function getToolbarColors(elementId) {
	toolbar = document.getElementById(elementId);
	toolbarColors[0] = toolbar.style.backgroundColor;
	toolbarColors[1] = toolbar.style.borderTopColor;
	toolbarColors[2] = toolbar.style.borderBottomColor;
}
