/*
Object Oreinted, multi-level dynamic content support.
Copyright 2008, Keen Kelly (www.keenkelly.com) All rights reserved.
Non-exclusive, unrestricted, transferrable license granted to Permco Engineering, Inc. without distribution.
*/

function dynamic_content() {
	this.last_content = Array();
	this.debug = false;

	this.change_content = change_content;
	this.initialize_level = initialize_level;

	function initialize_level(level, contentid) {
		this.last_content[level] = contentid;
	}

	function change_content(contentid, level) {

		// If there's no change from what's showing then bail
		if (contentid == this.last_content[level]) {
			return;
		}

		// Hide the old
		if (e = document.getElementById(this.last_content[level])) {
			e.style.display = 'none';
		}
		else {
			if (this.debug) {
				alert("dynamic_content.js - DEBUG: Couldn't find the LAST one [" + this.last_content[level] + "]");
			}
		}

		// Show the new
		if (e = document.getElementById(contentid)) {
			e.style.display = 'block';
		}
		else {
			if (this.debug) {
				alert("dynamic_content.js - DEBUG: Couldn't find the NEW one [" + contentid + "]");
			}
		}

		// Remember what we're showing
		this.last_content[level] = contentid;
	}
}