var exSections = {
	openImg:'data/minus.png',
	closedImg:'data/plus.png',
	sections:[],
	open:false,
	add:function( sectionID, state ) {
		var section = new exSection( sectionID, this, state );
		this.sections.push( section );
	},
	toggle:function( sectionID ) {
		var section = this.getSection( sectionID );
		section.toggle();
	},
	toggleAll:function() {
		if( this.open ) {
			this.closeAll();
			this.open = false;
		} else {
			this.openAll();
			this.open = true;
		}
	},
	closeAll:function() {
		for( var idx in this.sections ) {
			this.sections[idx].close();
		}
	},
	openAll:function() {
		for( var idx in this.sections ) {
			this.sections[idx].open();
		}
	},
	getSection:function( sectionID ) {
		for( var idx in this.sections ) {
			if( this.sections[idx].id == sectionID ) {
				return this.sections[idx];
			}
		}
		return false;
	},
	setOpenImg:function( img ) {
		this.openImg = img;
	},
	setClosedImg:function( img ) {
		this.closedImg = img;
	}
}

function exSection( id, sections, state )
{
	stateOpen = false;
	if( state == 'open' ) {
		stateOpen = true;
	}

	this.id = id;
	this.sections = sections;
	this.stateOpen = stateOpen;
	this.isOpen = function(){
		return this.stateOpen;
	};
	this.open = function() {
		var sectionContent = document.getElementById( 'sectionContent'+this.id );
		sectionContent.style.display = 'block';
		this.stateOpen = true;

		var sectionToggler = document.getElementById( 'sectionToggler'+this.id );
		if( sectionToggler ) {
			sectionToggler.src = this.sections.openImg;
		}
	};
	this.close = function() {
		var sectionContent = document.getElementById( 'sectionContent'+this.id );
		sectionContent.style.display = 'none';
		this.stateOpen = false;

		var sectionToggler = document.getElementById( 'sectionToggler'+this.id );
		if( sectionToggler ) {
			sectionToggler.src = this.sections.closedImg;
		}
	};
	this.toggle = function() {
		if( this.stateOpen ) {
			this.close();
		} else {
			this.open();
		}
	};
}