	
if (!document.FIN)
{ 	
	var aShowHideItems;
	
	window.addEvent('domready', function()
	{		
		if (!Browser.Engine.trident4)
		{			
			initOverLabels();	
			initHomeCarousel();
			initHomePanelSwitch();
		}
		
	});
		
	function showHideCommonItems()
	{	
		
		// find the btns and the content we want
		aShowHideItems										= [{btn: $('dyn_ln'),			container:	$('news-updates')},
															   {btn: $('dyn_pc'), 			container:	$('popular-content')}];		
		// cycle through our items
		for (var i = 0; i < aShowHideItems.length; i++)
		{
			// if both the btn and container exist 
			if (aShowHideItems[i].btn && aShowHideItems[i].container)
			{
				aShowHideItems[i].btn.set('inx', i);				
				aShowHideItems[i].btn.addEvent('click', function(event)
				{
					// hide everything else in the menu except the current btn
					hideAll(this.get('inx'));
					// define our content
					var objLanContainer							= aShowHideItems[this.get('inx')].container;	
					var objLanBtn								= aShowHideItems[this.get('inx')].btn;					
					
					// set the relevent classes 
					if (objLanBtn.hasClass('inactive'))			objLanBtn.removeClass('inactive').addClass('active');			
					//else 										objLanBtn.removeClass('active').addClass('inactive');
					if (objLanContainer.hasClass('inactive'))	objLanContainer.removeClass('inactive').addClass('active');			
					//else 										objLanContainer.removeClass('active').addClass('inactive');					
					
					return false;
				});		
			}
		}
	}
	
	function hideAll(param_execption)
	{
		// cycle through our common items
		for (var x = 0; x < aShowHideItems.length; x++)
		{
			// as long as it isn't the caller/execption & both the btn and container exist 
			if (x != param_execption && aShowHideItems[x].container && aShowHideItems[x].btn)
			{
				// hide it
				aShowHideItems[x].container.removeClass('active').addClass('inactive');
				aShowHideItems[x].btn.removeClass('active').addClass('inactive');		
			}
		}
	}

	function initHomePanelSwitch()
	{
		var panel = $('map-info');
		if(panel)
		{
			document.homePanelBusy		= false;

			// dirty hack to check if we're on the home page or the map page
			if($('google-map-area'))
			{
			    document.arrPanels		= new Array(	$('north_panel'),
									$('south_panel')	);
			    document.arrPanelLinks	= new Array(	$('north'),
									$('south')   );
			}
	

			for(var i = 0; i < document.arrPanelLinks.length; i++)
			{
			    if(document.arrPanels[i] && document.arrPanelLinks[i])
			    {
				if(i > 0)
				{
					document.arrPanels[i].setStyle('opacity', 0);
				}
				document.arrPanels[i].removeClass('hidden');

				document.arrPanelLinks[i].iID = i;
				document.arrPanelLinks[i].strID = document.arrPanelLinks[i].getProperty('id');
				document.arrPanelLinks[i].setProperty('href', 'javascript:void(0)');
				document.arrPanelLinks[i].addEvent('click', function()
														{
															// if i'm an active link and i'm not currently transitioning ...
															if(!this.hasClass('inactive') && !document.homePanelBusy)
															{
																for(var j = 0; j < document.arrPanels.length; j++)
																{
																    if(document.arrPanels[j])
																    {
																	// if I'm not the one we want to end up showing ...
																	if(j != this.iID)
																	{
																		// if I'm the one that is currently showing ...
																		if(document.arrPanels[j].getStyle('opacity') == 1)
																		{
																			var myEffect = new Fx.Tween(document.arrPanels[j], {
																																duration: 500,
																																transition: Fx.Transitions.Sine.easeOut
																															});
																			document.arrPanelLinks[j].removeClass('inactive');
																			document.homePanelBusy = true;
																			myEffect.start('opacity', 0);
																		}
																	}
																	else
																	{
																		var myEffect = new Fx.Tween(document.arrPanels[j], {
																																duration: 1000,
																																transition: Fx.Transitions.Sine.easeOut,
																																onComplete: function()
																																			{
																																				document.homePanelBusy = false;
																																			}
																															});
																		myEffect.start('opacity', 1);
																		document.arrPanelLinks[j].addClass('inactive');
																	}
																    }
																}
															}
														});
				}
			}
		}
	}

	var iTimeOut 	= 3500;
	var iTimer;
	var iCurrentID 	= 0;
	
	function fireNextCarouselLink()
	{
        iNewID = iCurrentID + 1;
		iCurrentID = ((iNewID > document.arrLinks.length-1) ? 0 : iNewID);
		document.arrLinks[iCurrentID].fireEvent('click');
	}
	
	function initHomeCarousel()
	{
		var holder = $('carousel-wrapper');
		if(holder)
		{
			document.homeCarouselBusy = false;
			document.arrImages = $$('.carousel-img');
			document.arrLinks = $$('.carousel_link');

			for(var i = 0; i < document.arrImages.length; i++)
			{
				if(i > 0)
				{
					document.arrImages[i].setStyle('opacity', 0);
				}
				document.arrImages[i].removeClass('hidden');

				document.arrLinks[i].ID = i+1;
				document.arrLinks[i].setProperty('href', 'javascript:void(0)');
				document.arrLinks[i].addEvent('mouseup', function()
				{
					iTimer = $clear(iTimer);
				});
				
				document.arrLinks[i].addEvent('click', function()
														{
															// if i'm an active link and i'm not currently transitioning ...
															if(!this.hasClass('inactive') && !document.homeCarouselBusy)
															{
																for(var j = 0; j < document.arrImages.length; j++)
																{
																	// if I'm not the one we want to end up showing ...
																	if(j+1 != this.ID)
																	{
																		// if I'm the one that is currently showing ...
																		if(document.arrImages[j].getStyle('opacity') == 1)
																		{
																			var myEffect = new Fx.Tween(document.arrImages[j], {
																																duration: 1000,
																																transition: Fx.Transitions.Sine.easeOut
																															});
																			document.arrLinks[j].removeClass('inactive');
																			document.homeCarouselBusy = true;
																			myEffect.start('opacity', 0);
																		}
																	}
																	else
																	{
																		var myEffect = new Fx.Tween(document.arrImages[j], {
																																duration: 1750,
																																transition: Fx.Transitions.Sine.easeOut,
																																onComplete: function()
																																			{
																																				document.homeCarouselBusy = false;
																																			}
																															});
																		myEffect.start('opacity', 1);
																		document.arrLinks[j].addClass('inactive');
																		document.iCurrentID = j;
																	}
																}
															}
														});
			}
			iTimer = fireNextCarouselLink.periodical(iTimeOut);
		}
	}
}
		
