
// Prevent console.log failures if not available
if (window['console'] === undefined) {
  window.console = { log: function(){} };
}

var Demo = function() {
	this.initialize = function() {
		this.optionspanel  = document.getElementById('optionspanel');
		this.optionsbutton = document.getElementById('optionsbutton');
		this.optionsclose  = document.getElementById('closeoptionsbtn');
		this.infopanel     = document.getElementById('infopanel');
		this.infobutton    = document.getElementById('infobutton');
		this.infoclose     = document.getElementById('closeinfobtn');
		
		var self = this;
		this.optionsbutton.onclick = function(event) {
			self.showHUD(this, self.optionspanel);
		}
		this.optionsclose.onclick = function(event) {
			self.closeHUD(self.optionsbutton, self.optionspanel);
		}
		this.infobutton.onclick = function(event) {
			self.showHUD(this, self.infopanel);
		}
		this.infoclose.onclick = function(event) {
			self.closeHUD(self.infobutton, self.infopanel);
		}
	}
	this.showHUD = function(button, panel) {
		if (panel.className == 'hud') {
			panel.className  = 'hud hud-visible';
			button.className = 'toolbutton toolbutton-active';
		} else {
			panel.className  = 'hud';
			button.className = 'toolbutton';
		}
	}
	this.closeHUD = function(button, panel) {
		panel.className  = 'hud';
		button.className = 'toolbutton';
	}
}

window.onload = function() {
	new Demo().initialize();
}

