


var site =
{
	CONST:
	{
	  root: '#/site/'
	, titleSuffix: ' - Little North Attleboro League'
	}	// CONST


, meta:
	{
		docs: new Array()
	, pathIx: new Array()
	}	// meta








, dedoubled: function
(
  path
)
		{
		return	path.replace( /\/\//g, '/' );
		}	// End method; dedoubled




, loadDoc: function
(
  docIx
, win
)
		{
		if ( (typeof win) == 'string'  &&  win != window.name )
			{
			docIx = ( (typeof docIx) != undefined  ?  docIx  :  '#' );

			win =  ( window.location.hash == docIx  ?  window  :  window.open( null, win ) );
			if ( win.location.hash.length < 1 )
				win.open( '/' + docIx, win.name );
			else
				win.site.loadDoc( docIx );

			win.focus();
			return	win;
			}
		docIx = unescape( ( (typeof docIx) != undefined  ?  docIx  : ( window.location.hash.length > 0  ?  window.location.hash  :  '#' )  ) );

		var doc = this.meta.docs[docIx];
		if ( (typeof doc) == undefined )
			{
			window.defaultStatus = 'no meta-site document information available; ' + docIx;
			alert( window.defaultStatus );
			return window;
			}

		if ( (typeof doc.title) != undefined )		document.title = doc.title + site.CONST.titleSuffix;
		window.location.hash = docIx

		if ( (typeof doc.sections) == undefined )
			{
			window.defaultStatus = 'no section(s) for document; ' + docIx;
			alert( window.defaultStatus );
			return window;
			}
		if ( (typeof doc.sections) == 'string' )
			this.loadSection( doc.section );
		else
			for ( var s = 0;  s < doc.sections.length;  s++ )
				{
				this.loadSection( doc.sections[s] )
				}	// End for; span of sections to load for document

		return	window;
		}	// End method; loadDoc






, loadSection: function
(
	sect
)
		{
		var div = document.getElementById( sect.divID );
		if ( (typeof div) == undefined )
			{
			window.defaultStatus = 'div/section not found: ' + sect.divID;
			alert( window.defaultStatus );
			return;
			}


// unload stuff loaded with previous section????
// unload stuff loaded with previous section????
// unload stuff loaded with previous section????
		div.innerHTML = '';
		div.style.backgroundImage = 'url( /assets/media/images/twiddler.gif )';
		div.style.backgroundPosition = 'center';
		div.style.backgroundRepeat = 'no-repeat';
		div.style.backgroundAttachment = 'fixed';

		var meta = null;
		var html;
		var anc;

		meta = ( (typeof sect.metaIx) != undefined  &&  sect.metaIx != null  ?  this.meta.pathIx[sect.metaIx]  :  { uri: sect.uri, css: sect.css, scripts: sect.scripts, inlineEval: sect.inlineEval } );
		if ( (typeof meta) == undefined )
			{
			window.defaultStatus = 'no meta-site path information available; ' + sect.metaIx;
			alert( window.defaultStatus );
			return;
			}

			// Load CSS before altering innerHTML...
		anc = ( (typeof meta.css) != undefined  &&  meta.css != null  ?  meta.css  :  null );
		if ( (typeof anc) != undefined  &&  anc != null )
			{
			if ( (typeof anc) == 'string' )
				core.css( anc );
			else
				for ( var s = 0;  s < anc.length;  s++ )
					core.css( anc[s] );
			}


		if ( (typeof meta.uri) == undefined  ||  meta.uri == null )
			{
			window.defaultStatus = 'no metaIx or uri information provided';
			alert( window.defaultStatus );
			return;
			}

		html = xHTTP( meta.uri );
		if ( (typeof html) == undefined  ||  html == null )
			{
			window.defaultStatus = 'uri not found: ' + meta.uri;
			alert( window.defaultStatus );
			return;
			}

		div.style.backgroundImage = 'none';
		div.innerHTML = html;


		anc = ( (typeof meta.scripts) != undefined  ?  meta.scripts  :  null );
		if ( (typeof anc) != undefined  &&  anc != null )
			{
			if ( (typeof anc) == 'string' )
				core.json( anc )
			else
				for ( var s = 0;  s < anc.length;  s++ )
					core.json( anc[s] );
			}

		anc = ( (typeof meta.inlineEval) != undefined  ?  meta.inlineEval  :  null );
		if ( (typeof anc) == 'string' )	eval( anc );

		}	// End method; loadSection



}	// site