var rix = 0;
var six = -1;
var mix = -1;
var aix = -1;
var pdf_params = "#pagemode=bookmarks&navpanes=1&toolbar=1&view=Fit";
var navpanes = 0
var thumbs = 0;
var toolbar = 1;
var zoom = 0;
var bookmarks = 0
var bookmarks_checked = true;
var view = "Fit"

var NEXT_SLIDE = 0;
var PREV_SLIDE = 1;
//var REPORT_MODE = 0;
//var APPX_MODE = 1;
//var PHOTO_MODE = 2
//var MAP_MODE = 3
//var mode = REPORT_MODE;

//function Xlertmsg(){
//Xlert("You pressed the keyboard inside the document!")
//}

// *****
function Page_OnLoad()
{
// Xlert("1 Page_OnLoad rt="+rt+"  root="+root);
var src = "Forward.asp"; // "_slides/report.pdf#page=10&zoom=100";


// Xlert("Page_OnLoad document.location="+document.location);
// DoSound("error.wav", 1)

LoadReportTable();
LoadPhotoTable();
LoadMapTable();
LoadAppendixTable();
// Xlert("Page_OnLoad src="+src);
// top.slide.location = src;
// GetId("bookmarks").checked == true;
// document.onkeypress=Page_OnKeyPress;
//top.menu.focus();
//top.menu.document.onkeypress=Xlertmsg
return;
}
// *****
//function Page_OnKeyPress()
//{
//Xlert("Page_OnKeyPress");
//return;
//}
// *****
function PhotoIndex_OnClick()
{
HideButtons("Map");
HideButtons("App");
ShowButtons("Photo");

BookmarksOff();
six = -1;
//mode = PHOTO_MODE;
//top.slide.location = "PhotoIndex.asp";
parent.slide.location = "PhotoIndex.asp?$W=" + screen.width + "&$S=2&$OL=Y";
return;
}
// *****
function MapIndex_OnClick()
{
HideButtons("Photo");
HideButtons("App");
ShowButtons("Map");

BookmarksOff();
mix = -1;
//mode = MAP_MODE;
//top.slide.location = "MapIndex.asp";
parent.slide.location = "MapIndex.asp?$W=" + screen.width + "&$S=2";
return;
}
// *****
function Report_OnClick()
{
HideButtons("Photo");
HideButtons("Map");
HideButtons("App");

if (bookmarks_checked == true) {
	BookmarksOn();
//	navpanes = 1
//	bookmarks = 1;
  } else {
	BookmarksOff();
//	navpanes = 0;
//	bookmarks = 0;
}
//mode = REPORT_MODE;
// top.slide.location = "_slides/report.pdf" + pdf_params;
parent.slide.location = "_slides/report.pdf" + pdf_params;
return;
}
// *****
function AppIndex_OnClick()
{
HideButtons("Photo");
HideButtons("Map");

ShowButtons("App");
//mode = APPX_MODE;
BookmarksOff();
// top.slide.location = "AppIndex.asp";
parent.slide.location = "AppIndex.asp?$W=" + screen.width + "&$S=2";
return;
}
// *****
function NextPhoto_OnClick()
{

//if (IsIndex(null) == true)
	//return(1);


//if (IsEndIndex(NEXT_SLIDE, six, top.menu.st) == true) {
if (IsEndIndex(NEXT_SLIDE, six, parent.menu.st) == true) {
	PhotoIndex_OnClick();
	return(1);
}

LoadPhoto(++six);
return;
}
// *****
function PrevPhoto_OnClick()
{

if (IsIndex(null) == true)
	return(1);

//if (IsEndIndex(PREV_SLIDE, six, top.menu.st) == true) {
if (IsEndIndex(PREV_SLIDE, six, parent.menu.st) == true) {
	PhotoIndex_OnClick();
	return(1);
}

LoadPhoto(--six);
return;
}
// *****
function NextMap_OnClick()
{
if (IsIndex(null) == true)
	return(1);

//if (IsEndIndex(NEXT_SLIDE, mix, top.menu.mt) == true) {
if (IsEndIndex(NEXT_SLIDE, mix, parent.menu.mt) == true) {
	MapIndex_OnClick();
	return(1);
}

LoadMap(++mix);
return;
}
// *****
function PrevMap_OnClick()
{
if (IsIndex(null) == true)
	return(1);

//if (IsEndIndex(PREV_SLIDE, mix, top.menu.mt) == true) {
if (IsEndIndex(PREV_SLIDE, mix, parent.menu.mt) == true) {
	MapIndex_OnClick();
	return(1);
}

LoadMap(--mix);
return;
}
// *****
function NextApp_OnClick()
{
if (IsIndex(null) == true)
	return(1);

// if (IsEndIndex(NEXT_SLIDE, aix, top.menu.at) == true) {
if (IsEndIndex(NEXT_SLIDE, aix, parent.menu.at) == true) {
	AppIndex_OnClick();
	return(1);
}

LoadAppendix(++aix);
return;
}
// *****
function PrevApp_OnClick()
{
// Xlert("1 PrevApp");
if (IsIndex(null) == true)
	return(1);
// Xlert("2 PrevApp");
//if (IsEndIndex(PREV_SLIDE, aix, top.menu.at) == true) {
if (IsEndIndex(PREV_SLIDE, aix, parent.menu.at) == true) {
	AppIndex_OnClick();
	return(1);
}

LoadAppendix(--aix);
return;
}
// *****
function HelpUs_OnClick()
{
HideId("ButtonSet1");
ShowId("ButtonSet2");
// top.slide.location = "http://www.newildernesstrust.org/article/view/8645/1/276/";
// top.slide.location = "http://newildernesstrust.org/wapack_donate/";
parent.slide.location = "http://newildernesstrust.org/wapack_donate/";
return;
}
// *****
function Return_OnClick()
{
HideId("ButtonSet2");
ShowId("ButtonSet1");
//top.slide.location = "Forward.asp";
parent.slide.location = "Forward.asp?$W=" + screen.width + "&$S=2";
return;
}
// *****
function Exit_OnClick()
{

// var s = top.calleeURL;
var s = parent.calleeURL;

s = s.toUpperCase();

// parent.calleeURL = "http://www.TOWNOFNEWIPSWICH.org";
if (s.indexOf("TOWNOFNEWIPSWICH") != -1) {
	top.document.location = "http://www.TownOfNewIpswich.org/index.aspx";
//	parent.document.location = "http://www.TownOfNewIpswich.org";
	return(false);
}

if (s.indexOf("TONI") != -1) {
	top.document.location = "http://localhost/toni/index.aspx";
//	parent.document.location = "http://www.NewIpswichCC.org";
	return(false);
}

if (s.indexOf("NEWIPSWICHCC") != -1) {
	top.document.location = "http://www.NewIpswichCC.org";
//	parent.document.location = "http://www.NewIpswichCC.org";
	return(false);
}

if (s.indexOf("CONCOM") != -1) {
	top.document.location = "http://localhost/concom";
//	parent.document.location = "http://www.NewIpswichCC.org";
	return(false);
}

//if (s.indexOf("NORTHEASTWILDERNESSTRUST") != -1) {
//	top.document.location = "http://www.newildernesstrust.org/article/view/8645/1/276/";
//	return;
//}

top.document.location = top.calleeURL;
/*
// Xlert("top.callee="+top.callee);
switch (top.callee) {
	case "CC":
		 top.document.location = "http://www.NewIpswichCC.org";
		 break;
	case "TONI":
		 top.document.location = "http://www.TownOfNewIpswich.org";
		 break;
	default:
		 top.document.location = "http://www.newildernesstrust.org/article/view/8645/1/276/";
		 break;
}
*/
// callee = alert(QueryURL("callee"));
// top.window.opener.history.back();

//alert(parent.window.opener.document.location);
//top.window.opener = "x";
// top.window.close();
// alert(top.window.opener.frames.length);
//top.window.close(); //location = top.window.opener.document.location;
//top.window.opener.close();
//top.window.document.location  = top.window.opener.location; // window.opener.document.location;
// top.document.location = "http://www.
// top.window.close();
return;
}
// *****
function Bookmarks_OnClick()
{
ToggleBookmarks();
return;
}
// *****
function SetPhotoIndex(s)
{
var i, j = 0, t;

s = unescape(s.toLowerCase());
//for (j = 0; j < top.menu.st.length; ++j) {
for (j = 0; j < parent.menu.st.length; ++j) {
//	t = new String(top.menu.st[j].file);
	t = new String(parent.menu.st[j].file);
	t = t.toLowerCase();
	if (s == t)
		break;
}
six = j;
return(six);
}
// *****
function SetMapIndex(s)
{
var i, j = 0, t;

s = unescape(s.toLowerCase());
//for (j = 0; j < top.menu.mt.length; ++j) {
for (j = 0; j < parent.menu.mt.length; ++j) {
//	t = new String(top.menu.mt[j].file);
	t = new String(parent.menu.mt[j].file);
	t = t.toLowerCase();
	if (s == t)
		break;
}
mix = j;
return(mix);
}
// *****
function SetAppIndex(s)
{
var i, j = 0, t;

s = unescape(s.toLowerCase());
// for (j = 0; j < top.menu.at.length; ++j) {
for (j = 0; j < parent.menu.at.length; ++j) {
//	t = new String(top.menu.at[j].file);
	t = new String(parent.menu.at[j].file);
	t = t.toLowerCase();
	if (s == t)
		break;
}
aix = j;
return(aix);
}
// *****
function SetPageIndex(url)
{
var s = new String(url);


if (IsPhotoIndex() == true) {
	SetPhotoIndex(s);
	return(six);
}

if (IsMapIndex() == true) {
	SetMapIndex(s)
	return(mix);
}

if (IsAppIndex() == true) {
	SetAppIndex(s)
	return(aix);
}
return(six);
}
// *****
function LoadReport(i)
{
// var s = new String(top.menu.st[i].file);
var s = new String(parent.menu.st[i].file);
var s = s.toLowerCase();

// SetParams(top.menu.rt, i);
SetParams(parent.menu.rt, i);
//top.frames[1].location = "_slides/" + top.menu.rt[i].file + "?" + DoWhen() + pdf_params;
parent.frames[1].location = "_slides/" + parent.menu.rt[i].file + "?" + DoWhen() + pdf_params;
return;
}
// *****
function LoadPhoto(i)
{
//var s = new String(top.menu.st[i].file);
var s = new String(parent.menu.st[i].file);
var s = s.toLowerCase();

//if (s.indexOf("body") != -1) {
//	navpanes = 1
//	bookmarks = 1;
//} else {
//	navpanes = 0;
//	bookmarks = 0;
//}

//SetParams(top.menu.st, i);
SetParams(parent.menu.st, i);
//top.frames[1].location = "_slides/" + top.menu.st[i].file + "?" + DoWhen() + pdf_params;
parent.frames[1].location = "_slides/" + parent.menu.st[i].file + "?" + DoWhen() + pdf_params;
return;
}
// *****
function LoadMap(i)
{
//var s = new String(top.menu.mt[i].file);
var s = new String(parent.menu.mt[i].file);
var s = s.toLowerCase();

navpanes = 0;
bookmarks = 0;
//SetParams(top.menu.mt, i);
SetParams(parent.menu.mt, i);
//top.frames[1].location = "_slides/" + top.menu.mt[i].file + "?" + DoWhen() + pdf_params;
parent.frames[1].location = "_slides/" + parent.menu.mt[i].file + "?" + DoWhen() + pdf_params;
return;
}
// *****
function LoadAppendix(i)
{
// var s = new String(top.menu.at[i].file);
var s = new String(parent.menu.at[i].file);
var s = s.toLowerCase();

if (s.indexOf("appendix a") != -1) {
	if (bookmarks_checked == true) {
		BookmarksOn();
//		navpanes = 1
//		bookmarks = 1;
	  } else {
		BookmarksOff();
//		navpanes = 0;
//		bookmarks = 0;
	}
  } else {
	BookmarksOff();
//	navpanes = 0;
//	bookmarks = 0;
}

// SetParams(top.menu.at, i);
SetParams(parent.menu.at, i);
//top.frames[1].location = "_slides/" + top.menu.at[i].file + "?" + DoWhen() + pdf_params;
parent.frames[1].location = "_slides/" + parent.menu.at[i].file + "?" + DoWhen() + pdf_params;
return;
}
// *****
function HideButtons(sfx)
{
HideId("Prev" + sfx);
HideId("Next" + sfx);
return;
}
// *****
function ShowButtons(sfx)
{
ShowId("Prev" + sfx);
ShowId("Next" + sfx);
return;
}
// *****
function ShowId(id)
{
if (id != null && id != "")
	GetId(id).style.display = "";
return;
}
// *****
function HideId(id)
{
if (id != null && id != "")
	GetId(id).style.display = "none";
return;
}
// *****
function SetParams(arr, i)
{
pdf_params = "";

// Xlert("SetParams");
if (bookmarks == 1) {
	navpanes = 1;
	pdf_params = "#pagemode=bookmarks";
  } else {
	navpanes = 0;
	pdf_params = "#pagemode=none";
}

pdf_params = pdf_params + "&navpanes=" + navpanes;
pdf_params = pdf_params + "&toolbar=" + toolbar;



// Xlert("SetParams zoom="+zoom+" view="+view);
/*
if (top.menu.st[i].scale == 0) {
	if (zoom < 25)
		pdf_params = pdf_params + "&view=" + view;
	  else
	  pdf_params = pdf_params + "&zoom=" + zoom;
  } else {
	pdf_params = pdf_params + "&zoom=" + top.menu.st[i].scale;
} */

if (arr[i].scale == 0)
	pdf_params = pdf_params + "&view=" + view;
  else
	pdf_params = pdf_params + "&zoom=" + arr[i].scale;
return;
}
// *****
function Link_OnClick(file)
{

SetPageIndex(file);

if (IsPhotoIndex() == true) {
	LoadPhoto(six);
	return(false);
}

if (IsMapIndex() == true) {
	LoadMap(mix);
	return(false);
}

if (IsAppIndex() == true) {
	LoadAppendix(aix);
	return(false);
}
return;
}
// *****
function ToggleBookmarks()
{
bookmarks_checked = GetId("bookmarks").checked;

if (bookmarks_checked == true) {
	navpanes = 1
	bookmarks = 1;
//	bookmarks_checked = false;
//	BookmarksOn();
  } else {
	navpanes = 0;
	bookmarks = 0;
//	bookmarks_checked = true;
//	BookmarksOff();
}
ReloadSlide();
return;
}

// *****
function BookmarksOff()
{
//HideId("bookmarksLabel");
//HideId("bookmarks");
navpanes = 0
bookmarks = 0;
return;
}
// *****
function BookmarksOn()
{
//ShowId("bookmarksLabel");
//ShowId("bookmarks");
navpanes = 1
bookmarks = 1;
return;
}
// *****
function ReloadSlide()
{

if (IsPhotoIndex() == true) {
//	SetParams(top.menu.st[six], six);
	LoadPhoto(six);
  } else {
	if (IsMapIndex() == true) {
//		SetParams(top.menu.mt[mix], mix);
		LoadMap(mix);
	  } else {
		if (IsAppIndex() == true) {
//			SetParams(top.menu.st[aix], aix);
			LoadApp(aix);
		  } else {
//			SetParams(top.menu.rt, rix);
			LoadReport(rix);
		}
	}
}
return;
}
// *****
function DoWhen()
{
var now, when;

now = new Date();
when = now.getTime();
return(when);
}
// *****
function DoPDF(i)
{
var s = new String(document.location);
var arr, text, file;

arr = SelectSlide(i);

text = arr.text;
file = arr.file;

if (text == "") {
	s = new String(file);
	if (s.indexOf("report") != -1)
		text = s.replace(/.pdf/i,"");
}

//Wr("<a class='StdLink' href='' onclick='return top.menu.Link_OnClick(\"" + file + "\");'>" + text + "</a>");
Wr("<a class='StdLink' href='' onclick='return parent.menu.Link_OnClick(\"" + file + "\");'>" + text + "</a>");
return;
}
// *****
function DoTitle(text)
{
//if (top.is_ie6up)
if (parent.is_ie6up)
	marg_top = 0;
  else
    marg_top = 4;

Wr("<div class='TitleBar' style='margin-top:" + marg_top + "'>");
	Wr(text);
Wr("</div>");
return;
}
// *****
function DoAppendix(i, level)
{
Wr("<li class='AppendixBullet10'>");
	DoPDF(i);
	//Wr("<span class='AppendixBulletText10'>" + top.menu.at[i].text1 + "</span>");
	Wr("<span class='AppendixBulletText10'>" + parent.menu.at[i].text1 + "</span>");
Wr("</li>")
return;
}
// *****
function DoPlate(i, j, level)
{
var pno = 1;
if (j > 8)
	pno = 2;
Wr("<li class='PlateBullet" + pno + "0'>");
	DoPDF(i);
//	Wr("<span class='PlateBulletText" + pno + "0'>" + top.menu.st[i].text1 + "</span>");
	Wr("<span class='PlateBulletText" + pno + "0'>" + parent.menu.st[i].text1 + "</span>");
Wr("</li>")
return;
}
// *****
function DoMap(i, level)
{
Wr("<li class='MapBullet10'>");
	DoPDF(i);
//	Wr("<span class='MapBulletText10'>" + top.menu.mt[i].text1 + "</span>");
	Wr("<span class='MapBulletText10'>" + parent.menu.mt[i].text1 + "</span>");
Wr("</li>")
return;
}
// *****
function DoText(level, text)
{
Wr("<tr>");
	Wr("<td width=100% colspan=2 align='left'>");
	if (level > 1) {
		Wr("<li class='StdBullet" + (level - 1) + "'>");
			Wr(text);
		Wr("</li>");
	  } else {
		Wr(text);
	}
	Wr("</td>")
Wr("</tr>");
return;
}
// *****
function IsPhotoIndex()
{
return(IsIndex("PhotoIndex"));
}
// *****
function IsMapIndex()
{
return(IsIndex("MapIndex"));
}
// *****
function IsAppIndex()
{
return(IsIndex("AppIndex"));
}
// *****
function IsIndex(key)
{
var ret = false;
// var s = new String(top.slide.location);
var s = new String(parent.slide.location);
var k;

if (key == null)
	k = "Index";
  else
    k = key;
if (s.indexOf(k) != -1) {
	if (key == null)
		DoSound("error.wav", 1)
	ret = true;
}
return(ret);
}
// *****
function IsEndIndex(dir, ix, arr)
{
var ret = false;

if (dir == PREV_SLIDE && ix == 0)
	return(true);

if (dir == NEXT_SLIDE && ix > arr.length - 2)
	ret = true;
return(ret);
}
// *****
function SelectSlide(i)
{
var arr;

if (IsPhotoIndex() == true) {
//	arr =  top.menu.st[i];
	arr =  parent.menu.st[i];
  } else {
	if (IsMapIndex() == true) {
//		arr =  top.menu.mt[i];
		arr =  parent.menu.mt[i];
	  } else {
//		arr =  top.menu.at[i];
		arr =  parent.menu.at[i];
	}
}
return(arr);
}
// *****
function DoPCC()
{
Wr("<span style='font-family: Arial;font-size: 9px;text-align: center;'>");
	Wr("<a href='mailto: Bob@GoPCC.com' title='Click this link to contact us'>");
		Wr("This Web Site Compliments of PC Consultants, Inc.");
	Wr("</a>");
Wr("</span>");
return;
}