
// class definitions for use in grouping national atlas layers and chapter info

function NAChapter (theId, theShortName, theLongName, theExample, theSortOrder, showIt, theLayers) {
	this.idString = theId;
	this.shortName = theShortName;
	this.longName = theLongName;
  this.example = theExample;
	this.sortOrder = theSortOrder;
	if (typeof showIt == "boolean") {
		this.show = showIt;
	} else {
		this.show = (showIt == 't' || showIt == 'true' || showIt == 1);
	}
	if (theLayers == null || typeof theLayers != "object") {
		this.layers = new Array();
	} else {
		this.layers = theLayers;
	}
}

function NALayerDesc (theId, theAltMldId, theTitle, theMetadataCreationDate, theMetadataOffsiteLink, theMapLink, showIt, theDataItems) {
	this.idString = theId;
	this.altMldId = theAltMldId;
	this.title = theTitle;	
	this.metaDataDate = theMetadataCreationDate;
  this.metaDataOffsiteLink = theMetadataOffsiteLink;
	if (typeof showIt == "boolean") {
		this.show = showIt;
	} else {
		this.show = (showIt == 't' || showIt == 'true' || showIt == 1);
	}
	this.mapLink = theMapLink;
	if (theDataItems == null || typeof theDataItems != "object") {
		this.dataItems = new Array();
	} else {
		this.dataItems = theDataItems;
	}
}

function NADataItem (theId, theType, theFileName, theOffsiteText, theUrl, theRBytes, theCBytes, theCreationDate, showIt) {
	this.idString = theId;
	this.type = theType;
	this.fileName = theFileName;
	this.offsiteText = theOffsiteText;
	this.downloadUrl = theUrl;
	this.rawBytes = theRBytes;
	this.compressedBytes = theCBytes;
	//this.creationDate = theCreationDate.toString();
	this.creationDate = theCreationDate;
	if (typeof showIt == "boolean") {
		this.show = showIt;
	} else {
		this.show = (showIt == 't' || showIt == 'true' || showIt == 1);
	}
}

var allChapters = new Object();
var allLayerDescs = new Object();
var allDataItems = new Object();

function addChapter(id, shortName, longName, example, sortOrder, showIt) {
	var c = new NAChapter(id, shortName, longName, example, sortOrder, showIt);
	allChapters[id] = c;
}

function addLayerDesc (id, altMldId, title, metadataDate, metadataOffsiteLink, parentChapterId, mapLink, showIt) {
	var d = new NALayerDesc (id, altMldId, title, metadataDate, metadataOffsiteLink, mapLink, showIt);
	allLayerDescs[id] = d;
	arrayPush(allChapters[parentChapterId]["layers"], id);
}

function addDataItem (id, type, fName, osText, url, rBytes, cBytes, cDate, parentLayerDescId, showIt) {
	var di = new NADataItem (id, type, fName, osText, url, rBytes, cBytes, cDate, showIt);
	allDataItems[id] = di;
	arrayPush(allLayerDescs[parentLayerDescId]["dataItems"], id);
}
	





addChapter('chpbound', 'Boundaries', 'Boundaries of the United States', 'Political Boundaries', 6, true);
	addLayerDesc('bound0m', null, 'North American Atlas - Political Boundaries', '2004-07-09', null, 'chpbound', null, true );
    addDataItem('bound0m_e00', 'Export', 'bound0m_e00.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/bound0m_e00.tar.gz', 13803520, 3521926, '2004-07-09', 'bound0m', true );
    addDataItem('bound0m_shp', 'Shapefile', 'bound0m_shp.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/bound0m_shp.tar.gz', 12032000, 7541127, '2004-07-09', 'bound0m', true );
  

addChapter('chpgeol', 'Geology', 'Geology of the United States', 'Bathymetry', 12, true);
	addLayerDesc('bathy0m', null, 'North American Atlas - Bathymetry', '2004-07-09', null, 'chpgeol', null, true );
    addDataItem('bathy0m_e00', 'Export', 'bathy0m_e00.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/bathy0m_e00.tar.gz', 21268480, 5258081, '2004-07-09', 'bathy0m', true );
    addDataItem('bathy0m_shp', 'Shapefile', 'bathy0m_shp.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/bathy0m_shp.tar.gz', 19783680, 12397646, '2004-07-09', 'bathy0m', true );
	
addChapter('chpref', 'Map Reference', 'Map Reference Data', 'Populated Places', 18, true);
	addLayerDesc('pop000x', null, 'North American Atlas - Populated Places', '2004-07-09', null, 'chpref', null, true );
    addDataItem('pop000x_e00', 'Export', 'pop000x_e00.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/pop000x_e00.tar.gz', 655360, 95254, '2004-07-09', 'pop000x', true );
    addDataItem('pop000x_shp', 'Shapefile', 'pop000x_shp.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/pop000x_shp.tar.gz', 327680, 76367, '2004-07-09', 'pop000x', true );
  

addChapter('chptrans', 'Transportation', 'Transportation of the United States', 'Railroads, Roads', 22, true);
 	addLayerDesc('rail00l', null, 'North American Atlas - Railroads', '2004-07-09', null, 'chptrans', null, true );
    addDataItem('rail00l_e00', 'Export', 'rail00l_e00.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/rail00l_e00.tar.gz', 3184640, 1124780, '2004-07-09', 'rail00l', true );
    addDataItem('rail00l_shp', 'Shapefile', 'rail00l_shp.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/rail00l_shp.tar.gz', 1259520, 998942, '2004-07-09', 'rail00l', true );
	addLayerDesc('road00l', null, 'North American Atlas - Roads', '2004-07-09', null, 'chptrans', null, true );
    addDataItem('road00l_e00', 'Export', 'road00l_e00.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/road00l_e00.tar.gz', 7004160, 2408939, '2004-07-09', 'road00l', true );
    addDataItem('road00l_shp', 'Shapefile', 'road00l_shp.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/road00l_shp.tar.gz', 2652160, 1988153, '2004-07-09', 'road00l', true );
 
addChapter('chpwater', 'Water', 'Water of the United States', 'Glaciers, Hydrography, Sea Ice', 24, true);
	addLayerDesc('ice000p', null, 'North American Atlas - Glaciers', '2004-07-09', null, 'chpwater', null, true );
    addDataItem('ice000p_e00', 'Export', 'ice000p_e00.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/ice000p_e00.tar.gz', 9277440, 2786099, '2004-07-09', 'ice000p', true );
    addDataItem('ice000p_shp', 'Shapefile', 'ice000p_shp.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/ice000p_shp.tar.gz', 2959360, 1913077, '2004-07-09', 'ice000p', true );
	addLayerDesc('hydro0m', null, 'North American Atlas - Hydrography', '2004-07-09', null, 'chpwater', null, true );
    addDataItem('hydro0m_e00', 'Export', 'hydro0m_e00.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/hydro0m_e00.tar.gz', 26368000, 7277497, '2004-07-09', 'hydro0m', true );
    addDataItem('hydro0m_shp', 'Shapefile', 'hydro0m_shp.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/hydro0m_shp.tar.gz', 20684800, 11411729, '2004-07-09', 'hydro0m', true );
	addLayerDesc('seaicep', null, 'North American Atlas - Sea Ice', '2004-07-09', null, 'chpwater', null, true );
    addDataItem('seaicep_e00', 'Export', 'seaicep_e00.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/seaicep_e00.tar.gz', 430080, 143047, '2004-07-09', 'seaicep', true );
    addDataItem('seaicep_shp', 'Shapefile', 'seaicep_shp.tar.gz', null, 'http://edcftp.cr.usgs.gov/pub/data/nationalatlas/seaicep_shp.tar.gz', 204800, 131830, '2004-07-09', 'seaicep', true );

