// JavaScript Document
$j(document).ready(function(){

	    /* set an interval to run code every 20 seconds (name it so we can end it later) */
	    var tabChange = setInterval
	    (
	    /* create an anonymous function to run the code */
	    function() {
	    /* check if the function '$' exists (since we need to use it) and that
	    the tabs have been loaded (second condition) */
	    if(typeof $!='undefined' && $('ka_messageBoardsTab'))
	    {
	    /* add a new <div> to the main navbar */
	    /*var NewDiv = document.createElement('div');
	    NewDiv.id = 'diversityLiveLink';
	    $('ka_headerTopNav_ul').parentNode.appendChild(NewDiv);*/
	
	    /* write the link into the new <div> */
	    /*$('diversityLiveLink').innerHTML = '<a href="http://www.diversitylive.net/">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>';*/
		
		/* change the ordering */ 
		//$('ChannelsTab').parentNode.insertBefore($('ChannelsTab'),$('ka_videoTab'));
		
		/*Change text from Groups to Chapters*/
		$('ka_groupsTab_nav').getElementsByTagName('span')[0].innerHTML = "<span>&nbsp;</span>";
		
		/* change the ordering */ 
		$('ka_groupsTab').parentNode.insertBefore($('ka_groupsTab'),$('ka_videoTab'));
		
		
		/* add another new <li> to the main navbar */
		var NewTab = document.createElement('li');
		NewTab.id = 'webinarTab';
		$('ka_messageBoardsTab').parentNode.appendChild(NewTab);
	
		/* write the link into the new <li> */
		$('webinarTab').innerHTML = '<a href="http://www.diversitylive.net/webinar.php" id="webinarTab_nav"><span>&nbsp;</span></a>';
	    
	    
	    /* add another new <li> to the main navbar */
		var NewTab2 = document.createElement('li');
		NewTab2.id = 'promotionTab';
		$('ka_messageBoardsTab').parentNode.appendChild(NewTab2);
	
		/* write the link into the new <li> */
		/*$('promotionTab').innerHTML = '<a href="http://www.diversitylive.net/foodnetwork/" id="promotionTab_nav"><span>&nbsp;</span></a>';*/
	
	    
	    /*Re-map links --------------------------------------*/
	    
	    $('ka_groupsTab').parentNode.insertBefore($('ka_memberTab'),$('ka_videoTab'));
	    $('ka_groupsTab').parentNode.insertBefore($('ka_photoTab'),$('ka_videoTab'));
	    
		/* stop the interval since the code has run successfully */
		
	    clearInterval(tabChange);
	    }
	    },20
	    );
});
