if (self == parent) document.location.replace('index.htm?'+escape(document.location));

function nl_getFilename()
{
	var f = document.location.href + ""; // Maybe use document.location.pathname instead so we don't have to strip out hash and question mark??
	f = f.substring(f.lastIndexOf("/")+1,f.length);
	if(f.indexOf("?")>0)
		f = f.substring(0,f.indexOf("?"));
	if(f.indexOf("#")>0)
		f = f.substring(0,f.indexOf("#"));
	return f;
}

function nl_go(offset)
{
	var nl_pages;
	var thispage = nl_getFilename();
	var index = -1;

	if (parent.SendLMS)
	{
		if (parent.SendLMS.nl_pages)
		{
			nl_pages = parent.SendLMS.nl_pages
			for (var x=0; x < nl_pages.length; x++)
			{
				if (nl_pages[x] == thispage)
				{
					index = x;
					break;
				}
			}
			if ((index >= 0) && (index < nl_pages.length-offset))
			{
				if (nl_pages[index+offset].substring(0,3) == nl_pages[index].substring(0,3))
				{
					// this is same section
					document.location = nl_pages[index+offset];
				}
				else
				{
					// different section, return to contents
					if (nl_pages[0] == "intro.htm")
					{
						document.location = nl_pages[1];
					}
					else
					{
						document.location = nl_pages[0];
					}
				}
				return;
			}
		}
	}

	alert("Sorry, an error has occured, try going back to the unit contents.")
}

function nl_goNext()
{
	nl_go(1)
}

function nl_goBack()
{
	nl_go(-1);
}

function nl_openLink(x)
{
	alert("Not implemented yet...: " + x)
}

function nl_writeNav()
{
	var imageRoot = document.location+"";
	imageRoot = imageRoot.substring(0,imageRoot.toLowerCase().indexOf("/courses"));

	var thispage = nl_getFilename().toLowerCase();
	if ((thispage != "intro.htm") &&
		(thispage != "contents.htm") &&
		(thispage != "15_02.htm") &&
		(thispage != "part1.htm") &&
		(thispage != "part2.htm") &&
		(thispage != "test.htm"))
	{
		document.write('<br><br><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>')
		document.write ('<td><a href="javascript:nl_goBack()" style="color:#0000ff"><img src="'+imageRoot+'/images/arrowback.gif" width="10" height="10" border="0" hspace="5"><b>BACK</b></td>')
		if (thispage != "15_01.htm")
		{
			document.write ('<td align="right"><a href="javascript:nl_goNext()" style="color:#0000ff"><b>NEXT</b><img src="'+imageRoot+'/images/arrow.gif" width="10" height="10" border="0" hspace="5"></td>')
		}
		document.write('</tr></table>')
	}
	if (thispage == "15_02.htm") {
		document.write('<table align="center"><tr><td><a href="contents.htm"><b>BACK TO UNIT CONTENTS</b></td></tr></table>')
	}
	if (thispage == "test.htm" || thispage == "part1.htm" || thispage == "part2.htm") {
		document.write('<br><br>')
	}
}

function nl_contentsGo(x)
{
//	parent.lhs.document.location = "../../lhs.htm"
}
/*
// En el load miro si es la pagina contents para cambiar la imagen
if(nl_getFilename(document.location) == "contents.htm") {
	parent.lhs.document.location = "../lhs.htm"
}
*/
function nl_loadLink()
{
	var href,filename;
	if (window.parent)
	{
		if (window.parent.Content)
		{
			href = window.parent.Content.location.href.toString().toLowerCase();
			filename = href.toLowerCase().substring(href.lastIndexOf("/")+1,href.length);
			href = href.substring(0,href.lastIndexOf("/")+1);

			switch(filename)
			{
				case "intro.htm":
				case "contents.htm":
					break;
				case "part1.htm":
				case "part2.htm":
					window.parent.location = "index.asp";
					break;
				default:
					window.parent.Content.location = href + "contents.htm";
			}

			return;
		}
	}

	alert("Sorry, this link is not available at this time.");
	return;
/*
	if(document.images['imagenAtras'].src.indexOf("l7lcont.gif")<0)
	{
		var contLoc = window.parent.Content.location + "";
		contLoc = contLoc.substring(0,contLoc.lastIndexOf("/")+1);
		window.parent.Content.location = contLoc + "contents.htm";
	}
	else
	{
		window.parent.location = "index.asp";
	}*/
}

