// Handle Window Onload Funtions
var woms = new Array();
function womOn(){ window.onload = womGo; }
function womGo(){ for(var i = 0;i < woms.length;i++) eval(woms[i]); }
function womAdd(func){ woms[woms.length] = func; }
womOn();

// Buttons
var initButtons = function() {
	var buttons = document.getElementsByClassName('button');
	for(var i=0;i<buttons.length;i++) {
		var a = buttons[i].cloneNode(false);
		a.classname = '';
		//var a = document.createElement('a');
		var b = document.createElement('b');
		var s = document.createElement('span');
		var p = document.createElement('p');
		s.innerHTML = buttons[i].innerHTML;
		b.appendChild(s);
		a.appendChild(b);
		p.appendChild(a);
		p.className = buttons[i].className;
		//a.href = buttons[i].href;
		//a.onclick = function() { buttons[i].onclick; };
		//a.setAttribute('onclick', buttons[i].getAttribute('onclick'));
		//a.setAttribute('id', buttons[i].getAttribute('id'));
		//if(buttons[i].onclick) p
		//p.setAttribute('onmouseover', buttons[i].getAttribute('onmouseover'));
		//p.setAttribute('onmouseout', buttons[i].getAttribute('onmouseout'));
		//p.setAttribute('tooltip', buttons[i].getAttribute('tooltip'));
		buttons[i].parentNode.replaceChild(p, buttons[i]);
	}
}
womAdd('initButtons()');

// Shortcuts
var initGotos = function() {
	var all = document.getElementsByTagName('*');
	for(var i=0;i<all.length;i++) {
		if(all[i].getAttribute('goto')) {
			var link = all[i].getAttribute('goto');
			addEvent(all[i], 'click', function() { window.location = link; });
			all[i].style.cursor = 'pointer';
		}
	}
}
womAdd('initGotos()');



// Utility Stuff
function addEvent(element, event, func){
	if (document.addEventListener) element.addEventListener(event, func, false);
	else element.attachEvent('on'+event, func);
}
function removeEvent(element, event, func){
	if (document.removeEventListener) element.removeEventListener(event, func, false);
	else element.detachEvent('on'+event, func);
}
function go() { void(0); }
