// The following calls the function in the main frameset to load the correct location tab

function runYouAreHere() {
	// The following reloads the page in a frameset if it is not already there

	if (self.name != "Main") {	// if page not loaded into frameset, pass page sourcefile name to window name, omit ".html", which is illegal in window name
		var wname = self.location.href.substring((self.location.href.lastIndexOf("/"))+1, self.location.href.lastIndexOf("."))
		window.name = wname
		window.location.replace("faqframe.html")
	}
	if (self.name == "Main" && self != top) {	//if page is loaded into frameset
		parent.noSearchFlag = true
		parent.youAreHere()	//set "you are here" arrow
		faqArrows()
	}
}

function leavePage() {
	if (self.name == "Main" && self != top) {	//if page is loaded into frameset
		parent.clearLocTab()
		parent.noSearchFlag = false
	}
}

// ***************************************************


// ********************
// The following assigns onclick event handlers to navigation arrows on faq pages

var numFaqs = 18	//set to the number of FAQ pages

function faqArrows() {
	document.farleftarrow.onclick = settoc
	document.leftarrow.onclick = setback
	document.rightarrow.onclick = setforward
}

function settoc() {
	window.location.href = "faq.html#toc"
}

function setback() {
	window.location.href = faqPages[previousPage]
}

function setforward() {
	window.location.href = faqPages[nextPage]
}

var faqPages = new Array(numFaqs)
faqPages[0] = "faqfear.html"
faqPages[1] = "faqodor.html"
faqPages[2] = "faqperio.html"
faqPages[3] = "faqchild.html"
faqPages[4] = "faqcosmt.html"
faqPages[5] = "faqfees.html"
faqPages[6] = "faqinsur.html"
faqPages[7] = "faqcomp.html"
faqPages[8] = "faqtox.html"
faqPages[9] = "faqpain.html"
faqPages[10] = "faqbroke.html"
faqPages[11] = "faqimplt.html"
faqPages[12] = "faqclean.html"
faqPages[13] = "faqpros.html"
faqPages[14] = "faqendo.html"
faqPages[15] = "faqscam.html"
faqPages[16] = "faqwiz.html"
faqPages[17] = "faqtmj.html"

var thisPage = 0
var previousPage = 0
var nextPage = 0
var wname = self.location.href.substring((self.location.href.lastIndexOf("/"))+1)
for (thisPage = 0; thisPage < numFaqs; thisPage++) {
	if (wname.indexOf(faqPages[thisPage]) != -1)  { // if location is matched within faqPages[i]
		break
	}
}
previousPage = thisPage - 1
if (previousPage < 0) {
	previousPage = 0
}
nextPage = thisPage + 1
if (nextPage > numFaqs - 1) {
	nextPage = numFaqs - 1
}