// ============================================================================ //
// WebShots JavaScript Engine:                                                  //
// ---------------------------                                                  //
//  WebShots format and JavaScript code engine © Copyright 2003-2006 Orton      //
//	Family Foundation  and Placeways, LLC. All rights reserved.   WebShots      //
//  content is owned by and is the responsibility of the author.  WebShots      //
//  presentations may be freely copied and distributed at the discretion of     //
//  and under the rights of the content author.                                 //
// ============================================================================ //

// ------- //
// Globals //
// ------- //
var bToResposNavLayers = true;
var iPos = location.href.indexOf("WebShots.htm")
var theWebShotsFolder = location.href.substring(0,iPos);	
var bNS = (navigator.appName == "Netscape");
var _dPixelWidth = 0;
var _dPixelHeight = 0;

// ---------------- //
// String Functions //
// ---------------- //
 function CommaParse(){
	var iPos_Start = 0;
	var iPos_End = 0;
	var iTemp = 0;
	var sItem;
	var i = 0;
	var alItems = new Array();
	var bQuote = false;
	while (iPos_Start < this.length) {
		if (this.charAt(iPos_Start) == '"') {
			i = iPos_Start;
			do {
				i++;
			} while(this.charAt(i) == '"');
			if ((i - iPos_Start) % 2 == 1) {
				bQuote = true;
				i = iPos_Start;
				do {
					i = this.indexOf("\",", i);
					if (i >= 1 && this.charAt(i - 1)=='"') {				
						iTemp = i;
						do {
							iTemp--;
						} while(this.charAt(iTemp)=='"');
						if((i - iTemp) % 2 == 0){
							i++;
						}
					} else if(iPos_Start == i) {
						i++;
					}
					iPos_End = i + 1;
				} while(iPos_End > 0 && this.charAt(i) != '"');
				iPos_End--;
				iPos_Start++;
			} else {
				iPos_End = this.indexOf(",", iPos_Start);
			}
		} else {
			iPos_End = this.indexOf(",", iPos_Start);
		}
		if (iPos_End == -1) {
			if (bQuote == true) {
				sItem = this.substring(iPos_Start, this.length - 1);
			} else {
				sItem = this.substring(iPos_Start, this.length);
			}
			alItems.push(sItem);
			break;
		} else {
			sItem = this.substring(iPos_Start, iPos_End);
			alItems.push(sItem);
		}
		iPos_Start = iPos_End + 1;
		if (bQuote == true) {
			bQuote = false;
			iPos_Start++;
		}
		if (iPos_Start == this.length && this.lastIndexOf(",") == iPos_Start-1) {
			alItems.push("");
		}
	}
	return alItems;
}
String.prototype.parse = CommaParse;

// ---------------- //
// Number Functions // (hanldes rounding)
// ---------------- //
function ToDecimalString(iDecimals) {
	var sNewValue = "";
	var iDec = parseInt(iDecimals);
	var iRaise = Math.pow(10,iDec);
	var iEval = Math.round(this * iRaise);
	var dNumber = parseFloat(iEval + 0.1) / iRaise;
	var sNumber = dNumber.toString();
	var iPos = sNumber.indexOf(".");
	var iCurrentDec = 0;
	if (iPos != -1) {
		if (iDec > 0) {
			iCurrentDec = parseInt(sNumber.length - iPos - 1);
			if (iCurrentDec >= iDec) {
				sNewValue = sNumber.substr(0,iPos + iDec + 1);
				if (iPos = 0) {
					sNewValue = "0" + sNewValue;
				}
			} else {
				for (i=iCurrentDec;i<iDec;i++) {
					sNewValue += "0";
				}
			}
		} else {
			sNewValue = sNumber.substr(0,iPos);
		}
	} else {
		if (iDec > 0) {
			sNewValue = sNumber + ".";
			for (i=0;i<iDec;i++) {
				sNewValue += "0";
			}
		} else {
			sNewValue = sNumber;
		}
	}
	return sNewValue;
}
Number.prototype.toDecimalStr = ToDecimalString;

// --------------- //
// Array Functions //
// --------------- //
function Contains(aValue) {
	var bLocated = false;
	for (i=0;i<this.length;i++) {
		if (this[i] == aValue) {
			bLocated = true;
			break;
		}
	}
	return bLocated;
}
Array.prototype.contains = Contains;

// ------------------- //
// Data Extract Object //
// ------------------- //

// Prototype
function Hash_prototype() {
	this.Length = function() {
		return this.Keys.length;
	}
	this.Add = function(aKey, aValue) {
		this.Library[aKey] = aValue;
		this.Keys.push(aKey);
		this.Values.push(aValue);
	}
	this.Remove = function(aKey) {
		var NewKeys = new Array();
		var NewValues = new Array();
		this.Library[aKey] = nil;
		for (i=0;i<this.Keys.length;i++) {
			if (this.Keys[i] != aKey) {
				NewKeys.push(aKey);
				NewValues.push(aValue);
			}
		}
		this.Keys = NewKeys;
		this.Values = NewValues;
	}
	this.Get = function(aKey) {
		if (this.Library[aKey] == null) {
			var bFoundKey = false;
			var iIndex = 0;
			for (i=0;i<this.Keys.length;i++) {
				if (this.Keys[i] == aKey) {
					bFoundKey = true;
					iIndex = i;
					break;
				}
			}
			if (bFoundKey) { 
				return this.Values[iIndex];
			} else {
				return "";
			}
		} else {
			return this.Library[aKey];
		}
	}
	this.ContainsKey = function(aKey) {
		var bIsContained = false;
		for (i=0;i<this.Keys.length;i++) {
			if (this.Keys[i] == aKey) {
				bIsContained = true;
				break;
			}
		}
		return bIsContained;
	}
}

// Constructor
function Hash() {
	this.Library = new Object();
	this.Keys = new Array();
	this.Values = new Array();
}
Hash.prototype = new Hash_prototype();


// ----------------------------------------------- //
// WebShot Assumption, Indicator and Chart Objects //
// ----------------------------------------------- //

// Prototypes
function Component_prototype() {
	this.Name = "";
	this.Description = "";
}
function Element_prototype() {
	this.Units = "";
}
Element_prototype.prototype = new Component_prototype();

// Constructors
function Assumption() {}
function Indicator() {}
function Chart() {}
Assumption.prototype = new Element_prototype();
Indicator.prototype = new Element_prototype();
Chart.prototype = new Component_prototype();

// --------------------- //
// WebShot Value Objects //
// --------------------- //

function AssumptionStats_prototype() {
	this.Name = "";
	this.Min = "";
	this.Max = "";
	this.Type = "";
	this.Units = "";
	this.Decimals = "";
	this.Description = "";
}
function AssumptionValue_prototype() {
	this.Name = "";
	this.Description = "";
	this.Units = "";
	this.Value = "";
	this.Decimals = "";
}
function ChartPath_prototype() {
	this.Name = "";
	this.Description = "";
	this.Path = "";
}
function IndicatorValue_prototype() {
	this.Name = "";
	this.Description = "";
	this.Units = "";
	this.Value = "";
	this.Decimals = "";
}
function ItemDescription_prototype() {
	this.Name = "";
	this.Description = "";
}
function Report_prototype() {
	this.Name = "";
	this.Path = "";
}
function SubLegend_prototype() {
	this.Name = "";
	this.Description = "";
	this.LegendPath = "";
}

// Constructors
function AssumptionStats() {}
function AssumptionValue() {}
function ChartPath() {}
function IndicatorValue() {}
function ItemDescription() {}
function Report() {}
function SubLegend() {}
AssumptionStats.prototype = new AssumptionStats_prototype();
AssumptionValue.prototype = new AssumptionValue_prototype();
ChartPath.prototype = new ChartPath_prototype();
IndicatorValue.prototype = new IndicatorValue_prototype();
ItemDescription.prototype = new ItemDescription_prototype();
Report.prototype = new Report_prototype();
SubLegend.prototype = new SubLegend_prototype();


// --------------- //
// Options Objects //
// --------------- //

function AssumptionValues_prototype() {
	this.Assumption = "";
	this.Default = "";
}

function Options_prototype() {
	this.Scenario = "";	
	this.ContainsAssumption = function(anAssumption) {
		var bIsContained = false;
		for (i=0;i<this.Assumptions.length;i++) {
			if (this.Assumptions[i].Assumption == anAssumption) {
				bIsContained = true;
				break;
			}
		}
		return bIsContained;
	}
	this.GetAssumptionValue = function(anAssumption) {
		var anAssumptionValue = null;
		for (i=0;i<this.Assumptions.length;i++) {
			if (this.Assumptions[i].Assumption == anAssumption) {
				anAssumptionValue = this.Assumptions[i];
				break;
			}
		}
		return anAssumptionValue;
	}
	this.AddAssumptionValue = function(anAssumption, aValue, bIsDefault) {
		var bFoundValue = false;
		var anAssumptionValue = null;
		if (!this.ContainsAssumption(anAssumption)) {
			var aNewAssumptionValue = new AssumptionValues();
			aNewAssumptionValue.Assumption = anAssumption;
			aNewAssumptionValue.Default = (bIsDefault) ? aValue : "";
			this.Assumptions.push(aNewAssumptionValue);
		}
		anAssumptionValue = this.GetAssumptionValue(anAssumption);
		for (i=0;i<anAssumptionValue.Values.length;i++) {
			if (anAssumptionValue.Values[i] == aValue) {
				bFoundValue = true;
				break;
			}
		}
		if (!bFoundValue) {
			anAssumptionValue.Values.push(aValue);
			anAssumptionValue.Default = (bIsDefault) ? aValue : "";
		}
	}
}

// Constructors
function AssumptionValues() {
	this.Values = new Array();
}
function Options() {
	this.Scenarios = new Array();
	this.Assumptions = new Array();
}
//ScenarioValues.prototype = new ScenarioValues_prototype();
AssumptionValues.prototype = new AssumptionValues_prototype();
Options.prototype = new Options_prototype();

// -------------- //
// WebShot Object //
// -------------- //

// Prototype
function WebShot_prototype() {
	this.ItemName = "";
	this.Scenario = "";
	this.Assumption = "";
	this.Value = "";
	this.MapImagePath = "";
	this.Explorable = false;
	this.SlideShow = false;
	this.IsDefault = false;
	this.AddAssumption = function(anAssumption) {
		this.ReportAssumptions.push(anAssumption);
	}
	this.AddChart = function(aChart) {
		this.ReportCharts.push(aChart);
	}
	this.AddIndicator = function(anIndicator) {
		this.ReportIndicators.push(anIndicator);
	}
	this.GetAssumptionValuesName = function() {
		var sName = "";
		sName = "Assumption Values," + this.Assumption + "," + this.Scenario + ",\"" + this.Value + "\"";
		return sName;
	}
	this.GetChartPathsName = function() {
		var sName = "";
		sName = "Chart Paths," + this.Assumption + "," + this.Scenario + ",\"" + this.Value + "\"";
		return sName;
	}
	this.GetDefaultName = function() {
		var sName = "";
		sName = this.Assumption + "_DefaultValue";
		return sName;
	}
	this.GetIndicatorValuesName = function() {
		var sName = "";
		sName = "Indicator Values," + this.Assumption + "," + this.Scenario + ",\"" + this.Value + "\"";
		return sName;
	}
	this.GetMapName = function() {
		var Name = "";
		sName = "Maps," + this.Assumption + "," + this.Scenario;
		return sName;
	}
	this.GetAssumptionStatsName = function () {
		var sname = "";
		sName = "Statistics," + this.Assumption;
		return sName;
	}
}

// Constructor
function WebShot() {
	this.ReportAssumptions = new Array();
	this.ReportCharts = new Array();
	this.ReportIndicators = new Array();
}
WebShot.prototype = new WebShot_prototype();


// ----------------- //
// WebShotSet Object //
// ----------------- //

// Prototype
function WebShotSet_prototype() {
	this.SlidePosition = -1;
	this.LegendPath = "";
	this.LinksToReports = false;
	this.CurrentWebShot = null;
	this.CoordTop = 0;
	this.CoordBottom = 0;
	this.CoordLeft = 0;
	this.CoordRight = 0;
	this.ScaleTop = 0;
	this.ScaleBottom = 0;
	this.ScaleLeft = 0;
	this.ScaleRight = 0;
	this.Scale1Pixels = 0;
	this.Scale2Pixels = 0;
	this.Scale1Units = "";
	this.Scale2Units = "";
	this.CoordsUnits = "";
	this.BaseMapWidth = 1;
	this.BaseMapHeight = 1;
	
	// Add WebShot
	this.Add = function(aWebShot) {
		this.WebShots.push(aWebShot);
	}
	
	// Get WebShot
	this.Get = function(anAssumption, aScenario, aValue) {
		var aWebShot = null;
		for (var i=0;i<this.WebShots.length;i++) {
			if ((this.WebShots[i].Assumption == anAssumption) && 
				(this.WebShots[i].Scenario == aScenario) &&
				(this.WebShots[i].Value == aValue)) {
				aWebShot = this.WebShots[i];
				break;
			}
		}
		return aWebShot;
	}
	
	// Get WebShot via Item Name
	this.ItemGet = function(anItem) {
		var aWebShot = null;
		for (var i=0;i<this.WebShots.length;i++) {
			if (this.WebShots[i].ItemName == anItem) {
				aWebShot = this.WebShots[i];
				break;
			}
		}
		return aWebShot;
	}
	
	// Get Current Description
	this.GetDescription = function() {
		var sDescHTML = "";
		var txtDescription = document.getElementById("WebShotsDescription");
		var txtSummary = document.getElementById("WebShotsSummary");
		if ((_oDataHash == null) || (this.CurrentWebShot == null)) {
			if (txtSummary.innerHTML != "") {
				sDescHTML = txtSummary.innerHTML;
			}
		} else {
			var sName = "WebShot Description," + this.CurrentWebShot.Assumption + "," + this.CurrentWebShot.Scenario + 
				",\"" + this.CurrentWebShot.Value + "\"";
			if (_oDataHash.ContainsKey(sName)) {
				var alValue = _oDataHash.Get(sName).parse();
				sDescHTML = alValue[0];
			} else {
				sDescHTML = "";
			}
		}
		txtDescription.innerHTML = sDescHTML;
	}
	
	// Explorable Methods
	this.ContainsExplorable = function(aScenario) {
		var bIsContained = false;
		for (var i=0;i<this.Explorable.length;i++) {
			if (this.Explorable[i].Scenario == aScenario) {
				bIsContained = true;
				break;
			}
		}
		return bIsContained;
	}
	this.GetExplorable = function(aScenario) {
		var anOption = null;
		for (var i=0;i<this.Explorable.length;i++) {
			if (this.Explorable[i].Scenario == aScenario) {
				anOption = this.Explorable[i];
				break;
			}
		}
		return anOption;
	}
	this.AddExplorable = function(anAssumption, aScenario, aValue, bIsDefault) {
		var bFoundValue = false;
		var anOption = null;
		if (!this.ContainsExplorable(aScenario)) {
			var aNewOption = new Options();
			aNewOption.Scenario = aScenario;
			this.Explorable.push(aNewOption);
		}
		anOption = this.GetExplorable(aScenario);
		anOption.AddAssumptionValue(anAssumption, aValue, bIsDefault);
	}

	// Slide Show Methods
	this.ContainsSlide = function(anItem) {
		var bIsContained = false;
		for (var i=0;i<this.SlideShow.length;i++) {
			if (this.SlideShow[i] == anItem) {
				bIsContained = true;
				break;
			}
		}
	}
	this.AddSlide = function(anItem) {
		if (!this.ContainsSlide(anItem)) {
			this.SlideShow.push(anItem);
		}
	}
	this.FirstSlide = function() {
		this.SlidePosition = 0;
		if (this.SlideShow.length > 0) {
			this.CurrentWebShot = this.ItemGet(this.SlideShow[this.SlidePosition])
		} else {
			this.SlidePosition = -1;
			this.CurrentWebShot = null;
		}
		return this.CurrentWebShot;
	}
	this.NextSlide = function() {
		this.SlidePosition += 1;
		if (this.SlidePosition >= this.SlideShow.length) {
			this.SlidePosition = this.SlideShow.length - 1;
		}
		this.CurrentWebShot = this.ItemGet(this.SlideShow[this.SlidePosition]);
		return this.CurrentWebShot;
	}
	this.PrevSlide = function() {
		this.SlidePosition -= 1;
		if (this.SlidePosition < 0) {
			this.SlidePosition = 0;
		}
		this.CurrentWebShot = this.ItemGet(this.SlideShow[this.SlidePosition]);
		return this.CurrentWebShot;
	}
	this.LastSlide = function() {
		this.SlidePosition = this.SlideShow.length - 1;
		if (this.SlidePosition >= 0) {
			this.CurrentWebShot = this.ItemGet(this.SlideShow[this.SlidePosition]);
		} else {
			this.SlidePosition = -1;
			this.CurrentWebShot = null;
		}
		return this.CurrentWebShot;
	}
	this.GetSlideNumber = function() {
		var iSlideNumber = 0;
		iSlideNumber = this.SlidePosition + 1;
		if (iSlideNumber <= 0) {
			iSlideNumber = 1;
		} else if (iSlideNumber > this.SlideShow.length) {
			iSlideNumer = this.SlideShow.length;
		}
		return iSlideNumber;
	}
	this.GotoSlide = function(theSlideNumber) {
		var iSlide = parseInt(theSlideNumber) - 1;
		if ((iSlide >= 0) && (iSlide <= (this.SlideShow.length - 1))) {
			this.SlidePosition = iSlide 
		}
		this.CurrentWebShot = this.ItemGet(this.SlideShow[this.SlidePosition]);
		return this.CurrentWebShot;
	}
	
	// Scenario Methods
	this.AddScenario = function(aScenario, aDescription) {
		if (!this.ContainsScenario(aScenario)) {
			var aScenarioItem = new ItemDescription();
			aScenarioItem.Name = aScenario;
			aScenarioItem.Description = aDescription;
			this.Scenarios.push(aScenarioItem);
		}
	}
	this.ContainsScenario = function(aScenario) {
		var bIsContained = false;
		for (var i=0;i<this.Scenarios.length;i++) {
			if (this.Scenarios[i].Name == aScenario) {
				bIsContained = true;
				break;
			}
		}
		return bIsContained;
	}
	this.GetScenario = function(aScenario) {
		var aScenarioItem = null;
		for (var i=0;i<this.Scenarios.length;i++) {
			if (this.Scenarios[i].Name == aScenario) {
				aScenarioItem = this.Scenarios[i];
				break;
			}
		}
		return aScenarioItem;
	}
	
	// WebShot Assumption Statistics Methods
	this.AddAssumption = function(anAssumption, aMin, aMax, aType, aUnits, aDecimal, aDescription) {
		if (!this.ContainsAssumption(anAssumption)) {
			var anAssumptionStats = new AssumptionStats();
			anAssumptionStats.Name = anAssumption;
			anAssumptionStats.Min = aMin;
			anAssumptionStats.Max = aMax;
			anAssumptionStats.Type = aType;
			anAssumptionStats.Units = aUnits;
			anAssumptionStats.Decimals = aDecimal;
			anAssumptionStats.Description = aDescription;
			this.Assumptions.push(anAssumptionStats);
		}
	}
	this.ContainsAssumption = function(anAssumption) {
		var bIsContained = false;
		for (var i=0;i<this.Assumptions.length;i++) {
			if (this.Assumptions[i].Name == anAssumption) {
				bIsContained = true;
				break;
			}
		}
		return bIsContained;
	}
	this.GetStats = function(anAssumption) {
		var aStats = null;
		var bFoundItem = false;
		for (var i=0;i<this.Assumptions.length;i++) {
			if (this.Assumptions[i].Name == anAssumption) {
				bFoundItem = true;
				aStats = this.Assumptions[i];
				break;
			}
		}
		return aStats;
	}
	
	// SubLegend Methods
	this.AddLegend = function(aLayer, aDescription, aPath) {
		if (!this.ContainsLegend(aLayer)) {
			var aSubLegend = new SubLegend();
			aSubLegend.Name = aLayer;
			aSubLegend.Description = aDescription;
			aSubLegend.LegendPath = aPath;
			this.SubLegends.push(aSubLegend);
		}
	}
	this.ContainsLegend = function(aLayer) {
		var bIsContained = false;
		for (var i=0;i<this.SubLegends.length;i++) {
			if (this.SubLegends[i].Name == aLayer) {
				bIsContained = true;
				break;
			}
		}
		return bIsContained;
	}
	
	// Report Methods
	this.AddReport = function(aReport, aPath) {
		if (!this.ContainsReport(aReport)) {
			var aReport = new Report();
			aReport.Name = aReport;
			aReport.Path = aPath;
			this.Reports.push(aReport);
		}
	}
	this.ContainsReport = function(aReport) {
		var bIsContained = false;
		for (var i=0;i<this.Reports.length;i++) {
			if (this.Reports[i].Name == aReport) {
				bIsContained = true;
				break;
			}
		}
		return bIsContained;
	}
}

// Constructor
function WebShotSet() {
	this.Assumptions = new Array();
	this.Explorable = new Array();
	this.Reports = new Array();
	this.Scenarios = new Array();
	this.SlideShow = new Array();
	this.SubLegends = new Array();
	this.WebShots = new Array();
}
WebShotSet.prototype = new WebShotSet_prototype();


// ------- //
// Globals //
// ------- //
var _oDataHash = new Hash();
var _oWebShotSet = new WebShotSet();


// ----------- //
// Data Loader //
// ----------- //
function LoadData() {

	// Upload the data stored in the Div tags into a custom hash object
	var idLen_name = 0;
	var idLen_value = 0;
	var mystring = "";
	var myarray = new Array();
	var sTest_name = "";
	var sTest_value = "";
	var re_name = /name__/;
	var re_value = /value_/;

	var DataFrame = (bNS) ? document.getElementById("WebShots_data").contentDocument : 
		document.WebShots_data.document;
	
	for (var i=0;i<DataFrame.all.length;i++) {
		idLen_name = DataFrame.all[i].id.length;
		sTest_name = DataFrame.all[i].id.replace(re_name,"");						
		if (sTest_name.length < idLen_name) {
			for (var j=0;j<DataFrame.all.length;j++) {
				idLen_value = DataFrame.all[j].id.length;
				sTest_value = DataFrame.all[j].id.replace(re_value,"");
				if ((sTest_value.length < idLen_value) && 
					(sTest_name == sTest_value)) {
					_oDataHash.Add( DataFrame.all[i].innerHTML, DataFrame.all[j].innerHTML );
				}
			}
		}
	}
	
	// Transfer the data from the hash to the data storage object (_oWebShotSet)
	var alAssumptionDecimals = new Array();
	var alAssumptionDescriptions = new Array();
	var alAssumptionStats = new Array();
	var alAssumptionUnits = new Array();
	var alAssumptionValues = new Array();
	var alAssumptions = new Array();
	var alChartDescriptions = new Array();
	var alChartPaths = new Array();
	var alCoordsEnvelope = new Array();
	var alCoordsUnits = new Array();
	var alDefaultValue = new Array();
	var alDimensions = new Array();
	var alExplorable = new Array();
	var alIndicatorDecimals = new Array();
	var alIndicatorDescriptions = new Array();
	var alIndicatorUnits = new Array();
	var alIndicatorValues = new Array();
	var alLayers = new Array();
	var alLayerDesc = new Array();
	var alLegendPaths = new Array();
	var alReportAssumptions = new Array();
	var alReportCharts = new Array();
	var alReportIndicators = new Array();
	var alReportPaths = new Array();
	var alReports = new Array();
	var alScaleBarEnvelope = new Array();
	var alScenarioDescriptions = new Array();
	var alScenarios = new Array();
	var alSlideShow = new Array();
	var alValues = new Array();
	var anAssumptionValue;
	var aChartPath;
	var anIndicatorValue;
	var aWebShot;
	var bExplorable = false;
	var bSlideShow = false;
	var i = 0;
	var j = 0;
	var k = 0;
	var z = 0;
	var sAssumption = "";
	var sDefaultValue = "";
	var sItemName = "";
	var sScenario = "";
	var sScenarioDescription = "";
	var sValue = "";
	var sAssumptions = _oDataHash.Get("WebShotAssumptions");
	if (sAssumptions != "") {
		alAssumptions = sAssumptions.parse();
	} else {
		alAssumptions.push("DUMMY_ASSUMPTION");
	}
	alDimensions = _oDataHash.Get("Map Image Size").parse();
	alExplorable = _oDataHash.Get("ExplorableWebShots").parse();
	alScenarios = _oDataHash.Get("WebShotScenarios").parse();
	alScenarioDescriptions = _oDataHash.Get("WebShotScenarioDescriptions").parse();
	alSlideShow = _oDataHash.Get("SlideShow").parse();
	alCoordsEnvelope = _oDataHash.Get("WebShots CoordsEnvelope").parse();
	alScaleBarEnvelope = _oDataHash.Get("WebShots ScaleBarEnvelope").parse();
	alCoordsUnits = _oDataHash.Get("WebShots CoordsUnits").parse();
	_oWebShotSet.CoordTop = alCoordsEnvelope[0];	
	_oWebShotSet.CoordRight = alCoordsEnvelope[1];
	_oWebShotSet.CoordBottom = alCoordsEnvelope[2];
	_oWebShotSet.CoordLeft = alCoordsEnvelope[3];
	_oWebShotSet.ScaleTop = alScaleBarEnvelope[0];
	_oWebShotSet.ScaleRight = alScaleBarEnvelope[1];
	_oWebShotSet.ScaleBottom = alScaleBarEnvelope[2];
	_oWebShotSet.ScaleLeft = alScaleBarEnvelope[3];
	_oWebShotSet.CoordsUnits = alCoordsUnits[0];
	_oWebShotSet.BaseMapHeight = alDimensions[0];
	_oWebShotSet.BaseMapWidth = alDimensions[1];
	bAssumptionsPresent = true;
	bChartsPresent = true
	bIndicatorsPresent = true;
	if ((alSlideShow.length <=0) && (alExplorable.length <=0)) {
		alAssumptions = new Array();
		alAssumptions.push("DUMMY_ASSUMPTION");
	}
	for (i=0;i<alAssumptions.length;i++) {
		sAssumption = alAssumptions[i];
		if (sAssumption != "DUMMY_ASSUMPTION") {
			alValues = _oDataHash.Get(sAssumption).parse();
		} else {
			alValues = new Array();
			alValues.push("DUMMY_VALUE");
		}
		for (j=0;j<alScenarios.length;j++) {
			sScenario = alScenarios[j];
			sScenarioDescription = alScenarioDescriptions[j];
			_oWebShotSet.AddScenario(sScenario, sScenarioDescription);
			for (k=0;k<alValues.length;k++) {
				sValue = alValues[k];
				sItemName = sScenario + sAssumption + sValue;
				bExplorable = (( sAssumption == "DUMMY_ASSUMPTION" ) && 
					( sValue == "DUMMY_VALUE" )) ? true : alExplorable.contains(sItemName);
				bSlideShow = alSlideShow.contains(sItemName);
				if (bExplorable || bSlideShow) {
					// create a WebShot
					aWebShot = new WebShot();
					aWebShot.ItemName = sItemName;
					aWebShot.Assumption = sAssumption;
					aWebShot.Scenario = sScenario;
					aWebShot.Value = sValue;
					aWebShot.Explorable = bExplorable;
					aWebShot.SlideShow = bSlideShow;
					// identify whether this WebShot is a default value
					sDefaultValue = _oDataHash.Get(aWebShot.GetDefaultName());
					if (sDefaultValue != "") {
						alDefaultValue = sDefaultValue.parse();
						sDefaultValue = alDefaultValue[0];
					}
					if (sDefaultValue == sValue) {
						aWebShot.IsDefault = true;
					} else {
						aWebShot.IsDefault = false;
					}
					// add webshot stats
					alAssumptionStats = _oDataHash.Get(aWebShot.GetAssumptionStatsName()).parse();
					_oWebShotSet.AddAssumption(sAssumption, alAssumptionStats[0], 
						alAssumptionStats[1], alAssumptionStats[2], alAssumptionStats[3], alAssumptionStats[4], alAssumptionStats[5]);
					// add reported assumptions
					alReportAssumptions = _oDataHash.Get("Assumption Names").parse();
					if (alReportAssumptions.length > 0) {
						alAssumptionDescriptions = _oDataHash.Get("Assumption Descriptions").parse();
						alAssumptionUnits = _oDataHash.Get("Assumption Units").parse();
						alAssumptionValues = _oDataHash.Get(aWebShot.GetAssumptionValuesName()).parse();
						alAssumptionDecimals = _oDataHash.Get("Assumption Decimals").parse();
						for (z=0;z<alReportAssumptions.length;z++) {
							anAssumptionValue = new AssumptionValue();
							anAssumptionValue.Name = alReportAssumptions[z];
							anAssumptionValue.Description = alAssumptionDescriptions[z];
							anAssumptionValue.Units = alAssumptionUnits[z];
							anAssumptionValue.Value = alAssumptionValues[z];
							anAssumptionValue.Decimals = alAssumptionDecimals[z];
							aWebShot.AddAssumption(anAssumptionValue);
						}
					} else {
						bAssumptionsPresent = false;
					}
					// add reported charts
					alReportCharts = _oDataHash.Get("Chart Names").parse();
					if (alReportCharts.length > 0) {
						alChartDescriptions = _oDataHash.Get("Chart Descriptions").parse();
						alChartPaths = _oDataHash.Get(aWebShot.GetChartPathsName()).parse();
						for (z=0;z<alReportCharts.length;z++) {
							aChartPath = new ChartPath();
							aChartPath.Name = alReportCharts[z];
							aChartPath.Description = alChartDescriptions[z];
							aChartPath.Path = alChartPaths[z];
							aWebShot.AddChart(aChartPath);
						}
					} else {
						bChartsPresent = false;
					}
					// add reported indicators
					alReportIndicators = _oDataHash.Get("Indicator Names").parse();
					if (alReportIndicators.length > 0) {
						alIndicatorDescriptions = _oDataHash.Get("Indicator Descriptions").parse();
						alIndicatorUnits = _oDataHash.Get("Indicator Units").parse();
						alIndicatorValues = _oDataHash.Get(aWebShot.GetIndicatorValuesName()).parse();
						alIndicatorDecimals = _oDataHash.Get("Indicator Decimals").parse();
						for (z=0;z<alReportIndicators.length;z++) {
							anIndicatorValue = new IndicatorValue();
							anIndicatorValue.Name = alReportIndicators[z];
							anIndicatorValue.Description = alIndicatorDescriptions[z];
							anIndicatorValue.Units = alIndicatorUnits[z];
							anIndicatorValue.Value = alIndicatorValues[z];
							anIndicatorValue.Decimals = alIndicatorDecimals[z];
							aWebShot.AddIndicator(anIndicatorValue);
						}
					} else {
						bIndicatorsPresent = false;
					}
					// add associated map image
					alMapImagePaths = _oDataHash.Get(aWebShot.GetMapName()).parse();
					aWebShot.MapImagePath = alMapImagePaths[k];
					_oWebShotSet.Add(aWebShot);
					if (aWebShot.Explorable) {
						_oWebShotSet.AddExplorable(sAssumption, sScenario, sValue, aWebShot.IsDefault);
					}
				}
			}
		}
	}

	// add slide show
	for (i=0;i<alSlideShow.length;i++) {
		_oWebShotSet.AddSlide(alSlideShow[i]);
	}
	
	// manage webshot navigation based upon available slide show and explorable elements
	var NavFrame = (bNS) ? self.top.document.getElementById("WebShots_leftnav").contentDocument.getElementById("WebShots_navigationpane").contentDocument.getElementById("WebShots_navigation").contentDocument : 
		self.WebShots_leftnav.WebShots_navigationpane.WebShots_navigation.document;
	if ((_oWebShotSet.Explorable.length <= 0) && (_oWebShotSet.SlideShow.length > 0)) {
		var tblExplorable = NavFrame.getElementById("Nav_EXPLORE");
		var tblOr = NavFrame.getElementById("Nav_OR");
		tblExplorable.style.display = "none";
		tblOr.style.display = "none";
		// shift legend pane up
		var theFrameset = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument.getElementById("WebShots_leftnav") :
			self.WebShots_leftnav.document.getElementById("WebShots_leftnav");
		theFrameset.rows = "385px,100%,0px";
	}
	if (_oWebShotSet.SlideShow.length <= 0) {
		var tblSlideShow = NavFrame.getElementById("Nav_SLIDESHOW");
		var tblOr = NavFrame.getElementById("Nav_OR");
		tblSlideShow.style.display = "none";
		tblOr.style.display = "none";
	}
	if ((_oWebShotSet.SlideShow.length <= 0) && (_oWebShotSet.Explorable[0].ContainsAssumption("DUMMY_ASSUMPTION"))) {
		NavFrame.getElementById("ShowAssumptions1").style.display = "none";
		NavFrame.getElementById("ShowAssumptions2").style.display = "none";
		NavFrame.getElementById("ShowAssumptions3").style.display = "none";
		NavFrame.getElementById("ShowValues1").style.display = "none";
		NavFrame.getElementById("ShowValues2").style.display = "none";
		NavFrame.getElementById("ShowValues3").style.display = "none";				
		var theFrameset = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument.getElementById("WebShots_leftnav") :
			self.WebShots_leftnav.document.getElementById("WebShots_leftnav");
		theFrameset.rows = "205px,100%,0px";
	}

	// add legends
	_oWebShotSet.LegendPath = _oDataHash.Get("Legend");
	alLayers = _oDataHash.Get("SubLegends_Layers").parse();
	alLayerDesc = _oDataHash.Get("SubLegends_Descriptions").parse();
	alLegendPaths = _oDataHash.Get("SubLegends_FileNames").parse();
	for (i=0;i<alLayers.length;i++) {
		_oWebShotSet.AddLegend(alLayers[i],alLayerDesc[i],alLegendPaths[i]);
	}

	// add links to reports
	alReports = _oDataHash.Get("Report Names").parse();
	alReportPaths = _oDataHash.Get("Report Paths").parse();
	for (i=0;i<alReports.length;i++) {
		_oWebShotSet.AddReport(alReports[i],alReportPaths[i]);
	}

	//page needs to be loaded for this...
	//interval_CheckLoad = window.setInterval("CheckLoad()",20);
	ShowLegend();
	InitializeContent();
}


// --------------------- //
// Manage User Interface //
// --------------------- //
var _sCurrentScenario = "";
var _sCurrentAssumption = "";
var _sCurrentValue = "";

function InitializeContent() {

	// remove data panes if data types not present
	if (!bAssumptionsPresent || !bChartsPresent || !bIndicatorsPresent) {
		AdjustDataPanes();
	}

	// set slide to first slide
	if (_oWebShotSet.SlideShow.length > 0) {
		var aWebShot = _oWebShotSet.FirstSlide();
	}

	// initialize control buttons
	InitializeControlButtons();

	// initialize Scenario Content
	var alScenarios = new Array();
	var i = 0;
	var sChecked = "";
	var theOption;
	var theScenarioDiv;
	var theScenarioDesc = "";
	var contentframe = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument : null;
	var NavFrame = (bNS) ? contentframe.getElementById("WebShots_navigationpane").contentDocument.getElementById("WebShots_navigation").contentDocument : 
		self.WebShots_leftnav.WebShots_navigationpane.WebShots_navigation.document;
	var theNavPane = (bNS) ? "self.top.document.getElementById('WebShots_leftnav').contentDocument.getElementById('WebShots_navigationpane').contentDocument.getElementById('WebShots_navigation')" :
		"self.top.WebShots_leftnav.WebShots_navigationpane.document.getElementById('WebShots_navigation')";
	var sHTML = "<table align=\"left\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\" width=\"100%\" class=\"Explore3\">\n";
	for (i=0;i<_oWebShotSet.Explorable.length;i++) {
		alScenarios.push(_oWebShotSet.Explorable[i].Scenario);
	}
	alScenarios = alScenarios.sort();
	for (i=0;i<_oWebShotSet.Explorable.length;i++) {
		theScenarioDesc = _oWebShotSet.GetScenario(alScenarios[i]).Description;
		sChecked = (i==0) ? " checked" : "";
		sHTML += "<tr id=\"row_SelectScenario" + i + "\">\n";
		if (theScenarioDesc != "") {
			sHTML += "<td style=\"cursor:pointer\" onclick=\"document.getElementById('SelectScenario" + i + "').click()\" " +
					  "onmousemove=\"self.top.ShowTooltip(event,document.getElementById('Tip_" + alScenarios[i] + 
					  "')," + theNavPane + ")\" " + 
					  "onmouseout=\"self.top.HideTooltip()\">\n";
		} else {
			sHTML += "<td style=\"cursor:pointer\" onclick=\"document.getElementById('SelectScenario" + i + 
					  "').click()\">\n";
		}		  
		sHTML += "<input type=\"checkbox\" id=\"SelectScenario" + i + "\" " + 
				  "onclick='self.top.SelectItem(\"SelectScenario\",\"" + i + "\")' " + 
				  "name=\"SelectScenario\" value=\"" + alScenarios[i] + "\" " + sChecked + ">" + alScenarios[i] + "\n";
		sHTML += "</td>\n";
		sHTML += "</tr>\n";
	}
	sHTML += "</table>\n";
	for (i=0;i<_oWebShotSet.Explorable.length;i++) {
		theScenarioDesc = _oWebShotSet.GetScenario(alScenarios[i]).Description;
		if (theScenarioDesc != "") {
			sHTML += "<div id=\"Tip_" + alScenarios[i] + "\" name=\"Tip_" + alScenarios[i] + "\" class=\"popup\">";
			sHTML += theScenarioDesc;
			sHTML += "</div>\n";
		}
	}	
	sHTML += "<input type=\"hidden\" name=\"SelectScenarioValue\" id=\"SelectScenarioValue\" value=\"" + 
			  alScenarios[0] + "\">\n";
	theScenarioDiv = NavFrame.getElementById("DIV_SelectScenario");
	theScenarioDiv.innerHTML = sHTML;
	if ((_oWebShotSet.Explorable.length <= 0) && (_oWebShotSet.SlideShow.length > 0)) {
		NavFrame.getElementById("NavType1").checked = true;
		SelectNavType('Slide Show');
		
	} else {
		SelectItem("SelectScenario","0");
	}
}

function AdjustDataPanes() {
	var ResultsPane = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument : 
		self.WebShots_content.WebShots_resultspane.document;
	var ContentFrame = ResultsPane.getElementById("WebShots_contentpane");
	var RemoveFrame;
	var alRows = new Array();
	var alShowRows = new Array();
	var i = 0;
	var iCount = 5;
	var iRemoved = 0;
	var sRows = "";
	var sStartValue = "33%";
	alRows = ContentFrame.rows.split(",");
	for (i=0;i<5;i++) {
		alShowRows[i] = true;
	}
	if (!bChartsPresent) {
		alShowRows[1] = false;
		iCount -= 1;
		iRemoved += 1;
		RemoveFrame = ResultsPane.getElementById("WebShots_chartspane");
		RemoveFrame.style.display = "none";
		//sChartsPane = "";
	}
	if (!bIndicatorsPresent) {
		alShowRows[2] = false;
		iCount -= 1;
		iRemoved += 1;
		RemoveFrame = ResultsPane.getElementById("WebShots_indicatorspane");
		RemoveFrame.style.display = "none";
		//sIndicatorsPane = "";
	}
	if (!bAssumptionsPresent) {
		alShowRows[3] = false;
		iCount -= 1;
		iRemoved += 1;
		RemoveFrame = ResultsPane.getElementById("WebShots_assumptionspane");
		RemoveFrame.style.display = "none";
		//sAssumptionsPane = "";
	}
	if (iRemoved == 1) {
		sStartValue = "50%";
	} else if (iRemove = 2) {
		sStartValue = "100%";
	} else if (iRemove = 3) {
		sStartValue = "0px";
	}
	for (i=0;i<alShowRows.length;i++) {
		if (alShowRows[i] == true) {
			if (bChartsPresent || bIndicatorsPresent || bAssumptionsPresent) {
				sRows += ((i==0) || (i==(alShowRows.length-1))) ? "0px" : sStartValue;
			} else {
				sRows += (i==0) ? "100%" : "0px";
			}
			if (i < alShowRows.length) {
				sRows += ",";
			}
		} else {
			sRows += "0px,";
		}
	}
	ContentFrame.rows = sRows;
	if (!bAssumptionsPresent && !bChartsPresent && !bIndicatorsPresent) {
		bDataPanePresent = false;
		var ContentFrame = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_contentpane") : 
			self.WebShots_content.document.getElementById("WebShots_contentpane");
		ContentFrame.cols = "1px,100%";
	}

}

function InitializeControlButtons() {
	var bReportsPresent = (_oWebShotSet.Reports.length > 0) ? true : false;
	var btnReports = document.getElementById("btnOpenReports");
	var btnToggleData = document.getElementById("btnToggleData");
	var btnHelp = document.getElementById("btnWebShotsHelp");
	var colButtons = document.getElementById("col_titlebuttons");
	if (bDataPanePresent && !bReportsPresent){
		btnReports.style.display = "none";
		if (bNS) {
			btnToggleData.style.margin = "2px 0px";
			colButtons.style.width = 81 + "px";
		} else {
			btnToggleData.style.margin = "2px 0px 2px 7px";
			colButtons.style.width = 73 + "px";
		}
	} else if (!bDataPanePresent && bReportsPresent) {
		btnToggleData.style.display = "none";
		if (bNS) {
			btnReports.style.margin = "2px 0px";
			colButtons.style.width = 81 + "px";
		} else {
			btnReports.style.margin = "2px 0px 2px 7px";
			colButtons.style.width = 73 + "px";
		}
	} else if (!bDataPanePresent && !bReportsPresent) {
		btnReports.style.display = "none";
		btnToggleData.style.display = "none";
		if (bNS) {
			colButtons.style.width = 48 + "px";
		} else {
			colButtons.style.width = 41 + "px";
		}
	} else {
		if (bNS) {
			btnReports.style.margin = "2px 0px 2px 5px";
			btnHelp.style.margin = "2px 0px 2px 0px";
			colButtons.style.width = "114px";
			document.getElementById("ButtonCell").style.borderLeftColor = "ButtonHighlight";
			document.getElementById("ButtonCell").style.padding = "0px";
		} else {
			btnReports.style.margin = "2px 5px 2px 7px";
		}
	}
	
}

function UpdateScenario() {
	var alAssumptions = new Array();
	var i = 0;
	var sChecked = ""
	var sHTML = "";
	var theAssumptionDiv;
	var theAssumptionDesc = "";
	var contentframe = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument : null;
	var NavFrame = (bNS) ? contentframe.getElementById("WebShots_navigationpane").contentDocument.getElementById("WebShots_navigation").contentDocument : 
		self.WebShots_leftnav.WebShots_navigationpane.WebShots_navigation.document;
	var theNavPane = (bNS) ? "self.top.document.getElementById('WebShots_leftnav').contentDocument.getElementById('WebShots_navigationpane').contentDocument.getElementById('WebShots_navigation')" :
		"self.top.WebShots_leftnav.WebShots_navigationpane.document.getElementById('WebShots_navigation')";
	var theControl_Scenario = NavFrame.getElementById("SelectScenarioValue");
	var sScenario = theControl_Scenario.value;
	_sCurrentScenario = sScenario;
	var theControl_Assumption = NavFrame.getElementById("SelectAssumptionValue");
	var sAssumpiton = (theControl_Assumption == null) ? "" : theControl_Assumption.value;
	theOption = _oWebShotSet.GetExplorable(sScenario);
	if (theOption.Assumptions.length > 0) {
		for (i=0;i<theOption.Assumptions.length;i++) {
			alAssumptions.push(theOption.Assumptions[i].Assumption);
		}
		alAssumptions = alAssumptions.sort();
		sHTML += "<table align=\"left\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\" width=\"100%\" class=\"Explore3\">\n";
		for (i=0;i<theOption.Assumptions.length;i++) {
			theAssumptionDesc = _oWebShotSet.GetStats(alAssumptions[i]).Description;
			sChecked = (i==0) ? " checked" : "";
			sHTML += "<tr id=\"row_SelectAssumption" + i + "\">\n";
			if (theAssumptionDesc != "") {
				sHTML += "<td style=\"cursor:pointer\" onclick=\"document.getElementById('SelectAssumption" + i + 
						  "').click()\" " +
						  "onmousemove=\"self.top.ShowTooltip(event,document.getElementById('Tip_" + alAssumptions[i] + 
						  "')," + theNavPane + ")\" " + 
						  "onmouseout=\"self.top.HideTooltip()\">\n";
			} else {
				sHTML += "<td style=\"cursor:pointer\" onclick=\"document.getElementById('SelectAssumption" + i + 
						  "').click()\">\n";
			}
			sHTML += "<input type=\"checkbox\" id=\"SelectAssumption" + i + "\" " + 
					  "onclick='self.top.SelectItem(\"SelectAssumption\",\"" + i + "\")' " + 
					  "name=\"SelectAssumption\" value=\"" + alAssumptions[i] + "\" " + sChecked + ">"+ 
					  alAssumptions[i] + "\n";
			sHTML += "</td>\n";
			sHTML += "</tr>\n";
		}
		sHTML += "</table>\n";
		for (i=0;i<theOption.Assumptions.length;i++) {
			theAssumptionDesc = _oWebShotSet.GetStats(alAssumptions[i]).Description;
			if (theAssumptionDesc != "") {
				sHTML += "<div id=\"Tip_" + alAssumptions[i] + "\" name=\"Tip_" + alAssumptions[i] + 
						  "\" class=\"popup\">";
				sHTML += theAssumptionDesc;
				sHTML += "</div>\n";
			}
		}	
		sHTML += "<input type=\"hidden\" name=\"SelectAssumptionValue\" id=\"SelectAssumptionValue\" value=\"" + 
				  alAssumptions[0] + "\">\n";
	} else {
		sHTML += "<input type=\"hidden\" name=\SelectAssumptionValue\" id=\"SelectAssumptionValue\" value=\"\">\n";
	}
	theAssumptionDiv = NavFrame.getElementById("DIV_SelectAssumption");
	theAssumptionDiv.innerHTML = sHTML;
	UpdateAssumption();
}

function UpdateAssumption() {
	var alValues = new Array();
	var i = 0;
	var sHTML = "";
	var contentframe = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument : null;
	var NavFrame = (bNS) ? contentframe.getElementById("WebShots_navigationpane").contentDocument.getElementById("WebShots_navigation").contentDocument : 
		self.top.WebShots_leftnav.WebShots_navigationpane.WebShots_navigation.document;
	var theControl_Scenario = NavFrame.getElementById("SelectScenarioValue");
	var sScenario = theControl_Scenario.value;
	_sCurrentScenario = sScenario;
	var theControl_Assumption = NavFrame.getElementById("SelectAssumptionValue");
	var sAssumption = theControl_Assumption.value;
	_sCurrentAssumption = sAssumption;
	var theAssumptionLabel = NavFrame.getElementById("AssumptionName");
	theAssumptionLabel.innerHTML = sAssumption;
	alValues = _oWebShotSet.GetExplorable(sScenario).GetAssumptionValue(sAssumption).Values;
	var sDefaultValue = _oWebShotSet.GetExplorable(sScenario).GetAssumptionValue(sAssumption).Default;
	var sDefault = "";
	if (alValues.length > 0) {
		//alValues = alValues.sort();
		sHTML += "<table align=\"left\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\" width=\"100%\" class=\"Explore3\">\n";
		for (i=0;i<alValues.length;i++) {
			sDefault = (sDefaultValue == alValues[i]) ? " (default)" : "";
			sChecked = (i==0) ? " checked" : "";
			sHTML += "<tr id=\"row_SelectValue" + i + "\">\n";
			sHTML += "<td style=\"cursor:pointer\" onclick=\"document.getElementById('SelectValue" + i + "').click()\">\n";
			sHTML += "<input type=\"checkbox\" id=\"SelectValue" + i + "\" " + 
					  "onclick='self.top.SelectItem(\"SelectValue\",\"" + i + "\")' " + 
					  "name=\"SelectValue\" value=\"" + alValues[i] + "\" " + sChecked + ">" +alValues[i] + " " +
					  _oWebShotSet.GetStats(sAssumption).Units + sDefault + "\n";
			sHTML += "</td>\n";
			sHTML += "</tr>\n";
		}
		sHTML += "</table>\n";
		sHTML += "<input type=\"hidden\" name=\"SelectValueValue\" id=\"SelectValueValue\" value=\"" + 
				  alValues[0] + "\">\n";
	} else {
		sHTML += "<input type=\"hidden\" name=\"SelectValueValue\" id=\"SelectValueValue\" value=\"\">\n";
	}
	theValueDiv = NavFrame.getElementById("DIV_SelectValue");
	theValueDiv.innerHTML = sHTML;
	UpdateValue();
}

function UpdateValue() {
	var contentframe = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument : null;
	var NavFrame = (bNS) ? contentframe.getElementById("WebShots_navigationpane").contentDocument.getElementById("WebShots_navigation").contentDocument : 
		self.top.WebShots_leftnav.WebShots_navigationpane.WebShots_navigation.document;
	var theControl_Scenario = NavFrame.getElementById("SelectScenarioValue");
	var sScenario = theControl_Scenario.value;
	_sCurrentScenario = sScenario;
	var theControl_Assumption = NavFrame.getElementById("SelectAssumptionValue");
	var sAssumption = theControl_Assumption.value;
	_sCurrentAssumption = sAssumption;
	var theControl_Value = NavFrame.getElementById("SelectValueValue");
	var sValue = (theControl_Value==null) ? "" : theControl_Value.value;
	_sCurrentValue = sValue;
	_oWebShotSet.CurrentWebShot = _oWebShotSet.Get(sAssumption,sScenario,sValue);
	ShowData();
}


// ------------------------- //
// Element/Frame Positioning //
// ------------------------- //
var bCheckSelect = true;

function GetElemLeft(theElem) {
	if (!theElem && this) {                                            
		theElem = this;                         
	}                                            
	var iPos = theElem.offsetLeft;          
	var theParentElem = theElem.offsetParent;     
	while (theParentElem != null) {                                            
		iPos += theParentElem.offsetLeft;      
		theParentElem = theParentElem.offsetParent;  
	}
	return iPos;                             
}

function GetElemTop(theElem) {
	if (!theElem && this) {
		theElem = this;
	}
	var iPos = theElem.offsetTop;
	var theParentElem = theElem.offsetParent;
	while (theParentElem != null) {
		iPos += theParentElem.offsetTop;
		theParentElem = theParentElem.offsetParent;
	}
	return iPos;
}

/*
These functions can be called in one of two ways:

element.getTrueX = GetElemLeft;
element.getTrueY = GetElemTop;
var iTrueX = element.getTrueX();
var iTrueY = element.getTrueY();

or:

var iTrueX = GetElemLeft(element);
var iTrueY = GetElemTop(element);
*/


// processed at intervals
var _bDISPLAY = false;
function ResizeMap() {

	var navpane;
	var navframe;
	var contentpane;
	var contentframe;
	var headerbottom;
	var iElementWidth = 0;
	var iWindowWidth = 0;
	var iWindowHeight = 0;
	var iContentTop = 0;
	var iHeaderHeight = 0;
	
	// get elements
	headerbottom = document.getElementById("HeaderBottom");
	navframe = document.getElementById("WebShots_leftnav");
	navpane = document.getElementById("NavPane"); 
	contentframe = document.getElementById("WebShots_content");
	contentpane = document.getElementById("ContentPane");
	
	// assign dimensioning methods to elements
	headerbottom.getTrueY = GetElemTop;
	navpane.getTrueX = GetElemLeft;
	navpane.getTrueY = GetElemTop;
	contentpane.getTrueX = GetElemLeft;
	contentpane.getTrueY = GetElemTop;
	
	// get current size of the window
	iWindowWidth = (bNS) ? innerWidth : document.body.offsetWidth;
	iWindowHeight = (bNS) ? innerHeight : document.body.offsetHeight;
	
	// prevent shrinking the window below it's limits
	if ((iWindowWidth < 400) || (iWindowHeight < 300)) {
		_bDISPLAY = false;
		document.getElementById("WebShotsPage").style.display = "none";
		navpane.style.display = "none";
		contentpane.style.display = "none";
		var theMessage = document.getElementById("BrowserTooSmall");
		theMessage.style.display = "block";
		/*
		var iMessageTop = parseInt(parseInt(iWindowHeight/2) - 100);
		var iMessageLeft = parseInt(parseInt(iWindowWidth/2) - 100);
		iMessageTop = (iMessageTop > 0) ? iMessageTop : 0;
		iMessageLeft = (iMessageLeft > 0) ? iMessageLeft : 0;
		theMessage.style.display = "block";
		theMessage.style.top = iMessageTop + "px";
		theMessage.style.left = iMessageLeft + "px";
		*/
		return false;
	} else {
		_bDISPLAY = true;
		document.getElementById("BrowserTooSmall").style.display = "none";
		document.getElementById("WebShotsPage").style.display = "block";
	}

	// get height of main page header
	iHeaderHeight = (bNS) ? parseInt(headerbottom.getTrueY() - 2) : parseInt(headerbottom.getTrueY() - 5);
	
	// set top of nav pane to bottom of header
	navpane.style.top = (bNS) ? parseInt(iHeaderHeight + 1) + "px" : parseInt(iHeaderHeight - 2) + "px";
	navpane.style.display = "block";

	// get repositioned integer top position of nav pane
	iContentTop = (bNS) ? parseInt(navpane.getTrueY() - 3) : parseInt(navpane.getTrueY());
	
	// set top of content pane to the same position as that of the nav pane
	contentpane.style.top = iContentTop + "px";
	contentpane.style.display = "block"
	
	// get width of the nav pane
	iElementWidth = (bNS) ? navframe.width : navpane.offsetWidth;
		
	// assign dimensions to the content pane and nav pane
	contentpane.style.width = (bNS) ? parseInt(iWindowWidth - iElementWidth - 35) + "px" : 
		parseInt(iWindowWidth - iElementWidth - 30) + "px";
	contentframe.style.width = (bNS) ? parseInt(iWindowWidth - iElementWidth - 40) + "px" : 
		parseInt(iWindowWidth - iElementWidth - 35) + "px";
	contentpane.style.height = parseInt(iWindowHeight - iContentTop - 4) + "px";
	contentframe.style.height = parseInt(iWindowHeight - iContentTop - 9) + "px";
	navpane.style.height = (bNS) ? parseInt(iWindowHeight - iContentTop - 10) + "px" : 
		parseInt(iWindowHeight - iContentTop - 6) + "px";
	navframe.style.height = (bNS) ? parseInt(iWindowHeight - iContentTop - 15) + "px" : 
		parseInt(iWindowHeight - iContentTop - 11) + "px";
		
	// adjust pane borders
	if (!bNS) {
		navframe.style.borderColor = "ButtonFace";
		navframe.style.borderWidth = "3 0 0 0";
		navframe.style.borderStyle = "solid none none none";
	} else {
		navframe.style.borderColor = "ButtonFace";
		navpane.style.borderColor = "ButtonFace";
		navpane.style.borderWidth = "3 0 0 0";
		navpane.style.borderStyle = "solid none none none";
		contentframe.style.borderColor = "ThreeDFace";
		var navborder = document.getElementById("NavBorder");
		navborder.style.top = parseInt(iHeaderHeight - 2) + "px";
		navborder.style.left = 5 + "px";
		navborder.style.width = 353 + "px";
		navborder.style.display = "block";
	}
	
	// position content pane to the right of the nav pane
	RepositionNavLayers();
	ZoomTo(CurrentZoom.id);

	// resize the header description
	if (bNS) {
		var theDescription = document.getElementById("WebShotsDescription");
		if (document.getElementById("col_description").offsetWidth > 15) {
			theDescription.style.width = parseInt(document.getElementById("col_description").offsetWidth - 25) + "px";
		}
		theDescription.style.top = "-13px";
		theDescription.style.left = "-2px";
		theDescription.style.height = "43px";
	}

}

function RepositionNavLayers() {
	if (bToResposNavLayers) {

		bToResposNavLayers = false;
		
		// reposition nav buttons
		var contentframe = (bNS) ? document.getElementById("WebShots_content").contentDocument : null;
		var navbuttons = document.getElementById("NavLayer");
		var iResultsWidth = (bNS) ? contentframe.getElementById("WebShots_resultspane").contentDocument.body.offsetWidth :
			self.WebShots_content.WebShots_resultspane.document.body.offsetWidth;
		iResultsWidth = (_bDataPaneOpen) ? iResultsWidth : 0;
		var iNavWidth = (bNS) ? parseInt((0.5 * navbuttons.offsetWidth ) + 6) : 0;
		navbuttons.style.top = (bNS) ? 2 + "px" : 5 + "px";
		navbuttons.style.left = (bNS) ? parseInt(iResultsWidth + iNavWidth - 31) + "px" : 
			parseInt(iResultsWidth + iNavWidth + 7) + "px";
		if (bNS) {
			var btnZoom2Center = document.getElementById("PanToCenter")
			btnZoom2Center.style.padding = "5px 3px 3px 3px";
			navbuttons.style.height = "247px";
		} else {
			navbuttons.style.height = "205px";
		}

		// reposition scale bar
		var iContentHeight = 0;
		var iWindowHeight = 0;
		var iContentTop = 0;
		var navpane = document.getElementById("NavPane"); 
		navpane.getTrueY = GetElemTop;
		iContentTop = parseInt(navpane.getTrueY());
		iWindowHeight = (bNS) ? innerHeight : document.body.offsetHeight;
		iContentHeight = parseInt(iWindowHeight - iContentTop - 10);
		var scalebar = document.getElementById("ScaleBar");
		scalebar.style.top = parseInt(iContentHeight - 43) + "px";
		scalebar.style.left = (bNS) ? parseInt(iResultsWidth + iNavWidth - 20) + "px" : 
			parseInt(iResultsWidth + iNavWidth + 14) + "px";

	}
}
				

// ------------------------------- //
// Response to Navigation Controls //
// ------------------------------- //

function SelectItem($list,$ID) {
	if (bCheckSelect) {
		var NavFrame = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument.getElementById("WebShots_navigationpane").contentDocument.getElementById("WebShots_navigation").contentDocument : 
			self.top.WebShots_leftnav.WebShots_navigationpane.WebShots_navigation.document;
		var theCheckList = NavFrame.getElementsByName($list);
		var theCheckName = $list.concat($ID);
		var theCheckBox = NavFrame.getElementById(theCheckName);
		var thePrefix = "row_";
		var theRowName = thePrefix.concat(theCheckName);
		var theRow = NavFrame.getElementById(theRowName);
		var theHiddenName = $list.concat("Value");
		var theHiddenControl = NavFrame.getElementById(theHiddenName);

		if (theCheckBox.checked) {

			// unselect other checkboxes
			bCheckSelect = false;
			for(i=0;i<(theCheckList.length);i++) {
				if(theCheckList[i].id != theCheckName) {
					theCheckList[i].checked = false;
					NavFrame.getElementById(thePrefix.concat(theCheckList[i].id)).style.background="transparent";
				}
			}
			bCheckSelect = true;

			// when checkbox is checked(TRUE) change background to blue
			theRow.style.background="skyblue";

			// reset the hidden value
			theHiddenControl.value = theCheckBox.value;

			switch ($list) {
				case "SelectScenario":
					UpdateScenario();
					SelectItem("SelectAssumption","0");
					break;
				case "SelectAssumption":
					UpdateAssumption();
					SelectItem("SelectValue","0");
					break;
				case "SelectValue":
					UpdateValue();
					break;
			}

		} else {
			bCheckSelect = false;
			theCheckBox.checked = true;
			bCheckSelect = true;
		}
	}
}

var bAllowClick = true;
function SelectReport(theDoc,theCheckName) {
	var theCheckBox = theDoc.getElementById(theCheckName);
	if (bAllowClick) {
		var thePrefix = "row_";
		var theRowName = thePrefix.concat(theCheckName);
		var theRow = theDoc.getElementById(theRowName);
		if (theCheckBox.checked == true) {
			theRow.style.background = "skyblue";
		} else {
			theRow.style.background = "transparent";
		}
	} else {
		theCheckBox.checked = !theCheckBox.checked;
	}
	bAllowClick = false;
	setTimeout("bAllowClick = true",50);
}

function SelectNavType(theNavType) {
	var NavFrame = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument.getElementById("WebShots_navigationpane").contentDocument.getElementById("WebShots_navigation").contentDocument : 
		self.top.WebShots_leftnav.WebShots_navigationpane.WebShots_navigation.document;
	var theExploreControl = NavFrame.getElementById("ExploreControl");
	var theCurrentSlide = NavFrame.getElementById("CurrentSlide");
	if (theNavType == "Slide Show") {
		theExploreControl.style.display = "none";
		theCurrentSlide.style.display = "block";
		LaunchSlideShow();
	} else {
		theExploreControl.style.display = "block";
		theCurrentSlide.style.display = "none";
		UpdateValue();
	}
}

function LaunchSlideShow() {
	var aWebShot = _oWebShotSet.CurrentWebShot;
	ShowSlideNavButtons();
	if (aWebShot!=null) {
		ShowSlide();
	}
}

function NavSlideShow(theDirection) {
	var aWebShot = (theDirection == "Next") ? _oWebShotSet.NextSlide() : _oWebShotSet.PrevSlide();
	var NavFrame = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument.getElementById("WebShots_navigationpane").contentDocument.getElementById("WebShots_navigation").contentDocument : 
		self.top.WebShots_leftnav.WebShots_navigationpane.WebShots_navigation.document;
	var txtSlideNum = NavFrame.getElementById("SlideNum");
	txtSlideNum.value = _oWebShotSet.GetSlideNumber();
	ShowSlideNavButtons();	
	if (aWebShot!=null) {
		ShowSlide();
	}
}

function GotoSlide(theValue) {
	var aWebShot = null;
	if (!isNaN(theValue)) {
		aWebShot = _oWebShotSet.GotoSlide(theValue);
	}
	var NavFrame = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument.getElementById("WebShots_navigationpane").contentDocument.getElementById("WebShots_navigation").contentDocument : 
		self.top.WebShots_leftnav.WebShots_navigationpane.WebShots_navigation.document;
	var txtSlideNum = NavFrame.getElementById("SlideNum");
	txtSlideNum.value = _oWebShotSet.GetSlideNumber();
	if (!isNaN(theValue)) {
		ShowSlideNavButtons();
		if (aWebShot!=null) {
			ShowSlide();
		}
	}
}

function GotoFirstSlide() {
	GotoSlide(1);
}

function GotoLastSlide() {
	var iLastSlide = _oWebShotSet.SlideShow.length;
	GotoSlide(iLastSlide);
}

function ShowSlideNavButtons() {
	var NavFrame = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument.getElementById("WebShots_navigationpane").contentDocument.getElementById("WebShots_navigation").contentDocument : 
		self.top.WebShots_leftnav.WebShots_navigationpane.WebShots_navigation.document;
	var txtCurrentSlide = NavFrame.getElementById("SlideNum");
	txtCurrentSlide.value = _oWebShotSet.GetSlideNumber();
	var btnFirstSlide = NavFrame.getElementById("btnFirstSlide");
	var btnLastSlide = NavFrame.getElementById("btnLastSlide");
	var btnNextSlide = NavFrame.getElementById("btnNextSlide");
	var btnPreviousSlide = NavFrame.getElementById("btnPreviousSlide");
	var imgFirstSlide = NavFrame.getElementById("imgFirstSlide");
	var imgLastSlide = NavFrame.getElementById("imgLastSlide");
	var imgNextSlide = NavFrame.getElementById("imgNextSlide");
	var imgPreviousSlide = NavFrame.getElementById("imgPreviousSlide");
	if (_oWebShotSet.SlidePosition >= _oWebShotSet.SlideShow.length - 1) {
		btnNextSlide.disabled = true;
		btnLastSlide.disabled = true;
		imgNextSlide.src = theWebShotsFolder.concat("Images/").concat("SlideNext_disabled.png");
		imgLastSlide.src = theWebShotsFolder.concat("Images/").concat("SlideLast_disabled.png");
		
	} else {
		btnNextSlide.disabled = false;
		btnLastSlide.disabled = false;
		imgNextSlide.src = theWebShotsFolder.concat("Images/").concat("SlideNext.png");
		imgLastSlide.src = theWebShotsFolder.concat("Images/").concat("SlideLast.png");
	}
	if (_oWebShotSet.SlidePosition <= 0) {
		btnFirstSlide.disabled = true;
		btnPreviousSlide.disabled = true;
		imgFirstSlide.src = theWebShotsFolder.concat("Images/").concat("SlideFirst_disabled.png");
		imgPreviousSlide.src = theWebShotsFolder.concat("Images/").concat("SlideBack_disabled.png");
	} else {
		btnFirstSlide.disabled = false;
		btnPreviousSlide.disabled = false;
		imgFirstSlide.src = theWebShotsFolder.concat("Images/").concat("SlideFirst.png");
		imgPreviousSlide.src = theWebShotsFolder.concat("Images/").concat("SlideBack.png");
	}
}

function ShowSlide() {
	var NavFrame = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument.getElementById("WebShots_navigationpane").contentDocument.getElementById("WebShots_navigation").contentDocument : 
		self.top.WebShots_leftnav.WebShots_navigationpane.WebShots_navigation.document;
	var theNavPane = (bNS) ? "self.top.document.getElementById('WebShots_leftnav').contentDocument.getElementById('WebShots_navigationpane').contentDocument.getElementById('WebShots_navigation')" :
		"self.top.WebShots_leftnav.WebShots_navigationpane.document.getElementById('WebShots_navigation')";
	_sCurrentAssumption = _oWebShotSet.CurrentWebShot.Assumption;
	_sCurrentScenario = _oWebShotSet.CurrentWebShot.Scenario;
	_sCurrentValue = _oWebShotSet.CurrentWebShot.Value;
	var theScenarioDesc = _oWebShotSet.GetScenario(_sCurrentScenario).Description;
	var theAssumptionDesc = _oWebShotSet.GetStats(_sCurrentAssumption).Description;
	var sScenHTML = "";	
	var sDefault = (_oWebShotSet.CurrentWebShot.IsDefault == true) ? " (default)" : "";
	sScenHTML += "<table align=\"left\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\" width=\"100%\" class=\"Explore3\">\n";
	sScenHTML += "<tr>\n";
	if (theScenarioDesc != "") {
		sScenHTML += "<td class=\"SelectedRow\" onmousemove=\"self.top.ShowTooltip(event,document.getElementById('SlideTip_" + 
					  _sCurrentScenario + "')," + theNavPane + ")\" " + 
					  "onmouseout=\"self.top.HideTooltip()\">\n";
	} else {
		sScenHTML += "<td class=\"SelectedRow\">\n";
	}
	sScenHTML += _sCurrentScenario + "\n";
	sScenHTML += "</td>\n";
	sScenHTML += "</tr>\n";
	sScenHTML += "</table>\n";
	if (theScenarioDesc != "") {
		sScenHTML += "<div id=\"SlideTip_" + _sCurrentScenario + "\" name=\"SlideTip_" + _sCurrentScenario + 
					  "\" class=\"popup\">";
		sScenHTML += theScenarioDesc;
		sScenHTML += "</div>\n";
	}
	var sAsmptHTML = "";
	sAsmptHTML += "<table align=\"left\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\" width=\"100%\" class=\"Explore3\">\n";
	sAsmptHTML += "<tr>\n";
	if (theAssumptionDesc != "") {
		sAsmptHTML += "<td class=\"SelectedRow\" onmousemove=\"self.top.ShowTooltip(event,document.getElementById('SlideTip_" + 
						_sCurrentAssumption + "')," + theNavPane + ")\" " + 
						"onmouseout=\"self.top.HideTooltip()\">\n";
	} else {
		sAsmptHTML += "<td class=\"SelectedRow\">\n";
	}
	sAsmptHTML += _sCurrentAssumption + "\n";
	sAsmptHTML += "</td>\n";
	sAsmptHTML += "</tr>\n";
	sAsmptHTML += "</table>\n";
	if (theAssumptionDesc != "") {
		sAsmptHTML += "<div id=\"SlideTip_" + _sCurrentAssumption + "\" name=\"SlideTip_" + _sCurrentAssumption + 
					   "\" class=\"popup\">";
		sAsmptHTML += theAssumptionDesc;
		sAsmptHTML += "</div>\n";
	}
	NavFrame.getElementById("Slide_Assumption").innerHTML = sAsmptHTML;
	NavFrame.getElementById("Slide_Scenario").innerHTML = sScenHTML;
	NavFrame.getElementById("Slide_Value").innerHTML = _sCurrentValue + " " + 
		_oWebShotSet.GetStats(_sCurrentAssumption).Units + sDefault;
	ShowData();
}

function ShowData() {

	// check for complete IE website load
	if (!bNS && ((document.WebShots_content == null) || 
		(document.WebShots_content.WebShots_map == null) || 
		(document.WebShots_content.WebShots_map.document == null))) {
		alert("Error: Improper load of the website.\n\n" + 
			  "To correctly reload the website, reselect the address \n" + 
			  "in the address bar and hit the return key or right-\n" +
			  "click over the web page and select 'Refresh'...");
		return;
	}
	
	// check for complete NS website load
	if (bNS && ((document.getElementById("WebShots_content") == null) || 
		(document.getElementById("WebShots_content").contentDocument == null) || 
		(document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_map") == null) || 
		(document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_map").contentDocument == null))) {
		alert("Error: Improper load of the website.\n\n" + 
			  "To correctly reload the website, reselect the address \n" + 
			  "in the address bar and hit the return key or right-\n" +
			  "click over the web page and select 'Refresh'...");
		return;
	}

	// show map
	var theMapDoc = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_map").contentDocument : 
		document.WebShots_content.WebShots_map.document;	
	var theMapImage = theMapDoc.getElementById("MapImage");
	theMapImage.src = theWebShotsFolder.concat(_oWebShotSet.CurrentWebShot.MapImagePath);
	ZoomTo(CurrentZoom.id);

	// show charts
	if (bChartsPresent) {
		var ChartsFrame = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_chartspane").contentDocument.getElementById("WebShots_charts").contentDocument : 
			self.top.WebShots_content.WebShots_resultspane.WebShots_chartspane.WebShots_charts.document;
		var theChartsPane = (bNS) ? "self.top.document.getElementById('WebShots_content').contentDocument.getElementById('WebShots_resultspane').contentDocument.getElementById('WebShots_chartspane').contentDocument.getElementById('WebShots_charts')" :
			"self.top.WebShots_content.WebShots_resultspane.WebShots_chartspane.document.getElementById('WebShots_charts')";
		var theChartsContent = ChartsFrame.getElementById("ChartsContent");
		var alCharts = _oWebShotSet.CurrentWebShot.ReportCharts;
		var sChartHTML = "";
		var theChartName = "";
		var theChartPath = "";
		var theChartDesc = "";
		var theMinusPath = theWebShotsFolder.concat("Images\/Section_minus.gif");

		// store existing expanded/contracted charts
		var sSection = "Chart_Section_";
		var sSectionID = "";
		var alOpenCharts = new Array();
		var obj;
		if (_ChartCols == 1) {
			for (i=0;i<alCharts.length;i++) {
				sSectionID = sSection + alCharts[i].Name;
				obj = ChartsFrame.getElementById(sSectionID);
				if ((obj != null) && (obj.style.display == "block")) {
					alOpenCharts.push(obj.id);
				}
			}
		} else {
			for (i=0;i<alCharts.length;i++) {
				sSectionID = sSection + alCharts[i].Name + "2";
				obj = ChartsFrame.getElementById(sSectionID);
				if ((obj != null) && (obj.style.display == "block")) {
					alOpenCharts.push(obj.id);
				}
			}		
		}

		// SINGLE COLUMN CHARTS
		sChartHTML += "<table id=\"Charts_1Col\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"display:block\">\n";
		for (i=0;i<alCharts.length;i++) {
			theChartName = alCharts[i].Name;
			theChartPath = theWebShotsFolder.concat(alCharts[i].Path);
			theChartDesc = alCharts[i].Description;
			sChartHTML += "<tr>\n";
			sChartHTML += "<td class=\"ItemBar\">\n";
			if (theChartDesc != "") {
				sChartHTML += "<div class=\"ItemClick\" onclick=\"toggle('Chart_Section_" + theChartName + "')\" " +
								"onmousemove=\"self.top.ShowTooltip(event,document.getElementById('Tip_" + 
								theChartName + "')," + theChartsPane + ")\" " + 
								"onmouseout=\"self.top.HideTooltip()\">";
			} else {
				sChartHTML += "<div class=\"ItemClick\" onclick=\"toggle('Chart_Section_" + theChartName + "')\">\n";
			}
			sChartHTML += "<img src=\"" + theMinusPath + "\" alt=\"click icon to open or close this chart\" " +
						  "id=\"Chart_IMG_" + theChartName + "\" align=\"left\" " +
							  "onMouseOver=\"self.top.status='click icon to open or close this chart'\" " +
							  "onMouseOut=\"self.top.status=''\"/><b>" + theChartName + "</b>\n"
			sChartHTML += "</div>\n";
			sChartHTML += "</td>\n";
			sChartHTML += "</tr>\n";
			sChartHTML += "<tr>\n";
			sChartHTML += "<td align=\"center\">\n";
			sChartHTML += "<div id=\"Chart_Section_" + theChartName + "\" name=\"Chart_Section_" + theChartName + "\" " +
						  "style=\"display:block\">\n";
			sChartHTML += "<img src=\"" + theChartPath + "\" alt=\"" + theChartDesc + "\" align=\"absmiddle\" " +
						  "width=\"100%\" id=\"CHARTIMG_" + theChartName + "\" />\n"
			sChartHTML += "</div>\n";
			sChartHTML += "</td>\n";
			sChartHTML += "</tr>\n";
		}
		sChartHTML += "</table>\n";

		// DOUBLE COLUMN CHARTS
		var theSide = "left";
		sChartHTML += "<table id=\"Charts_2Col\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"display:none\">\n";
		var sChartLEFT = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin:0px 2px 0px 0px;padding:0px\">\n";
		var sChartRIGHT = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin:0px 0px 0px 2px;padding:0px\">\n";
		var sChartTEMP = ""
		for (i=0;i<alCharts.length;i++) {
			theChartName = alCharts[i].Name;
			theChartPath = theWebShotsFolder.concat(alCharts[i].Path);
			theChartDesc = alCharts[i].Description;
			sChartTEMP = "<tr>\n";
			sChartTEMP += "<td class=\"ItemBar\">\n";
			if (theChartDesc != "") {
				sChartTEMP += "<div class=\"ItemClick\" onclick=\"toggle('Chart_Section_" + theChartName + "2')\" " +
								"onmousemove=\"self.top.ShowTooltip(event,document.getElementById('Tip_" + 
								theChartName + "')," + theChartsPane + ")\" " + 
								"onmouseout=\"self.top.HideTooltip()\">";
			} else {
				sChartTEMP += "<div class=\"ItemClick\" onclick=\"toggle('Chart_Section_" + theChartName + "2')\">\n";
			}
			sChartTEMP += "<img src=\"" + theMinusPath + "\" alt=\"click icon to open or close this chart\" " +
						  "id=\"Chart_IMG_" + theChartName + "2\" align=\"left\" " +
							  "onMouseOver=\"self.top.status='click icon to open or close this chart'\" " +
							  "onMouseOut=\"self.top.status=''\"/><b>" + theChartName + "</b>\n"
			sChartTEMP += "</div>\n";
			sChartTEMP += "</td>\n";
			sChartTEMP += "</tr>\n";
			sChartTEMP += "<tr>\n";
			sChartTEMP += "<td align=\"center\">\n";
			sChartTEMP += "<div id=\"Chart_Section_" + theChartName + "2\" name=\"Chart_Section_" + theChartName + 
						  "2\" " + "style=\"display:block\">\n";
			sChartTEMP += "<img src=\"" + theChartPath + "\" alt=\"" + theChartDesc + "\" align=\"absmiddle\" " +
						  "width=\"100%\" id=\"CHARTIMG2_" + theChartName + "2\" />\n"
			sChartTEMP += "</div>\n";
			sChartTEMP += "</td>\n";
			sChartTEMP += "</tr>\n";
			if (theSide == "left") {
				sChartLEFT += sChartTEMP;
				theSide = "right";
			} else {
				sChartRIGHT += sChartTEMP;
				theSide = "left";
			}
		}
		sChartHTML += "<tr>\n";
		sChartHTML += "<td valign=\"top\">\n";
		sChartHTML += sChartLEFT;
		sChartHTML += "</table>\n";
		sChartHTML += "</td>\n";
		sChartHTML += "<td valign=\"top\">\n";
		sChartHTML += sChartRIGHT;
		sChartHTML += "</table>\n";
		sChartHTML += "</td>\n";
		sChartHTML += "</tr>\n";	
		sChartHTML += "</table>\n";

		for (i=0;i<alCharts.length;i++) {
			theChartName = alCharts[i].Name;
			theChartDesc = alCharts[i].Description;
			if (theChartDesc != "") {
				sChartHTML += "<div id=\"Tip_" + theChartName + "\" name=\"Tip_" + theChartName + "\" class=\"popup\">";
				sChartHTML += theChartDesc;
				sChartHTML += "</div>\n";
			}
		}
		theChartsContent.innerHTML = sChartHTML;
		ResizeCharts();

		if (alOpenCharts.length > 0) {
			var sIMG = "Chart_IMG_";
			var sIMGID = "";
			var obj, img, re;
			if (_ChartCols == 1) {
				for (var i=0;i<alCharts.length;i++) {
					sSectionID = sSection + alCharts[i].Name;
					sIMGID = sIMG + alCharts[i].Name;
					obj = ChartsFrame.getElementById(sSectionID);
					img = ChartsFrame.getElementById(sIMGID);
					if (alOpenCharts.contains(sSectionID)) {
						obj.style.display = "block";
						var re = /plus.gif/;
						img.src = img.src.replace(re, "minus.gif");
					} else {
						obj.style.display = "none";
						var re = /minus.gif/;
						img.src = img.src.replace(re, "plus.gif");
					}
				}		
			} else {
				for (var i=0;i<alCharts.length;i++) {
					sSectionID = sSection + alCharts[i].Name + "2";
					sIMGID = sIMG + alCharts[i].Name + "2";
					obj = ChartsFrame.getElementById(sSectionID);
					img = ChartsFrame.getElementById(sIMGID);
					if (alOpenCharts.contains(sSectionID)) {
						obj.style.display = "block";
						var re = /plus.gif/;
						img.src = img.src.replace(re, "minus.gif");
					} else {
						obj.style.display = "none";
						var re = /minus.gif/;
						img.src = img.src.replace(re, "plus.gif");
					}
				}		
			}	
		}
	}

	// show indicators
	if (bIndicatorsPresent) {
		var IndicFrame = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_indicatorspane").contentDocument.getElementById("WebShots_indicators").contentDocument : 
			self.top.WebShots_content.WebShots_resultspane.WebShots_indicatorspane.WebShots_indicators.document;
		var theIndicContent = IndicFrame.getElementById("IndicatorsContent");
		var alIndicators = _oWebShotSet.CurrentWebShot.ReportIndicators;
		var sIndicHTML = "";
		var theIndicName = "";
		var theIndicValue = "";
		var theIndicUnits = "";
		var theIndicDesc = "";
		var theIndicDecimals = "";
		var alAlignSide = new Array(alIndicators.length);
		var thePlusPath = theWebShotsFolder.concat("Images\/Section_plus.gif");
		sIndicHTML += "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"ValueTable\">\n";
		sIndicHTML += "<col id=\"col_IndicatorName\">\n";
		sIndicHTML += "<col id=\"col_IndicatorValue\">\n";
		sIndicHTML += "<col id=\"col_indicatorUnits\">\n";
		sIndicHTML += "<tr>\n";
		sIndicHTML += "<td class=\"ValueTitle\">\n";
		sIndicHTML += "Name\n";
		sIndicHTML += "</td>\n";
		sIndicHTML += "<td class=\"ValueTitle\">\n";
		sIndicHTML += "Value\n";
		sIndicHTML += "</td>\n";
		sIndicHTML += "<td class=\"ValueTitle\">\n";
		sIndicHTML += "Units\n";
		sIndicHTML += "</td>\n";
		sIndicHTML += "</tr>\n";
		for (i=0;i<alIndicators.length;i++) {
			theIndicName = alIndicators[i].Name;
			theIndicValue = alIndicators[i].Value;
			theIndicValue = (theIndicValue.toUpperCase() == "FALSE") ? "No" : theIndicValue;
			theIndicValue = (theIndicValue.toUpperCase() == "TRUE") ? "Yes" : theIndicValue;
			theIndicUnits = alIndicators[i].Units;
			if (theIndicUnits == "undefined") {
				theIndicUnits = "";
			}
			theIndicDesc = alIndicators[i].Description;
			theIndicDecimals = alIndicators[i].Decimals;
			if (isNaN(theIndicValue)) {
				sAlignSide = "left";
			} else {
				sAlignSide = "right";
				dNumber = new Number(parseFloat(theIndicValue));
				theIndicValue = dNumber.toDecimalStr(parseInt(theIndicDecimals));
			}
			sIndicHTML += "<tr>\n";
			sIndicHTML += "<td class=\"ValueBar\">\n";
			if (theIndicDesc != "") {
				sIndicHTML += "<div class=\"ItemClick\" onclick=\"toggle('Indicator_Section_" + theIndicName + "')\">\n";
				sIndicHTML += "<img src=\"" + thePlusPath + "\" + alt=\"click icon to open or close the description\" " +
							  "id=\"Indicator_IMG_" + theIndicName + "\" align=\"left\" " +
							  "onMouseOver=\"self.top.status='click icon to open or close the description'\" " +
							  "onMouseOut=\"self.top.status=''\"/>\n";
			} else {
				sIndicHTML += "<div class=\"EmptyElementDesc\">\n";
			}
			sIndicHTML += theIndicName + "\n";
			sIndicHTML += "</div>\n";
			sIndicHTML += "</td>\n";
			sIndicHTML += "<td class=\"ValueBar\" style=\"text-align:" + sAlignSide + "\">\n";
			if (theIndicDesc != "") {
				sIndicHTML += "<div onclick=\"toggle('Indicator_Section_" + theIndicName + "')\">\n";
			} else {
				sIndicHTML += "<div>\n";
			}
			sIndicHTML += theIndicValue + "\n";
			sIndicHTML += "</div>\n";
			sIndicHTML += "</td>\n";
			sIndicHTML += "<td class=\"ValueBar\">\n";
			if (theIndicDesc != "") {
				sIndicHTML += "<div onclick=\"toggle('Indicator_Section_" + theIndicName + "')\">\n";
			} else {
				sIndicHTML += "<div>\n";
			}
			sIndicHTML += theIndicUnits + "\n";
			sIndicHTML += "</div>\n";
			sIndicHTML += "</td>\n";
			sIndicHTML += "</tr>\n";
			sIndicHTML += "<tr>\n";
			sIndicHTML += "<td colspan=\"3\" class=\"ValueDescription\">\n";
			if (theIndicDesc != "") {
				sIndicHTML += "<div id=\"Indicator_Section_" + theIndicName + "\" name=\"Indicator_Section_" + 
							  theIndicName + "\" style=\"display:none\">\n";
			} else {
				sIndicHTML += "<div>\n";
			}
			sIndicHTML += theIndicDesc + "\n";
			sIndicHTML += "</div>\n";
			sIndicHTML += "</td>\n";
			sIndicHTML += "</tr>\n";
		}
		sIndicHTML += "</table>\n";
		theIndicContent.innerHTML = sIndicHTML;
	}

	// show assumptions
	if (bAssumptionsPresent) {
		var AssmptFrame = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_assumptionspane").contentDocument.getElementById("WebShots_assumptions").contentDocument : 
			self.top.WebShots_content.WebShots_resultspane.WebShots_assumptionspane.WebShots_assumptions.document;
		var theAssmptContent = AssmptFrame.getElementById("AssumptionsContent");
		var alAssumptions = _oWebShotSet.CurrentWebShot.ReportAssumptions;
		var sAssmptHTML = "";
		var theAssmptName = "";
		var theAssmptValue = "";
		var theAssmptUnits = "";
		var theAssmptDesc = "";
		var theAssmptDecimals = "";
		alAlignSide = new Array(alAssumptions.length);
		thePlusPath = theWebShotsFolder.concat("Images\/Section_plus.gif");
		sAssmptHTML += "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"ValueTable\">\n";
		sAssmptHTML += "<col id=\"col_assumptionName\">\n";
		sAssmptHTML += "<col id=\"col_assumptionValue\">\n";
		sAssmptHTML += "<col id=\"col_assumptionUnits\">\n";
		sAssmptHTML += "<tr>\n";
		sAssmptHTML += "<td class=\"ValueTitle\">\n";
		sAssmptHTML += "Name\n";
		sAssmptHTML += "</td>\n";
		sAssmptHTML += "<td class=\"ValueTitle\">\n";
		sAssmptHTML += "Value\n";
		sAssmptHTML += "</td>\n";
		sAssmptHTML += "<td class=\"ValueTitle\">\n";
		sAssmptHTML += "Units\n";
		sAssmptHTML += "</td>\n";
		sAssmptHTML += "</tr>\n";
		for (i=0;i<alAssumptions.length;i++) {
			theAssmptName = alAssumptions[i].Name;
			theAssmptValue = alAssumptions[i].Value;
			theAssmptValue = (theAssmptValue.toUpperCase() == "FALSE") ? "No" : theAssmptValue;
			theAssmptValue = (theAssmptValue.toUpperCase() == "TRUE") ? "Yes" : theAssmptValue;
			theAssmptUnits = alAssumptions[i].Units;
			if (theAssmptUnits == "undefined") {
				theAssmptUnits = "";
			}
			theAssmptDesc = alAssumptions[i].Description;
			theAssmptDecimals = alAssumptions[i].Decimals;
			if (isNaN(theAssmptValue)) {
				sAlignSide = "left";
			} else {
				sAlignSide = "right";
				dNumber = new Number(parseFloat(theAssmptValue));
				theAssmptValue = dNumber.toDecimalStr(parseInt(theAssmptDecimals));
			}
			sAssmptHTML += "<tr>\n";
			sAssmptHTML += "<td class=\"ValueBar\">\n";
			if (theAssmptDesc != "") {
				sAssmptHTML += "<div class=\"ItemClick\" onclick=\"toggle('Assumption_Section_" + theAssmptName + "')\">\n";
				sAssmptHTML += "<img src=\"" + thePlusPath + "\" + alt=\"click icon to open or close the description\" " +
							  "id=\"Assumption_IMG_" + theAssmptName + "\" align=\"left\" " +
							  "onMouseOver=\"self.top.status='click icon to open or close the description'\" " +
							  "onMouseOut=\"self.top.status=''\"/>\n";
			} else {
				sAssmptHTML += "<div class=\"EmptyElementDesc\">\n";
			}
			sAssmptHTML += theAssmptName + "\n";
			sAssmptHTML += "</div>\n";
			sAssmptHTML += "</td>\n";
			sAssmptHTML += "<td class=\"ValueBar\" style=\"text-align:" + sAlignSide + "\">\n";
			if (theAssmptDesc != "") {
				sAssmptHTML += "<div onclick=\"toggle('Assumption_Section_" + theAssmptName + "')\">\n";
			} else {
				sAssmptHTML += "<div>\n";
			}
			sAssmptHTML += theAssmptValue + "\n";
			sAssmptHTML += "</div>\n";
			sAssmptHTML += "</td>\n";
			sAssmptHTML += "<td class=\"ValueBar\">\n";
			if (theAssmptDesc != "") {
				sAssmptHTML += "<div onclick=\"toggle('Assumption_Section_" + theAssmptName + "')\">\n";
			} else {
				sAssmptHTML += "<div>\n";
			}
			sAssmptHTML += theAssmptUnits + "\n";
			sAssmptHTML += "</div>\n";
			sAssmptHTML += "</td>\n";
			sAssmptHTML += "</tr>\n";
			sAssmptHTML += "<tr>\n";
			sAssmptHTML += "<td colspan=\"3\" class=\"ValueDescription\">\n";
			if (theAssmptDesc != "") {
				sAssmptHTML += "<div id=\"Assumption_Section_" + theAssmptName + "\" name=\"Assumption_Section_" + 
							  theAssmptName + "\" style=\"display:none\">\n";
			} else {
				sAssmptHTML += "<div>\n";
			}
			sAssmptHTML += theAssmptDesc + "\n";
			sAssmptHTML += "</div>\n";
			sAssmptHTML += "</td>\n";
			sAssmptHTML += "</tr>\n";
		}
		sAssmptHTML += "</table>\n";
		theAssmptContent.innerHTML = sAssmptHTML;
	}
	
	// update WebShot description
	_oWebShotSet.GetDescription();
	
}

function ShowLegend() {
	var theLegendDoc = (bNS) ? document.getElementById("WebShots_leftnav").contentDocument.getElementById("WebShots_legendpane").contentDocument.getElementById("WebShots_legend").contentDocument :
		document.WebShots_leftnav.WebShots_legendpane.WebShots_legend.document;
	var theLegendContent = theLegendDoc.getElementById("LegendContent");
	var sLegendHTML = "";
	var theLegendName = "";
	var theLegendPath = "";
	var theLegendDesc = "";
	var theMinusPath = theWebShotsFolder.concat("Images\/Section_minus.gif");
	sLegendHTML += "<table width=\"100%\" border=\"0\" class=\"LegendBorder\" cellpadding=\"0\" cellspacing=\"0\">\n";
	var theLegendPane = (bNS) ? "self.top.document.getElementById('WebShots_leftnav').contentDocument.getElementById('WebShots_legendpane').contentDocument.getElementById('WebShots_legend')" :
		"self.top.WebShots_leftnav.WebShots_legendpane.document.getElementById('WebShots_legend')";
	for (i=0;i<_oWebShotSet.SubLegends.length;i++) {
		theLegendName = _oWebShotSet.SubLegends[i].Name;
		theLegendPath = theWebShotsFolder.concat(_oWebShotSet.SubLegends[i].LegendPath);
		theLegendDesc = _oWebShotSet.SubLegends[i].Description;
		sLegendHTML += "<tr>\n";
		sLegendHTML += "<td class=\"ItemBar\">\n";
		if (theLegendDesc != "") {
			sLegendHTML += "<div class=\"ItemClick\" onclick=\"toggle('Legend_Section_" + theLegendName + "')\" " +
							"onmousemove=\"self.top.ShowTooltip(event,document.getElementById('Tip_" + 
							theLegendName + "')," + theLegendPane + ")\" " + 
							"onmouseout=\"self.top.HideTooltip()\">";
		} else {
			sLegendHTML += "<div class=\"ItemClick\" onclick=\"toggle('Legend_Section_" + theLegendName + "')\">";
		}
		sLegendHTML += "<img src=\"" + theMinusPath + "\" alt=\"click icon to open or close this layer\" id=\"Legend_IMG_" + 
			theLegendName + "\" align=\"left\" onMouseOver=\"self.top.status='click icon to opn or close this layer'\" " +
			"onMouseOut=\"self.top.status=''\"/>\n";
		sLegendHTML += "<b>" + theLegendName + "</b>\n";
		sLegendHTML += "</div>\n";
		sLegendHTML += "</td>\n";
		sLegendHTML += "</tr>\n";
		sLegendHTML += "<tr>\n";
		sLegendHTML += "<td align=\"left\">\n";
		sLegendHTML += "<table border=\"0\" class=\"LegendItem\" cellpadding=\"0\" cellspacing=\"0\">\n";
		sLegendHTML += "<tr>\n";
		sLegendHTML += "<td>\n";
		sLegendHTML += "<div id=\"Legend_Section_" + theLegendName + "\" name=\"Legend_Section_" + theLegendName + 
			"\" style=\"display:block;padding:5px\">\n";
		sLegendHTML += "<img src=\"" + theLegendPath + "\" align=\"absmiddle\" alt=\"" + theLegendDesc + "\" name=\"" + 
			theLegendName + "\" + width=\"100%\" />\n";
		sLegendHTML += "</div>\n";
		sLegendHTML += "</td>\n";
		sLegendHTML += "</tr>\n";
		sLegendHTML += "</table>\n";
		sLegendHTML += "</td>\n";
		sLegendHTML += "</tr>\n";
	}
	sLegendHTML += "</table>\n";			
	for (i=0;i<_oWebShotSet.SubLegends.length;i++) {
		sLegendName = _oWebShotSet.SubLegends[i].Name
		sLegendDesc = _oWebShotSet.SubLegends[i].Description
		if (sLegendDesc != "") {
			sLegendHTML += "<div id=\"Tip_" + sLegendName + "\" name=\"Tip_" + sLegendName + "\" class=\"popup\">";
			sLegendHTML += sLegendDesc;
			sLegendHTML += "</div>\n";
		}
	}
	theLegendContent.innerHTML = sLegendHTML;	
}

function CalcMapSize() {
	if (_bDISPLAY) {
		var sUnits1 = "";
		var dWidth1 = 0;
		var dScale1 = 0;
		var sUnits2 = "";
		var dWidth2 = 0;
		var dScale2 = 0;
		var dFactor1 = 1;
		var dFactor2 = 1;
		var theMapWin = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_map") :
			document.WebShots_content.WebShots_map;
		var theMapDoc = (bNS) ? theMapWin.contentDocument : 
			theMapWin.document;	
		var theMapImage = theMapDoc.getElementById("MapImage");
		var leftnav = document.getElementById("WebShots_leftnav");
		var navpane = document.getElementById("NavPane");
		navpane.getTrueY = GetElemTop;	
		var iContentTop = parseInt(navpane.getTrueY());
		var iElementWidth = (bNS) ? leftnav.width : navpane.offsetWidth;
		var iWindowHeight = (bNS) ? innerHeight : document.body.offsetHeight;
		var iWindowWidth = (bNS) ? innerWidth : document.body.offsetWidth;
		var iResultsWidth = 0;
		if (_bDataPaneOpen) {
			if (bAssumptionsPresent) {
				var AssumptionsWin = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_assumptionspane").contentDocument.getElementById("WebShots_assumptions") : 
					self.top.WebShots_content.WebShots_resultspane.WebShots_chartspane.WebShots_charts;
				iResultsWidth = (bNS) ? AssumptionsWin.contentDocument.body.offsetWidth : AssumptionsWin.document.body.offsetWidth;
				iResultsWidth = parseInt(iResultsWidth + 30);
			}
			if ((bChartsPresent) && (iResultsWidth == 0)) {	
				var ChartsWin = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_chartspane").contentDocument.getElementById("WebShots_charts") : 
					self.top.WebShots_content.WebShots_resultspane.WebShots_chartspane.WebShots_charts;
				iResultsWidth = (bNS) ? ChartsWin.contentDocument.body.offsetWidth : ChartsWin.document.body.offsetWidth;
				iResultsWidth = parseInt(iResultsWidth + 30);
			}
			if ((bIndicatorsPresent) && (iResultsWidth == 0)) {
				var IndicatorsWin = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_Indicatorspane").contentDocument.getElementById("WebShots_indicators") : 
					self.top.WebShots_content.WebShots_resultspane.WebShots_chartspane.WebShots_charts;
				iResultsWidth = (bNS) ? IndicatorsWin.contentDocument.body.offsetWidth : IndicatorsWin.document.body.offsetWidth;	
				iResultsWidth = parseInt(iResultsWidth + 30);
			}
		}
		var iFrameHeight = parseInt(iWindowHeight - iContentTop - 15);
		var iFrameWidth = parseInt(iWindowWidth - iElementWidth - iResultsWidth - 35);

		// calculate starting center coordinate
		var iStartCenterX = _ScrollX + parseInt(0.5 * iFrameWidth);
		var iStartCenterY = _ScrollY + parseInt(0.5 * iFrameHeight);
		var dLocX = parseFloat(_oWebShotSet.CoordLeft) + parseFloat(_dPixelWidth * iStartCenterX);
		var dLocY = parseFloat(_oWebShotSet.CoordTop) - parseFloat(_dPixelHeight * iStartCenterY);

		// calculate new map image height/width
		var iMapWidth = parseInt(_oWebShotSet.BaseMapWidth * _dZoomFactor);
		var iMapHeight = parseInt(_oWebShotSet.BaseMapHeight * _dZoomFactor);

		// resize map image
		theMapImage.style.width = iMapWidth + "px";
		theMapImage.style.height = iMapHeight + "px";

		// pan image to keep center coordinate in center of map pane
		var dCoordWidth = _oWebShotSet.CoordRight - _oWebShotSet.CoordLeft;
		var dCoordHeight = _oWebShotSet.CoordTop - _oWebShotSet.CoordBottom;
		_dPixelWidth = parseFloat(dCoordWidth / iMapWidth);
		_dPixelHeight = parseFloat(dCoordHeight / iMapHeight);
		var iEndCenterX = parseInt((dLocX - _oWebShotSet.CoordLeft) / _dPixelWidth);
		var iEndCenterY = parseInt((_oWebShotSet.CoordTop - dLocY) / _dPixelHeight);
		_ScrollX = iEndCenterX - parseInt(0.5 * iFrameWidth);
		_ScrollY = iEndCenterY - parseInt(0.5 * iFrameHeight);

		if (!bNS) { 
			theMapWin.scroll(_ScrollX,_ScrollY);
		} else {
			_bScrollNOW = true;
		}

		// adjust scale bar
		var dWidth1 = parseFloat(iFrameWidth * _dPixelWidth); // based on frame width
		sUnits1 = "m";
		dScale1 = GetScaleWidth(dWidth1);
		if (parseInt(dScale1) > 999) {
			dFactor1 = 1/1000;
			dWidth1 = dWidth1 * dFactor1;
			sUnits1 = "km";
			dScale1 = Math.round(GetScaleWidth(dWidth1) + 0.5);
		}
		var sUnits2 = "ft";
		if (sUnits1 == "m") {
			dFactor2 = 3.2808399;
			dWidth2 = dWidth1 * dFactor2;
			dScale2 = GetScaleWidth(dWidth2);
		} else {
			dWidth2 = ((dWidth1/dFactor1) * dFactor2);
			dScale2 = GetScaleWidth(dWidth2);
		}
		if (parseInt(dScale2) > 1000) {
			sUnits2 = "mi";
			dFactor2 = (sUnits1 == "m") ? (0.621371192/1000) : 0.621371192;
			dWidth2 = parseFloat(dWidth1 * dFactor2);
			if (parseInt(dScale2) < 2640) {
				dScale2 = 0.25;
			} else if (parseInt(dScale2) < 5280) {
				dScale2 = 0.5;
			} else {
				dScale2 = Math.round(GetScaleWidth(dWidth2) + 0.5);
			}
		}
		_oWebShotSet.Scale1Pixels = parseInt(parseFloat(parseFloat(dScale1/dFactor1)/_dPixelWidth));
		_oWebShotSet.Scale2Pixels = parseInt(parseFloat(parseFloat(dScale2/dFactor2)/_dPixelWidth));
		_oWebShotSet.Scale1Units = sUnits1;
		_oWebShotSet.Scale2Units = sUnits2;

		var ScaleBar1 = document.getElementById("ScaleBar1");
		var ScaleBar1Text = document.getElementById("ScaleBar1Text");
		var ScaleBar2 = document.getElementById("ScaleBar2");
		var ScaleBar2Text = document.getElementById("ScaleBar2Text");

		ScaleBar1.style.width = _oWebShotSet.Scale1Pixels + "px";
		ScaleBar2.style.width = _oWebShotSet.Scale2Pixels + "px";

		ScaleBar1Text.innerHTML = dScale1 + " " + _oWebShotSet.Scale1Units;
		ScaleBar2Text.innerHTML = dScale2 + " " + _oWebShotSet.Scale2Units;

		if (bNS) {
			ScaleBar1.style.top = "-3px";
			ScaleBar2.style.top = "-4px";
		}
	}
}

function GetScaleWidth(dWidth) {
	var iDigits = 0;
	var dTestVal = dWidth;
	var dBaseNum = 1;
	var dFactor = 0;
	var dScale = 0;
	while (dTestVal >= 1) {
		iDigits += 1;
		dBaseNum = Math.pow(10,iDigits);
		dTestVal = parseFloat(dWidth / dBaseNum);
	}
	dFactor = parseFloat(parseInt((dTestVal + 0.01) * 10));
	if (dFactor == 0) {
		dFactor = dWidth;
	} else {
		dFactor = parseFloat((dFactor * dBaseNum) / 10)
	}
	dScale = parseFloat(dFactor / 5);
	return dScale;
}


// ---- //
// Zoom //
// ---- //

var CurrentZoom;
var _dZoomFactor = 1;

function ZoomOut(theZoomID) {
	var theZoom = document.getElementById(theZoomID);
	if (theZoomID == CurrentZoom.id) {
		theZoom.src="Images/zoom_highlight.gif";
	} else {
		theZoom.src = theZoom.name;
	}
}

function ZoomTo(theZoomID) {
	var theMapWin = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_map") : 
		document.WebShots_content.WebShots_map;	
	var theZoom = document.getElementById(theZoomID);
	CurrentZoom.src = CurrentZoom.name;
	CurrentZoom = theZoom;
	CurrentZoom.src = "Images/zoom_highlight.gif";
	CalcZoomFactor();
	CalcMapSize();
	
	//alert(theMapWin.offsetTop + "\n" + theMapWin.offsetLeft);
}

function ZoomStepIn() {
	var iZoomNum = parseInt(CurrentZoom.id.substr(4,1));
	if (iZoomNum > 1) {
		ZoomTo("Zoom" + parseInt(iZoomNum - 1))
	}
}

function ZoomStepOut() {
	var iZoomNum = parseInt(CurrentZoom.id.substr(4,1));
	if (iZoomNum < 7) {
		ZoomTo("Zoom" + parseInt(iZoomNum + 1));
	}
}

function CalcZoomFactor() {
	var theMapDoc = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_map").contentDocument : 
		document.WebShots_content.WebShots_map.document;		
	var leftnav = document.getElementById("WebShots_leftnav");
	var navpane = document.getElementById("NavPane"); 
	var iElementWidth = (bNS) ? leftnav.width : navpane.offsetWidth;	
	var iWindowWidth = (bNS) ? innerWidth : document.body.offsetWidth;
	var iResultsWidth = 0;
	if (_bDataPaneOpen) {
		if (bAssumptionsPresent) {
			var AssumptionsWin = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_assumptionspane").contentDocument.getElementById("WebShots_assumptions") : 
				self.top.WebShots_content.WebShots_resultspane.WebShots_chartspane.WebShots_charts;
			iResultsWidth = (bNS) ? AssumptionsWin.contentDocument.body.offsetWidth : AssumptionsWin.document.body.offsetWidth;
			iResultsWidth = parseInt(iResultsWidth + 30);
		}
		if ((bChartsPresent) && (iResultsWidth == 0)) {	
			var ChartsWin = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_chartspane").contentDocument.getElementById("WebShots_charts") : 
				self.top.WebShots_content.WebShots_resultspane.WebShots_chartspane.WebShots_charts;
			iResultsWidth = (bNS) ? ChartsWin.contentDocument.body.offsetWidth : ChartsWin.document.body.offsetWidth;
			iResultsWidth = parseInt(iResultsWidth + 30);
		}
		if ((bIndicatorsPresent) && (iResultsWidth == 0)) {
			var IndicatorsWin = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_Indicatorspane").contentDocument.getElementById("WebShots_indicators") : 
				self.top.WebShots_content.WebShots_resultspane.WebShots_chartspane.WebShots_charts;
			iResultsWidth = (bNS) ? IndicatorsWin.contentDocument.body.offsetWidth : IndicatorsWin.document.body.offsetWidth;	
			iResultsWidth = parseInt(iResultsWidth + 30);
		}
	}
	var iFrameWidth = parseInt(iWindowWidth - iElementWidth - iResultsWidth - 35);
	var dTempFactor = parseFloat(iFrameWidth / _oWebShotSet.BaseMapWidth);
	switch (CurrentZoom.id) {
		case "Zoom1":
			_dZoomFactor = 3
			break;
		case "Zoom2":
			if (dTempFactor >= 1) {
				_dZoomFactor = parseFloat(1 + (5 * parseFloat(1/3)));
			} else {
				_dZoomFactor = parseFloat(1 + (2 * parseFloat(2/3)));
			}
			break;
		case "Zoom3":
			if (dTempFactor >= 1) {
				_dZoomFactor = parseFloat(1 + (4 * parseFloat(1/3)));
			} else {
				_dZoomFactor = parseFloat(1 + parseFloat(2/3));
			}
			break;
		case "Zoom4":
			if (dTempFactor >= 1) {
				_dZoomFactor = parseFloat(1 + (3 * parseFloat(1/3)));
			} else {
				_dZoomFactor = 1;			
			}
			break;
		case "Zoom5":
			if (dTempFactor >= 1) {
				_dZoomFactor = parseFloat(1 + (2 * parseFloat(1/3)));
			} else {
				_dZoomFactor = parseFloat(dTempFactor + (2 * parseFloat((1 - dTempFactor)/3)))
			}
			break;
		case "Zoom6":
			if (dTempFactor >= 1) {
				_dZoomFactor = parseFloat(1 + parseFloat(1/3));
			} else {
				_dZoomFactor = parseFloat(dTempFactor + parseFloat((1 - dTempFactor)/3));			
			}
			break;
		case "Zoom7":
			if (dTempFactor >= 1) {
				_dZoomFactor = 1;
			} else {
				_dZoomFactor = dTempFactor;
			}
			break;			
	}
}

// ------------ //
// Open Reports //
// ------------ //

function OpenReportList() {
	var theParams = "directories=no,fullscreen=no,height=215,width=350,location=no,menubar=no,scrollbars=no,resizable=no,status=no,titlebar=yes,toolbar=no";
	var theLeft = parseInt(screen.width / 2) - 200;
	var theTop = parseInt(screen.height / 2) - 200;
	theOutParams = theParams + ",left=" + theLeft + ",top=" + theTop;
	window.open('Resources/WebShots_reports.htm','_blank',theOutParams)
}

function OpenReports (theWin, theDoc) {
	var alReports = theDoc.getElementsByName("SelReport");
	var i = 0;
	var theOutParams = ""
	var theParams = "fullscreen=no,height=400,width=400,scrollbars=yes,menubar=no,location=no,toolbar=no"
	var theLeft = 100;
	var theTop = 100;
	for (i=0;i<alReports.length;i++) {
		if (alReports[i].checked) {
			theLeft += 30;
			theTop += 30;
			theOutParams = theParams + ",left=" + theLeft + ",top=" + theTop;
			window.open(alReports[i].value,"_blank", theOutParams);
		}
	}
	theWin.close();
}


// ------------- //
// Resize charts //
// ------------- //
var _ChartCols = 1;
function ResizeCharts() {
	var alCharts = new Array();
	alCharts = _oDataHash.Get("Chart Names").parse();
	if ((alCharts.length > 0) && _bDISPLAY) {
		var ChartsWin = (bNS) ? document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_chartspane").contentDocument.getElementById("WebShots_charts") : 
			self.top.WebShots_content.WebShots_resultspane.WebShots_chartspane.WebShots_charts;
		var iFrameWidth = (bNS) ? ChartsWin.contentDocument.body.offsetWidth : ChartsWin.document.body.offsetWidth;
		var theDoc = (bNS) ? ChartsWin.contentDocument : ChartsWin.document;
		if (_ChartCols == 1) {
			theDoc.getElementById("Charts_1Col").style.display = "block";
			theDoc.getElementById("Charts_2Col").style.display = "none";					
		} else {
			theDoc.getElementById("Charts_1Col").style.display = "none";
			theDoc.getElementById("Charts_2Col").style.display = "block";					
		}
		var imgname = "";
		var testname = "";	
		var iNewWidth = (_ChartCols == 1) ? parseInt(iFrameWidth - 55) : parseInt(parseInt(iFrameWidth - 60) / 2);
		for (i=0;i<theDoc.images.length;i++) {
			theImage = theDoc.images[i];
			var re = (_ChartCols == 1) ? /CHARTIMG_/ : /CHARTIMG2_/;
			if (bNS) {
				imgname = theImage.name;
			} else {
				imgname = theImage.id;
			}
			var testname = imgname.replace(re,"");
			if (imgname.length != testname.length) {
				if (iFrameWidth > 55) {
					theImage.width = iNewWidth;
				}
			}
		}
		var alCharts = _oWebShotSet.CurrentWebShot.ReportCharts;
		var sSection = "Chart_Section_";
		var sIMG = "Chart_IMG_";
		var sSectionID = "";
		var sIMGID = "";
		var alOpenCharts = new Array();
		var obj1, img1, obj2, img2, re;
		if ((iNewWidth < 247) && (_ChartCols == 2)) {
			_ChartCols = 1;
			for (i=0;i<alCharts.length;i++) {
				sSectionID = sSection + alCharts[i].Name;
				sIMGID = sIMG + alCharts[i].Name;
				obj2 = theDoc.getElementById(sSectionID + "2");
				obj1 = theDoc.getElementById(sSectionID);
				img1 = theDoc.getElementById(sIMGID)
				if (obj2.style.display == "block") {
					obj1.style.display = "block";
					re = /plus.gif/;
					img1.src = img1.src.replace(re, "minus.gif");
				} else {
					obj1.style.display = "none";
					re = /minus.gif/;
					img1.src = img1.src.replace(re, "plus.gif");
				}
			}		
		} else if ((iNewWidth >=500) && (_ChartCols == 1)) {
			_ChartCols = 2;
			for (i=0;i<alCharts.length;i++) {
				sSectionID = sSection + alCharts[i].Name;
				sIMGID = sIMG + alCharts[i].Name;
				obj1 = theDoc.getElementById(sSectionID);
				obj2 = theDoc.getElementById(sSectionID + "2");
				img2 = theDoc.getElementById(sIMGID + "2")
				if (obj1.style.display == "block") {
					obj2.style.display = "block";
					re = /plus.gif/;
					img2.src = img2.src.replace(re, "minus.gif");
				} else {
					obj2.style.display = "none";
					re = /minus.gif/;
					img2.src = img2.src.replace(re, "plus.gif");
				}
			}		
		}	
	}
}

// ---------------- //
// Toggle data pane //
// ---------------- //
var _bDataPaneOpen = true;
function ToggleData(theIMG) {
	var iFrame = -1;
	var iPos = 0;
	iFrame = 1;
	var ContentPane = (bNS) ? document.getElementById("WebShots_content") : 
		self.WebShots_content;
	var theFrameset = (bNS) ? ContentPane.contentDocument.getElementById("WebShots_contentpane") :
		ContentPane.document.getElementById("WebShots_contentpane");
	var alCols = theFrameset.cols.split(",");
	if (alCols[0] != "0px") { // minimize content
		alCols[0] = "0px";
		alCols[1] = "100%";
		theIMG.src = theWebShotsFolder.concat("Images\/").concat("Data_Open.png");
		theIMG.alt = "Click here to open data pane."
		_bDataPaneOpen = false;
	} else {						// maximize content
		alCols[0] = "30%";
		alCols[1] = "70%";
		theIMG.src = theWebShotsFolder.concat("Images\/").concat("Data_Close.png");
		theIMG.alt = "Click here to close data pane."
		_bDataPaneOpen = true;
	}
	var sCols = "";
	sCols = alCols[0] + "," + alCols[1];
	theFrameset.cols = sCols;
	if (!bNS) {
		RepositionNavLayers();
	}
	ZoomTo(CurrentZoom.id);
}

// ---------------- //
// Open Help window //
// ---------------- //
var HelpWindow = null;
function OpenHelp(theTopic) {
	var theURL = theWebShotsFolder.concat("Resources/").concat("WebShots_Help.htm#") + theTopic;
	if ((HelpWindow == null) || (HelpWindow.closed)) {
		var theURL = theWebShotsFolder.concat("Resources/").concat("WebShots_Help.htm#") + theTopic;
		var theParams = "directories=no,fullscreen=no,height=575,width=397,location=no,menubar=no,scrollbars=yes,resizable=yes,status=no,titlebar=yes,toolbar=no";
		var theLeft = parseInt(screen.width / 2) - 200;
		var theTop = parseInt(screen.height / 2) - 300;
		theOutParams = theParams + ",left=" + theLeft + ",top=" + theTop;
		HelpWindow = window.open(theURL,'_blank',theOutParams);
	} else {
		HelpWindow.location.href = theURL;
		HelpWindow.focus();
	}
}

// ------------------------ //
// Restore WebShots Summary //
// ------------------------ //
function RestoreSummary() {
	var sAnalysisDesc = "";
	var theDescription = document.getElementById("WebShotsDescription");
	var theAnalysisDesc = document.getElementById("AnalysisSummary");
	if ((document.getElementById("WebShotsSummary").innerHTML != "") && (theAnalysisDesc.innerHTML != "")) {
		sAnalysisDesc = "\n<br>\n"
	}
	if (theAnalysisDesc.innerHTML != "") {
		sAnalysisDesc += theAnalysisDesc.innerHTML;
	}
	theDescription.innerHTML = document.getElementById("WebShotsSummary").innerHTML + sAnalysisDesc;
}

// -------- //
// ToolTips //
// -------- //
var _sDescription = "";
var _iScrPos = 0;
var _sSpacer = "  . . . . . . . . ";
var _bScrollMsg = false;
var _sStatus = "";
var iSpeed = (bNS) ? 2100 : 525;
function ShowTooltip(event, tip, pane) {
	if (!bNS) {
		x = event.clientX
		y = event.clientY
		var Popup = document.getElementById("WebShotsPopup");
		Popup.innerHTML = tip.innerHTML;
		Popup.style.display = "block";
		pane.getTrueX = GetElemLeft;
		pane.getTrueY = GetElemTop;
		x += pane.getTrueX();
		y += pane.getTrueY();
		Popup.style.top = y + 20 + "px";
		Popup.style.left = x + 15 + "px";
	} else {
		var re_space = /&nbsp;/
		_sDescription = tip.innerHTML.replace(re_space," ");
		//self.top.status = tip.innerHTML.replace(re_space," ");
		if (_sDescription.length > 70) {
			_bScrollMsg = true;
			self.top.setTimeout("ScrollMessage()", iSpeed);
		} else if ((_sDescription.length <= 70) && (_sDescription != "")) {
			self.top.status = _sDescription;
		}
	}
}

function ScrollMessage() {
	if (_bScrollMsg) {
		_sStatus = _sDescription.substring(_iScrPos, _sDescription.length) + _sSpacer + 
			_sDescription.substring(0,_iScrPos);
		self.top.status = _sStatus
		_iScrPos++;
		if (_iScrPos > _sDescription.length) _iScrPos = 0;
		// empty space size is much smaller than most characters
		if (_sStatus.substring(0, 1) == " ") {
			iSpeed = (bNS) ? 1800 : 193;
		// the larger the character disappearing, the faster movement seems
		} else {
			iSpeed = (bNS) ? 4200 : 450;
		}
		self.top.setTimeout("ScrollMessage()", iSpeed);		
	}
}

function HideTooltip() {
	_bScrollMsg = false;
	self.top.status = "";
	var Popup = document.getElementById("WebShotsPopup");
	Popup.style.display = "none";
}

function GetNSPaneX(pane) {
	var theParent;
	var X = pane.offsetLeft;
	switch (pane.contentDocument.title) {
		case "WebShots Map Legend":
			theParent = self.top.document.getElementById('WebShots_leftnav').contentDocument.getElementById('WebShots_legendpane');			
			X += GetNSPaneX(theParent);
			break;
		case "WebShots Map Legend Pane", "WebShots Navigation":
			theParent = self.top.document.getElementById('WebShots_leftnav');
			X += GetNSPaneX(theParent);
			break;
		case "WebShots Charts":
			theParent = document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_chartspane");
			X += GetNSPaneX(theParent);
			break;
		case "Charts Pane":
		    theParent = document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane");
			X += GetNSPaneX(theParent);
			break;
		case "WebShots Results":
			theParent = document.getElementById("WebShots_content");
			break;
		default:
			break;
	}
	return X;
}

function GetNSPaneY(pane) {
	var theParent;
	var Y = pane.offsetTop;
	switch (pane.contentDocument.title) {
		case "WebShots Map Legend":
			theParent = self.top.document.getElementById('WebShots_leftnav').contentDocument.getElementById('WebShots_legendpane');			
			Y += GetNSPaneY(theParent);
			break;
		case "WebShots Map Legend Pane", "WebShots Navigation":
			theParent = self.top.document.getElementById('WebShots_leftnav');
			Y += GetNSPaneY(theParent);
			break;
		case "WebShots Charts":
			theParent = document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane").contentDocument.getElementById("WebShots_chartspane");
			Y += GetNSPaneY(theParent);
			break;
		case "Charts Pane":
		    theParent = document.getElementById("WebShots_content").contentDocument.getElementById("WebShots_resultspane");
			Y += GetNSPaneY(theParent);
			break;
		case "WebShots Results":
			theParent = document.getElementById("WebShots_content");
			break;
		default:
			break;
	}
	return Y;
}

// ------------------- //
// Page Initialization //
// ------------------- //

function Init() {
	CurrentZoom = document.getElementById("Zoom7");
	LoadData();
	var WebShotsPage = document.getElementById("WebShotsPage");
	WebShotsPage.style.width = "100%";
	WebShotsPage.style.height = "100%";
	RestoreSummary();
	ResizeMap();
	self.top.ToCenterMap = true;
	bPageLoaded = true;
}

