var handbook = null;
var notescolumn = null;
var notes = null;
var current = null;
var bookmarkpos = null;

//-------------------------------------------
function resizeNotes() {
	if (handbook == null || notes == null) return;

	var header = 250;
	var winH = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    winH = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    winH = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    winH = document.body.clientHeight;
  }
	
	if (winH != 0) {
		handbook.style.height = (winH - header) + 'px';
		notes.style.height = (winH - header - 80) + 'px';
	}
	return;
}

//-------------------------------------------
function hideGuidanceNotes()
{
	if (!document.getElementById) return;

	// hack for opera! makes a change from IE i suppose
	document.body.className += '';
	
	for (a in notes.childNodes) {
		var note = notes.childNodes[a];
		if (note.className == "guidancenotecontainer") {
			note.style.display = "none";
		}
	}
	notescolumn.style.display = "none";
	
	if (bookmarkpos != null) {
		bookmarkpos.scrollIntoView(true);
	}
}

//-------------------------------------------
function showGuidanceNote(link, rooturl, bookmark)
{
	if (!document.getElementById) return;
	
	if (current != null) {
		current.style.display = "none";
	}

	current = document.getElementById("Note_" + bookmark);
	while (current != null) {
		if (current.className == "guidancenotecontainer") {
			break;
		}
		current = current.parentNode;
	}

	if (current == null) {
		hideGuidanceNotes();
		link.scrollIntoView(true);
		alert("Bookmark not found.");
	}
	else {
		current.style.display = "block";
		notescolumn.style.display = "block";
		link.scrollIntoView(true);
		// hack for opera! makes a change from IE i suppose
		document.body.className += '';
	}
	
	bookmarkpos = link;
	return false;
}	

//-------------------------------------------
window.onload = function()
{
	if (!document.getElementById) return;
	
	handbook = document.getElementById('handbook');
	notes = document.getElementById('notes');
	notescolumn = document.getElementById('notescolumn');
	
	hideGuidanceNotes();
	resizeNotes();
}

