/**
 * tabflex - for displaying different modules within a tabbed layout
 * @author Tom Cool @ FrenzyMedia B.V. - http://frenzymedia.eu
 * @class tabflex object
 * @constructor
 * @param {jQuery} $ The jQuery object - to prevent conflicts with similar libraries
 */
var tabflex = (function ($) {

	/**
	 * Additional css-selectors are stored seperately
     * @namespace Private properties
     */
	var selectors = {
		tabs :		'ul.tabflex_tabs li a',
		content :	'.tabflex_content',
		activeTab : 'a.activetab',
		active :	'activetab'
	},

	/**
     * @namespace Private properties and methods
     */
	priv = {

		/**
		 * This function binds the click-event to each tab
		 */
		setTabbedContent : function () {
			
			$(selectors.tabs).bind('click', function () {
				
				$(this).parents('ul').find(selectors.activeTab).removeClass(selectors.active);
				$(this).addClass(selectors.active);
				$(this.hash).show().siblings(selectors.content).hide();
				return false;
				
			}).filter(':first').click();
		}
	};

	/**
	 * @namespace Public properties and methods
     * @scope log
     */
	return {

		/**
		 * This function is called on initial body.onload and binds the tabbed-functionality to the tabflex
		 */
		initiate : function () {
			priv.setTabbedContent();
		}
	};

})(jQuery);

jQuery( function () {
	tabflex.initiate();
});
