function TabbyCat(){
	
}
TabbyCat.prototype.handleClick=function(tabPrefix, clickedTab, classPrefix){
	this.deactivateAll(tabPrefix, classPrefix);
	this.activate(tabPrefix, clickedTab, classPrefix);
}
TabbyCat.prototype.activate=function(tabPrefix, tab, classPrefix){
	if(this.isActive(tab, classPrefix)){
		return;
	}else{
		tab.className+=' '+classPrefix+'ActiveTab';
		document.getElementById(tabPrefix+'Content'+this.tabNumber(tabPrefix, tab)).className+=' '+classPrefix+'VisibleContent';
	}
}
TabbyCat.prototype.removeClass=function(target, className){
	var currentClasses=target.className.split(" ");
	var newClasses="";
	for(var i=0; i<currentClasses.length; i++){
		if(currentClasses[i]!=className){
			newClasses+=" "+currentClasses[i];
		}
	}
	target.className=newClasses;
}
TabbyCat.prototype.deactivate=function(tabPrefix, tab, classPrefix){
	if(!this.isActive(tab, classPrefix)){
		return;
	}else{
		this.removeClass(tab, classPrefix+"ActiveTab");
		this.removeClass(document.getElementById(tabPrefix+'Content'+this.tabNumber(tabPrefix, tab)), classPrefix+"VisibleContent");
	}
}
TabbyCat.prototype.deactivateAll=function(tabPrefix, classPrefix){
	var currentTab=document.getElementById(tabPrefix+'Tab1');
	var i=1;
	while(currentTab!=null){
		this.deactivate(tabPrefix, currentTab, classPrefix);
		i++;
		currentTab=document.getElementById(tabPrefix+'Tab'+i.toString());
	}
}
TabbyCat.prototype.isActive=function(tab, classPrefix){
	return Boolean(tab.className.search(classPrefix+"ActiveTab")!=-1);
}
TabbyCat.prototype.tabNumber=function(tabPrefix, tab){
	// "tab" is three letters long
	return tab.id.slice(tabPrefix.length+3, tab.id.length);
}
document.tabbyCat=new TabbyCat();
