var mootabs = new Class({
	
	initialize: function(element, loadtab, options) {
		this.options = Object.extend({
			activeClass:		'active',
			hoverClass:			'over',
			activateOnLoad:		loadtab
		}, options || {});
		
		this.el = $(element);
		this.elid = element;
		
		this.titles = $$('#' + this.elid + ' .nik_tab_title li');
		
		this.panels = $$('#' + this.elid + ' .nik_content_panel');
		
		this.titles.each(function(item) {
			item.addEvent('click', function(){
					item.removeClass(this.options.activeClass);
					this.activate(item);
				}.bind(this)
			);
			
			item.addEvent('mouseover', function() {
				if(item != this.activeTitle)
				{
					item.addClass(this.options.hoverClass);
				}
			}.bind(this));
			
			item.addEvent('mouseout', function() {
				if(item != this.activeTitle)
				{
					item.removeClass(this.options.hoverClass);
				}
			}.bind(this));
		}.bind(this));		
		
		if(this.options.activateOnLoad != 'none')
		{
			this.activate(this.titles[this.options.activateOnLoad]);
		}
	},
	
	activate: function(tab){		
		var newTab = tab.getProperty('title');
				
		this.panels.removeClass(this.options.activeClass);
		this.panels.setStyle('display', 'none');
		
		if($('section_tabs') != null){
			this.titles.removeClass('p1active');
			this.titles.removeClass('e2active');
			this.titles.removeClass('l3active');
		}else{
			this.titles.removeClass(this.options.activeClass);	
		}
		
		if($('section_tabs') != null){
			if(newTab == 'performance'){ $(newTab + '_tab').addClass('p1active'); };
			if(newTab == 'environmental'){ $(newTab + '_tab').addClass('e2active'); };
			if(newTab == 'lifestyle')  { $(newTab + '_tab').addClass('l3active'); };
		}else{
			$(newTab + '_tab').addClass(this.options.activeClass);	
		}
		$(newTab).setStyle('display', 'block');
		
		this.activeTitle = tab;

	}
});

function getURLVar(urlVarName) {
//divide the URL in half at the '?'
	var urlHalves = String(document.location).split('?');
	var urlVarValue = 0;
	if(urlHalves[1]){
		//load all the name/value pairs into an array
		var urlVars = urlHalves[1].split('&');
		//loop over the list, and find the specified url variable
		for(i=0; i<=(urlVars.length); i++){
			if(urlVars[i]){
				//load the name/value pair into an array
				var urlVarPair = urlVars[i].split('=');
				if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
					//I found a variable that matches, load it's value into the return variable
					urlVarValue = urlVarPair[1];
				}
			}
		}
	}
	return urlVarValue;   
}