if (typeof Haaretz === 'undefined') {
  Haaretz = {};
}

if (typeof jQuery !== 'undefined') {
	jQuery(document).ready(function() {
			Haaretz.Facebook.facebookInArticleTabInit();
		}
	);
}

Haaretz.Facebook = function() {
	return {
		facebookInArticleTabInit : function() {
			var tabset = jQuery("#facebookTabset");						
			var tabs = jQuery("#facebookTabset .tabTitle", tabset);
			tabs.each(function(){
				var _this = jQuery(this);
				var tabId = _this.attr('id');
				var tabMatchingBox = jQuery("#"+tabId+"Box", tabset);
				_this.click(function(){
					//remove all current active classes
					 tabs.removeClass('active');
					var facebookTabs = jQuery(".facebookTab", tabset);
					facebookTabs.removeClass('active');
					//set active class 
					tabMatchingBox.addClass("active");
					_this.addClass("active");
				})
			})
				
		}
		
	};

}();
