<!-- This javascript file is responsible for the registration and activity management of the sidebar tab boxes.-->

var registrationArray = new Array();
var tabArray = new Array();

function registerTabs(containerID, referenceArray) {
	var tempArray = new Array();
	tempArray.push(containerID);
	tempArray.push(referenceArray);
	tabArray.push(tempArray);
}

function registerTabsActivate() {
	tabArray.each(function(t) {
		var init=true;
		
		var arrayIndex = registrationArray.push(t[1]) - 1;
		
		t[1].each(function(s) {
			s.arrayIndex = arrayIndex;
			
			$(s.id).setStyle({
				cursor: 'pointer'
			});
			
			$(s.id).observe('click', function(event) {
				activitySet(t[0], s);
			});
			
			if(init) {
				activitySet(t[0], s);
				init=false;
			}
		});
	});
}

function activitySet(containerID, tabObject) {
	registrationArray[tabObject.arrayIndex].each(function(s) {
		$(s.id).setStyle({
			backgroundColor: '#eeeeee'
		});
		
		$$('#'+s.id+'>img')[0].src = s.tabImage+'.gif';

		$(s.contentID).setStyle({
			display: 'none'			
		});
	});
	
	$(tabObject.id).setStyle({
		backgroundColor: '#cccccc'
	});
	
	$(tabObject.contentID).setStyle({
		display: 'block'
	});
	
	$$('#'+tabObject.id+'>img')[0].src = tabObject.tabImage+'_over.gif';
}

function TabInstance(id, tabImage, contentID) {
	this.id = id;
	this.tabImage = tabImage;	
	this.contentID = contentID;	
	this.arrayIndex;
}

Event.observe(window, 'load', function() {
	registerTabsActivate();
});
