var Base = Class.create();
Base.prototype = {
	initialize: function() {
		// public variables
		images = new Array();
		mouseOver = this.mouseOver || Prototype.emptyFunction;
		setContainer = this.setContainer || Prototype.emptyFunction;
		openedContainer = '';
		// private variables
		this.x = 0;
		this.directory = '';
	},
	createMouseOvers: function(container, directory) {
		if (typeof(container) != 'string') container = container.id;
		var reversed = false;
		var curImg = '';
		var newImg = '';
		this.directory = directory;
		this._MOloopTroughContainer(container);
	},
	mouseOver: function(img, index) {
		if (typeof(img) != 'string') img = img.id;
		$(img).src = images[$(img).id.match(/[0-9+]/)[0]][index];
	},
	createTextContainer: function(linkcontainer) {
		if (typeof(linkcontainer) != 'string') linkcontainer = linkcontainer.id;
		var cid = '';
		this._TCloopTroughContainer(linkcontainer);
	},
	setContainer: function(container) {
		if (typeof(container) != 'string') container = container.id;
		if (openedContainer != '') $(openedContainer).style.display = 'none';
		$(container).style.display = 'block';
		openedContainer = container;
	},
	_MOloopTroughContainer: function(container) {
		var nodes = $(container).childNodes;
		for (var i = 0; i < nodes.length; i++) {;
			if (nodes[i].hasChildNodes()) this._MOloopTroughContainer(nodes[i]);
			if (nodes[i].nodeName.match(/IMG/)) {
				if (nodes[i].id.match(/mouseover/)) {	
					reversed = nodes[i].id.match(/reversed/);
					curImg = nodes[i].src;
					newImg = nodes[i].id.split("_").reverse()[0];
					if (this.directory != '') newImg = this.directory + newImg;
					nodes[i].id = 'image' + this.x;
					if (reversed) nodes[i].src = newImg;
					var arr = new Array(2);
					arr[0] = (reversed) ? curImg : newImg;
					arr[1] = (reversed) ? newImg : curImg;
					images.push(arr);
					nodes[i].onmouseover = function() {
						mouseOver(this.id, 0);
					}
					nodes[i].onmouseout = function() {
						mouseOver(this.id, 1);
					}
					this.x++;
				}
			}
		}
	},
	_TCloopTroughContainer: function(container) {
		var nodes = $(container).childNodes;
		for (var i = 0; i < nodes.length; i++) {
			if (nodes[i].hasChildNodes()) this._TCloopTroughContainer(nodes[i]);
			if (nodes[i].nodeName && nodes[i].nodeName.match(/A/)) {
				if (nodes[i].id.match(/TCLink/) && nodes[i].href.match(/#/)) {
					cid = nodes[i].href.match(/\#(.+)/)[1];
					if ($(cid)) $(cid).style.display = 'none';
					nodes[i].parentNode.insertBefore($(cid), nodes[i].nextSibling);
					nodes[i].onclick = function() {
						setContainer(this.href.match(/\#(.+)/)[1]);
					}
				}
			}
		}
	}
}