/******************--------- TAB Nav homepage----------*************************/
fp = {
	///Initialise variables///
	// Page section IDs
	contentWrapperId:'center-interface', // Main content container - must be on the page you want the tabs on
	detailsContainer:'tabs-homepage-top', // Details container that gets pre hidden before page has loaded
	detailsNav:'home-extra-nav', // UL id of tabs
/* 	listCourses: 'list-courses', */
	
	// CSS classes
	dynamicClass:'fp',
	showClass:'show',
	currentClass:'current',
	hideClass:'hide',
	// Define the firsttab
	initID:'specialoffers',
	
	init:function(){
		
		if(!document.getElementById || !document.createTextNode){return;}
		var container=document.getElementById(fp.contentWrapperId);
		if(!container){return;}
		helper.cssjs('add',container,fp.dynamicClass);
		fp.initTabs();
		//fp.initList();
	},
	
	showPara:function(e)
	{
		var whichPara=helper.getTarget(e);
		var toDisplay=whichPara.getAttribute('href').replace('.php', "");
		var toDisplay=toDisplay.replace(/^.*[\/\\]/g, '');
		
		if(document.getElementById(toDisplay))
			{
				var toDisplay=document.getElementById(toDisplay);
				toDisplay.style.display='block';
			}
	},
	
	deletePara:function(e)
	{
		var whichPara=helper.getTarget(e);
		var toDisplay=whichPara.getAttribute('href').replace('.php', "");
		var toDisplay=toDisplay.replace(/^.*[\/\\]/g, '');
		
		if(document.getElementById(toDisplay))
			{
				var toDisplay=document.getElementById(toDisplay);
				toDisplay.style.display='none';
			}
	},
	
	initTabs:function()
	{
		var nav=document.getElementById(fp.detailsNav);
		if(nav && nav.getElementsByTagName('a')[0])
		{
			var links=nav.getElementsByTagName('a');
			var firstSection=links[0].href.toString().match(/#(.*)/)[1];
			firstSection=document.getElementById(firstSection);
			
			if(firstSection){
				
				//var parentDIV=firstSection.parentNode.parentNode;
				var firsttab=document.getElementById(fp.initID);
/*				var essai=firsttab.getElementsByTagName('p');
				essai[essai.length-1].style.display='none';
*/				helper.cssjs('add',firsttab,fp.showClass);
				fp.currentSection=firstSection;
								
				// Add currentClass to first link
				helper.cssjs('add',links[0],fp.currentClass);
				fp.currentLink=links[0];
				for(var i=0;i<links.length;i++){
					helper.addEvent(links[i],'click',fp.showTab,false);
					helper.fixSafari(links[i]);
				}
			}
		}
	},
	
	showTab:function(e)
	{
		var section=helper.getTarget(e);
		var toshow=section.getAttribute('href').toString().match(/#(.*)/)[1];
		
		/*----Get rid off the "Back Menu" link-----*/
		var backMenu=document.getElementById(toshow).getElementsByTagName('p');
		backMenu[backMenu.length-1].style.display='none';
		
/*		var backMenu=document.getElementById(toshow).getElementsByTagName('a');
		backMenu[0].style.display='none';
*/
		
		
		if(fp.currentSection && fp.currentLink)
		{
			helper.cssjs('remove',fp.currentSection,fp.showClass);
			helper.cssjs('remove',fp.currentLink,fp.currentClass);
		}
		if(document.getElementById(toshow))
		{
			var toshow=document.getElementById(toshow);
			helper.cssjs('add',toshow,fp.showClass);
			helper.cssjs('add',section,fp.currentClass);
			fp.currentSection=toshow;
			fp.currentLink=section;
		}
		helper.cancelClick(e);
	}
}
// start the show.
helper.addEvent(window, 'load', fp.init, false);
