document.write('<script type="text/javascript" src="banner.js"></script>');

function preloadImages() 
{
  if (document.images) 
  {
    var imgFiles = preloadImages.arguments;
    if (document.preloadArray == null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j < imgFiles.length; j++)
    {
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
    }
  }
}
function swapImage(img,src)
{
	imgObj = eval('document.' + img);
	if (imgObj != null)
	{
		document.swappedImg = imgObj;
		document.swappedImgSrc = imgObj.src;
		imgObj.src = src;
	}
}
function swapImgRestore()
{
	if (document.swappedImg != null) document.swappedImg.src = document.swappedImgSrc;
}
// sniff the browser
var g_sBrowser = document.all ? "IE" : "NN";
var g_fBrowserVersion = 5;
var g_sOS = navigator.platform.indexOf('Mac') == -1 ? "Win" : "Mac";
if (g_sBrowser == "IE")
{
	nVersionIndex = navigator.userAgent.indexOf('MSIE ') + 5;
	g_fBrowserVersion = parseFloat(navigator.userAgent.substring(nVersionIndex,nVersionIndex+4));
}
else if (g_sBrowser == "NN")
{
	g_fBrowserVersion = parseFloat(navigator.appVersion.substring(0,4));
	if (g_fBrowserVersion == 5)
	{
		nVersionIndex = navigator.userAgent.indexOf('Netscape6/') + 10;
		g_fBrowserVersion = parseFloat(navigator.userAgent.substring(nVersionIndex,nVersionIndex+3));
	}
}
//if (g_sBrowser == "NN" && g_fBrowserVersion < 5 && g_sOS == "Win") document.classes.s1.all['fontSize']="11px";
function buildFramePageName(nActivitySetID, nGrade, nTopic, nInitialPageID)
{
	var sPage = 'frames_asid_' + nActivitySetID + '_g_' + nGrade + '_t_' + nTopic + '.html';
	if (nInitialPageID == 2) sPage += "?open=activities";
	else if (nInitialPageID == 3) sPage += "?open=instructions";
	return sPage;
}
function openActivity(nActivitySetID, nGrade, nTopic, nInitialPageID)
{
	openActivityPage(buildFramePageName(nActivitySetID, nGrade, nTopic, nInitialPageID),nInitialPageID);
}
function openActivityFromQuery(nActivitySetID, nGrade, nTopic, nInitialPageID)
{
	openActivityPage("../../../nav/" + buildFramePageName(nActivitySetID, nGrade, nTopic, nInitialPageID),nInitialPageID);
}
function openActivityPage(sPage, nInitialPageID)
{
	var nHeight = screen.availHeight - 60;
	var nWidth = screen.availWidth - 12;
	if (nWidth > 1500) nWidth = (nWidth / 2) - 5;

	// IE
	if (document.all)
	{
		// WIN
		if (navigator.platform.indexOf('Mac') == -1)
		{
			// IE-Win
			window.open(sPage,'activity','resizable=yes,top=0,left=0,width=' + nWidth + ',height=' + nHeight + ',toolbar=0,status=0,location=1,menubar=0').focus();
		}
		// MAC
		else
		{
			var nVersionIndex = navigator.userAgent.indexOf('MSIE ') + 5;
			var sAppVersion = navigator.userAgent.substring(nVersionIndex,nVersionIndex+4);
			var fAppVersion = parseFloat(sAppVersion);

			// IE4-Mac
			if (fAppVersion < 5)
			{
				hwnd = window.open('','resizable=yes,top=42,left=6,width=' + (nWidth-8) + ',height=' + nHeight + ',toolbar=0,status=0,location=0,menubar=1');
				hwnd.document.location.href=sPage;
				hwnd.focus();
			}
			// IE5-MacOS
			else if (fAppVersion < 5.2)
			{
				if (nInitialPageID != 1) nWidth -= 284;
				else nWidth -= 8;
				nHeight -= 2;
				hwnd = window.open('','activity','resizable=yes,top=0,left=0,width=' + nWidth + ',height=' + nHeight + ',toolbar=0,status=0,location=0,menubar=1');
				hwnd.document.location.href=sPage;
			}
			// IE5-MacOSX
			else
			{
				if (nInitialPageID != 1) nWidth -= 266;
				window.open(sPage,'activity','resizable=yes,top=0,left=0,width=' + nWidth + ',height=' + nHeight + 8 + ',toolbar=0,status=0,location=0,menubar=1');
			}
		}
	}
	// NN
	else
	{
		// WIN
		if (g_sOS == "Win")
		{
			// NN4-Win
			if (g_fBrowserVersion < 6) window.open(sPage,'activity','resizable=yes,top=0,left=0,width=' + nWidth + ',height=' + nHeight + ',toolbar=0,status=0,location=1,menubar=0').focus();
			// NN6
			else window.open(sPage,'activity','resizable=yes,top=0,left=0,width=' + nWidth + ',height=' + nHeight + ',toolbar=1,status=0,location=1,menubar=0').focus();
		}
		// MAC
		else
		{
			// NN4-Mac
			window.open(sPage,'activity','resizable=yes,top=0,left=0,width=' + nWidth + ',height=' + (nHeight+30) + ',toolbar=0,status=0,location=0,menubar=1').focus();
		}
	}
}

function navLanguage()
{
  // Determine selected language
  box = document.forms[0].lang;
  language = box.options[box.selectedIndex].value;

  // If it needs to go to index, go there
  if (arguments[0] == "query")
  {
    newURL = "http://nlvm.usu.edu/" + language + "/nav/vlibrary.html";
  }
  else
  {
    // Determine page name
    curURL = window.location.href;
    indexLastSlash = curURL.lastIndexOf("/");
    if (indexLastSlash == -1)
    {
      indexLastSlash = curURL.lastIndexOf("\\");
    }
    pageName = curURL.substring(1+indexLastSlash);
    newURL = "../../" + language + "/nav/" + pageName;
  }


  // Redirect to the same page, but for the selected language
  window.open(newURL, "_top")
}