//<!--
// Finding Measurement Tools script
// Last updated 12/31/03
// Harry Love (hlove@u.washington.edu)

//Get the URL of the current document and store it
// in the loc variable
var w = window;
var d = document;
var loc = d.location.href;

//Replace the "//" in "http://currentURL.com" with "/"
//and store that in the loc variable
var newLoc = loc.replace("//", "/");
	
//Split the URL into segments and store them in
// an array using "/" as a delimiter
var linkArray = newLoc.split('/');

//Get the current directory
var curDirectory = linkArray[linkArray.length-2];

//Get the current file
var curFile = linkArray[linkArray.length-1];

//If the current file shows up blank...
if(curFile == "")
{
	//Call the current file "index.html"
	curFile = "index.html";
}

//Separate the current file from its DOS extension
var curFileSplit = curFile.split('.');

//Populate the navList variable with an array of
//the entire tutorial contents
// Order of elements:
// Element 0: directory, subdirectory, or sub2, sub3, etc.;
// Element 1: main containing directory within the tutorial;
// Element 2: if subdirectory or other, directory that contains the file; if element 0 is directory, leave blank with quotes "";
// Element 3: the name of the file, without file extension;
// Element 4: the relative address of the file;
// Element 5: the name to use for the link;
var navList = new Array(
	["dir", "measurement", "", "index" , "/howto/measurement/" , "Introduction"],
	["dir", "quicktips", "", "index" , "/howto/measurement/quicktips" , "Quick Tips"],
	["dir", "paths", "", "index", "/howto/measurement/paths/", "Paths to Information"],
	["image", "paths", "paths", "title", "/howto/measurement/paths/title.html", "Find Specific Test Flowchart"],
	["image", "paths", "paths", "variable", "/howto/measurement/paths/variable.html", "Find Test for Variable Flowchart"],
	["image", "paths", "paths", "review", "/howto/measurement/paths/review.html", "Find Test Reviews Flowchart"],
	["dir", "scenarios", "", "index", "/howto/measurement/scenarios/", "Scenarios"],
	["sub", "scenarios", "testByTitle", "index", "/howto/measurement/scenarios/testByTitle/", "Find Specific Test"],
	["sub2", "scenarios", "verify", "index", "/howto/measurement/scenarios/testByTitle/verify/", "Verify Test Information"],
	["sub2", "scenarios", "find", "index", "/howto/measurement/scenarios/testByTitle/find/", "Locate Full-Text of Test"],
	["sub2", "scenarios", "check", "index", "/howto/measurement/scenarios/testByTitle/check/", "Check for Copyright Permissions"],
	["sub", "scenarios", "testByVariable", "index", "/howto/measurement/scenarios/testByVariable/", "Find Test for Variable"],
	["sub2", "scenarios", "variable", "index", "/howto/measurement/scenarios/testByVariable/variable/", "Identify Variable(s) to Measure"],
	["sub2", "scenarios", "setup", "index", "/howto/measurement/scenarios/testByVariable/setup/", "Setup Test Selection Criteria"],
	["sub2", "scenarios", "browse", "index", "/howto/measurement/scenarios/testByVariable/browse/", "Browse Test Sources"],
	["sub", "scenarios", "qol", "index", "/howto/measurement/scenarios/qol/", "Find QoL Tests"],
	["sub2", "scenarios", "setup", "index", "/howto/measurement/scenarios/qol/setup/", "Setup Test Selection Criteria"],
	["sub2", "scenarios", "browse", "index", "/howto/measurement/scenarios/qol/browse/", "Browse Test Sources"],
	["sub", "scenarios", "testReviews", "index", "/howto/measurement/scenarios/testReviews/", "Find Test Reviews"],
	["sub2", "scenarios", "identify", "index", "/howto/measurement/scenarios/testReviews/identify/", "Identify Specific Test"],
	["sub2", "scenarios", "locate", "index", "/howto/measurement/scenarios/testReviews/locate/", "Locate Standard Review"],
	["sub2", "scenarios", "match", "index", "/howto/measurement/scenarios/testReviews/match/", "Match Review Against Your Selection Criteria"],
	["dir", "resources", "", "index", "/howto/measurement/resources/", "Resource Tables"],
	["dir", "links", "", "index", "/howto/measurement/links/", "Related Links"],
	["dir", "glossary", "", "index", "/howto/measurement/glossary/", "Glossary"],
	["dir", "summary", "", "index", "/howto/measurement/summary/", "Summary"], 
	["dir", "eval", "", "index", "https://catalysttools.washington.edu/tools/survey/?sid=10476&amp;owner=hsled", "Evaluation"],
	["dir", "help", "", "index", "/howto/measurement/help/", "Help/Contact"]);		


function createNavigation()
{
	for(x=0; x<navList.length; x++)
	{
		if(navList[x][0] == "dir")
		{
			if(curDirectory == navList[x][1] || (navList[x][1] == linkArray[linkArray.length-3] && x != 0 && navList[x][1] != "help") || (navList[x][1] == linkArray[linkArray.length-4] && x != 0 && linkArray[linkArray.length-4] != "help"))
			{
				d.write('<div class="directoryActive"><a href="' + navList[x][4]+ '">' + navList[x][5] + '</a></div>');
			}
			else
			{
				d.write('<a href="' + navList[x][4] + '">' + navList[x][5] + '</a><br />');
			}
		}
		if(navList[x][0] == "sub")
		{
			if(curDirectory == navList[x][2] && curFileSplit[0] == navList[x][3] || navList[x][2] == linkArray[linkArray.length-3] && x != 0 || navList[x][2] == linkArray[linkArray.length-2] && x != 0)
			{
				d.write('<div class="subDirectoryActive"><a href="' + navList[x][4] + '">' + navList[x][5] + '</a></div>');
			}
			else
			{
				d.write('<div class="subDirectory"><a href="' + navList[x][4] + '">' + navList[x][5] + '</a></div>');
			}
		}
		
		// If the current file is a below the subdirectory level
		// do nothing --> i.e., do not write the anchor to the screen.
		// The link will still show up in the "Previous/Next" links
		// To do something with the sub-subdirectory elements, remove the comments below.
			
		//if(navList[x][0] != "dir" && navList[x][0] != "sub")
		//{	
			// Old script to print subdirectories to the screen --> to make active, remove comments
			//if(curDirectory == navList[x][2] && curFileSplit[0] == navList[x][3])
			//{
			//	d.write('<div class="subDirectory2Active"><a href="' + navList[x][4] + '">' + navList[x][5] + '</a></div>');
			//}
			//else
			//{
			//	d.write('<div class="subDirectory2"><a href="' + navList[x][4] + '">' + navList[x][5] + '</a></div>');
			//}
		//}
	}
}	

function createPrevNextLinks()
{
	var prevSymbol = '&laquo;&nbsp;';
	var nextSymbol = '&nbsp;&raquo;';
	var space = '&nbsp;|&nbsp;';
	for (x=0;x<navList.length;x++)
	{
		if(navList[x][0] == "dir" && navList[x][1] == curDirectory || navList[x][0] == "sub" && navList[x][2] == curDirectory || navList[x][0] != "dir" && navList[x][0] != "sub" && navList[x][2] == curDirectory)
		{
			if(navList[x][3] == curFileSplit[0])
			{
				var y = parseInt(x) -1;
				var z = parseInt(x) +1;
				if(y>=0 && z<navList.length)
				{
					if(navList[x][4] != navList[z][4])
					{
						if(navList[x][4] == navList[y][4])
						{
							var y = y - 1;
						}
						d.write(prevSymbol+'<a href="' + navList[y][4] + '" title="' + navList[y][5] + '">Previous</a>');
						d.write(space);
						d.write('<a href="' + navList[z][4] + '" title="' + navList[z][5] + '">Next</a>'+nextSymbol);
					}
				}
				else
				{
					if(y<0)
					{
						d.write(prevSymbol+'Previous');
						d.write(space);
						d.write('<a href="' + navList[z][4] + '" title="' + navList[z][5] + '">Next</a>'+nextSymbol);
					}
					else
					{
						d.write(prevSymbol+'<a href="' + navList[y][4] + '" title="' + navList[y][5] + '">Previous</a>');
						d.write(space);
						d.write('Next'+nextSymbol);
					}
				}	
			}
		}
	}
}

var dbWindow="";
function loadDB(elem)
{
	var w = screen.availWidth;
	var h = screen.availHeight;
	var dbWidth = Math.round((w * 0.7) - 20);
	var components = "left=0,top=0,width="+dbWidth+",height="+h+",scrollbars,menubar,resizable,location";
	dbWindow = window.open(elem.href,"dbWindow",components);
	dbWindow.location.href=elem.href;
	dbWindow.resizeTo(dbWidth,h);
	dbWindow.moveTo(0,0);
	return false;
}

function closeWindow(elem)
{
	if(dbWindow && !dbWindow.closed)
		{
			dbWindow.close();
		}
	window.resizeTo(screen.availWidth,screen.availHeight);
	window.moveTo(0,0);
	document.location.href = elem.href;
}



function openNewWindow(url)
{
	w.open(url,"myWindow","scrollbars,menubar,width=800,resizable");
}

function openFullWindow(url)
{
	var name = "window" + url.length;
	w.open(url, name);
}

function alertWindow(url)
{
	w.open(url,"newWindow","width=600,height=400,resizable");
}

function closeNewWindow()
{
	this.w.close();
}

/* printTable hides the tables that should not be printed, prints the page, then reveals the hidden tables again. */
function printTable(tableToHide)
{
	d.getElementById(tableToHide).style.display = "none";
	w.print();
}

/* printTable hides the tables that should not be printed, prints the page, then reveals the hidden tables again. */
function showTables()
{
	var url = d.location.href;
	url = url.substr(0, d.location.href.lastIndexOf("#"));
	d.location.href = url;
	window.location.reload();
}

// End script for Finding Measurement tutorial
//-->