//
// Kinderism JS
// Depends on Mootools 1.2
//
var KinderismCore = new Class( 
{
	options: 
	{
		current_tab:		"",
		action_dispatch:	""
	},
	
	initialize: function( options )
	{
		this.setOptions( options );
		this.dispatch();
	},
	
	dispatch: function()
	{
		//
		// Get the action
		var _tmp = this.options.action_dispatch.split("/");
		var actionDispatch = ( _tmp[1] ) ? _tmp[1] : 'home';
		delete _tmp;
		
		//
		// WP bug fix
		actionDispatch = ( actionDispatch.test("page") ) ? 'home' : actionDispatch;
		
		var tabChildren = $('knMBTabs').getChildren('li');
		tabChildren.each( function(el)
		{
			if( el.hasClass('current') )
			{
				el.removeClass('current');
			}
			
			if( el.id == actionDispatch )
			{
				el.addClass('current');
			}
		});
	}
});

//
// Implement MT
KinderismCore.implement( new Options, new Events );