// Copyright © 2002 Microsoft Corporation.  All rights reserved.
var oHelpWin = null;
var oLMSAPI = null;
	
function document.onreadystatechange()
{
	if (document.readyState != "complete")
		return;

	oLMSAPI = FindLMSAPI();

	document.all("__idNext").src = IMG_NEXT_BUTTON_NORMAL;
	document.all("__idNext").title = LBL_NEXT;

	document.all("__idPrevious").src = IMG_PREVIOUS_BUTTON_NORMAL;
	document.all("__idPrevious").title = LBL_PREVIOUS;
		
	document.all("idHelpLink").innerText = LBL_HELP;
	document.all("idHelpLink").title = LBL_HELP_TIP;

	if (document.all("idCloseSyllabus"))
	{
		document.all("idCloseSyllabus").src = IMG_TOC_MINIMIZE_BUTTON_NORMAL;
		document.all("idCloseSyllabus").title = LBL_CLOSE_OUTLINE;
	}

	if (document.all("idOpenSyllabus"))
	{
		document.all("idOpenSyllabus").src = IMG_TOC_OPEN_BUTTON_NORMAL;
		document.all("idOpenSyllabus").title = LBL_OPEN_OUTLINE;
	}
}

function document.onkeypress()
{
	switch (event.srcElement.id)
	{
		case "__idPrevious":
		case "__idNext":
		case "idHelpLink":
		case "idCloseSyllabus":
		case "idOpenSyllabus":
		{
			if (event.keyCode == ASCII_KEYCODE_ENTER || event.keyCode == ASCII_KEYCODE_SPACE)
				document.onclick();
			break;
		}
		default:
			return;
	}
							
	event.cancelBubble = true;
	event.returnValue = false;
}

function document.onclick()
{
	switch (event.srcElement.id)
	{
		case "__idPrevious":
			if(oLMSAPI)
				oLMSAPI.LRNDoPrevious();
			break;
				
		case "__idNext":
			if(oLMSAPI)
				oLMSAPI.LRNDoNext();
			break;

		case "idHelpLink":
			displayHelp();
			break;

		case "idCloseSyllabus":
			// save the current frameset width
			window.parent.strFrameCols = window.parent.frames.__idParentUIFrameset.cols;

			// collapse the frameset
			window.parent.frames.__idParentUIFrameset.cols = "0px,*";
			break;

		case "idOpenSyllabus":
			// restore frameset to its original width
			window.parent.__idParentUIFrameset.cols = window.parent.strFrameCols;
			break;
			
		default:
			return;
	}
							
	event.cancelBubble = true;
	event.returnValue = false;
}

function document.onmouseover()
{
	switch (event.srcElement.id)
	{
		case "__idPrevious":
			document.all("__idPrevious").src = IMG_PREVIOUS_BUTTON_HOVER;
			break;

		case "__idNext":
			document.all("__idNext").src = IMG_NEXT_BUTTON_HOVER;
			break;

		case "idCloseSyllabus":
			document.all("idCloseSyllabus").src = IMG_TOC_MINIMIZE_BUTTON_HOVER;
			break;

		case "idOpenSyllabus":
			document.all("idOpenSyllabus").src = IMG_TOC_OPEN_BUTTON_HOVER;
			break;

		default:
			return;
	}

	event.cancelBubble = true;
	event.returnValue = false;
}

function document.onmouseout()
{
	switch (event.srcElement.id)
	{
		case "__idPrevious":
			document.all("__idPrevious").src = IMG_PREVIOUS_BUTTON_NORMAL;
			break;

		case "__idNext":
			document.all("__idNext").src = IMG_NEXT_BUTTON_NORMAL;
			break;

		case "idCloseSyllabus":
			document.all("idCloseSyllabus").src = IMG_TOC_MINIMIZE_BUTTON_NORMAL;
			break;

		case "idOpenSyllabus":
			document.all("idOpenSyllabus").src = IMG_TOC_OPEN_BUTTON_NORMAL;
			break;

		default:
			return;
	}

	event.cancelBubble = true;
	event.returnValue = false;
}

function document.onmousedown()
{
	switch (event.srcElement.id)
	{
		case "__idPrevious":
			document.all("__idPrevious").src = IMG_PREVIOUS_BUTTON_PRESSED;
			break;

		case "__idNext":
			document.all("__idNext").src = IMG_NEXT_BUTTON_PRESSED;
			break;

		case "idCloseSyllabus":
			document.all("idCloseSyllabus").src = IMG_TOC_MINIMIZE_BUTTON_PRESSED;
			break;

		case "idOpenSyllabus":
			document.all("idOpenSyllabus").src = IMG_TOC_OPEN_BUTTON_PRESSED;
			break;

		default:
			return;
	}

	event.cancelBubble = true;
	event.returnValue = false;
}

function document.onmouseup()
{
	switch (event.srcElement.id)
	{
		case "__idPrevious":
			document.all("__idPrevious").src = IMG_PREVIOUS_BUTTON_NORMAL;
			break;

		case "__idNext":
			document.all("__idNext").src = IMG_NEXT_BUTTON_NORMAL;
			break;

		case "idCloseSyllabus":
			document.all("idCloseSyllabus").src = IMG_TOC_MINIMIZE_BUTTON_NORMAL;
			break;

		case "idOpenSyllabus":
			document.all("idOpenSyllabus").src = IMG_TOC_OPEN_BUTTON_NORMAL;
			break;

		default:
			return;
	}

	event.cancelBubble = true;
	event.returnValue = false;
}

function document.oncontextmenu()
{
	// Don't show default context menu
	event.cancelBubble = true;
    	event.returnValue = false;
}

function displayHelp()
{
	if (oHelpWin && !oHelpWin.closed )
	{
		oHelpWin.focus();
		return;
	}

   	var strWinProps = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,status=no,height=188,width=530,left=20,top=0";

    	oHelpWin = window.open("help/Help.htm", "", strWinProps); 
	oHelpWin.focus();
}