var Insights = Class.create();
Insights.prototype = {	
	initialize : function() {
		var self = this;
		var insight_tabs = $A($('insights-categories').getElementsByTagName('LI'));
		var divs = $A($('insights').getElementsByTagName('DIV'));
		//console.log(divs);
		insight_tabs.each(function(tab) {
			var ankor = $(tab).firstDescendant();
			addEvent(ankor, "click", function() {
				if ($(this.parentNode).hasClassName('selected')) { return false; }
				var cln = this.className;
				insight_tabs.each(function(t) {
					if (Element.hasClassName(t,'selected')) { 
						Element.removeClassName(t,'selected');
					}
					if ((cln!="commentary") && $('insights-hub')) {
						$('insights-hub').hide();
					} else if ((cln=="commentary") && $('insights-hub')) {
						$('insights-hub').show();
					}
				});
				divs.each(function(d) {
					if ($(d).className == cln) {
						if (cln == "commentary" && $('insights-hub')) {
							$('insights-hub').down().addClassName('selected');
							$('hub-view').show();
						} else {
							$(d).show();
						}
					} else {	
					 $(d).hide();
					}
				});
				Element.addClassName(this.parentNode,'selected');
				self.adjust_ad_spots();
				return false;		
			});
		});
	},
	
	adjust_ad_spots : function() {
		if ($('halfpageR')) {
			placeAC('halfpageR');
		}
	}
		
};