function setup_toggle_tabs() {

	// find all anchors with a class of toggle_tab
	var toggle_tabs = getElementsByClass('toggle_tab', document, 'A');
	// loop through, add event on change
	for (var i = 0; i < toggle_tabs.length; i++) {
		toggle_tab_link = toggle_tabs[i];
		// attach onclick function
		addEvent(toggle_tab_link, 'click', toggle_tab, false);
	}

}

function toggle_tab(e) {

	if (window.event) {
		// IE does it differently... stores the event in a window.event object
		var this_element = window.event.srcElement;
	} else {
		var this_element = this;
	}

	// find the target
	var target = findTarget(e);
	// get some of the targets attributes
	var target_href = target.getAttribute('href');
	// strip the hash off the href
	var target_id = target_href.replace(/#/i, '');
	
	/* IE bug where the href value is prepended by the HTTP HOST */
	target_id = target_id.replace(/http:\/\/projects.presencemultimedia.co.uk\/nac\//i, '');
	target_id = target_id.replace(/http:\/\/www.na-c.co.uk\//i, '');
	target_id = target_id.replace(/http:\/\/www.na-consultants.co.uk\//i, '');
	
	/* alert(target_id); */

	if (!document.getElementById(target_id)) return false;
	
	active_tab = document.getElementById(target_id);
	
	// hide all tab_panels
	var tab_panels = getElementsByClass('tab_panel', document, 'DIV');
	// loop through, add event on change
	for (var i = 0; i < tab_panels.length; i++) {
		tab_panel = tab_panels[i];
		tab_panel.style.display = 'none';
	}
	
	// show the active one
	active_tab.style.display = '';
	
	// unhighlight all tab_panel_links
	var tab_panel_links = getElementsByClass('tab_panel_link', document, 'H3');
	
	for (var i = 0; i < tab_panel_links.length; i++) {
		tab_panel_link = tab_panel_links[i];
		//alert(tab_panel_link.className);
		tab_panel_link.className = tab_panel_link.className.replace(/\b ?active_tab\b/,'');
	}
	
	this_element.parentNode.className += ' active_tab';
	
	// cancel bubble and href of this anchor
	cancelClick(e);
	// hack for Safari (stops browser following href link)
	this_element.onclick = function() { return false; }
}

addLoadEvent(setup_toggle_tabs);