function SwapTabsA(active)
{
	// set the regex
	var reg = new RegExp(active);
	// get the li elements in the tabs div
	var tabs = $('tabsa').firstDescendant().childElements();
	// loop through all li elements
	tabs.each(function(tab)
	{
		// set the clicked tab to selected		
		if (tab.readAttribute("onclick").match(reg))
			tab.className = "selected";
		else
			tab.className = "";
	});
	// get the div elements in the tabs content div
	var divs = $('tabsa-content').childElements();
	divs.each(function(content)
	{
		// set the content to block for clicked tab
		if (content.id == active)
			content.style.display = "block";
		else
			content.style.display = "none";
	});
}

function centerDiv(el, toggle)
{
    var docWH = document.viewport.getDimensions();
    var divLoadingWH = $(el).getDimensions();
    $(el).setStyle({
      left: (docWH.width - divLoadingWH.width) / 2 + 'px',
      top: (docWH.height - divLoadingWH.height) / 2 + 'px'
    });
    if (toggle)
      $(el).toggle();
}

function chatTracker () {
	window.open('https://www.theplanet.com/chat/launch-chat-estara.html','','top=36,left=36,height=1,width=1');
}



function tabSwitch(id)
{
	switch(id)
	{
	case 'tab1': //First Tab
		$('tabs').style.backgroundPosition = '0px 39px';
		$('tabContent').innerHTML = '<a href="/hosting-solutions/"><img src="http://content.theplanet.com/images/layout/' + id + 'Banner.jpg" alt="" /></a>';
		$('tabContent').style.display = 'block';
		$('tabAltContent').style.display = 'none';		
		break;
	case 'tab2': //Second Tab
		$('tabs').style.backgroundPosition = '0px 85px';
		$('tabContent').innerHTML = '<a href="/data-centers/"><img src="http://content.theplanet.com/images/layout/' + id + 'Banner.jpg" alt="" /></a>';
		$('tabContent').style.display = 'block';
		$('tabAltContent').style.display = 'none';		
		break;
	case 'tab3': //Third Tab
		$('tabs').style.backgroundPosition = '0px 131px';
		$('tabContent').innerHTML = '<a href="/why-the-planet/Customer-Success-Stories/"><img src="http://content.theplanet.com/images/layout/' + id + 'Banner.jpg" alt="" /></a>';
		$('tabContent').style.display = 'block';
		$('tabAltContent').style.display = 'none';		
		break;
	case 'tab4': //Fourth Tab
		$('tabs').style.backgroundPosition = '0px 177px';
		$('tabContent').style.display = 'none';
		$('tabAltContent').style.display = 'block';		
		break;
	default:
		$('tabs').style.backgroundPosition = '0px 39px';
		$('tabContent').innerHTML = '<a href="/hosting-solutions/"><img src="http://content.theplanet.com/images/layout/' + id + 'Banner.jpg" alt="" /></a>';
		$('tabContent').style.display = 'block';
		$('tabAltContent').style.display = 'none';		
	}
}

//clean-up the following code when time permits

function specialSwitch(id) {
	switch(id)
	{
	case 'special01':
		$('specialTabs').style.background = '#fff url(http://content.theplanet.com/images/layout/SpecialsTab01-Bkgd.jpg) no-repeat left top';
		$('specialContent01').style.display = 'block';
		$('specialContent02').style.display = 'none';
		$('specialContent03').style.display = 'none';
		$('specialContent04').style.display = 'none';
//		$('specialContent05').style.display = 'none';
		$('specialBanner01').style.display = 'block';
		$('specialBanner02').style.display = 'none';
		$('specialBanner03').style.display = 'none';
		$('specialBanner04').style.display = 'none';
//		$('specialBanner05').style.display = 'none';		
		break;
//	case 'special02':
//		$('specialTabs').style.background = '#fff url(http://content.theplanet.com/images/layout/SpecialsTab02-Bkgd.jpg) no-repeat left top';
//		$('specialContent01').style.display = 'none';
//		$('specialContent02').style.display = 'block';
//		$('specialContent03').style.display = 'none';
//		$('specialContent04').style.display = 'none';
//		$('specialContent05').style.display = 'none';
//		$('specialBanner01').style.display = 'none';
//		$('specialBanner02').style.display = 'block';
//		$('specialBanner03').style.display = 'none';
//		$('specialBanner04').style.display = 'none';
//		$('specialBanner05').style.display = 'none';		
		break;
	case 'special02':
		$('specialTabs').style.background = '#fff url(http://content.theplanet.com/images/layout/SpecialsTab02-Bkgd.jpg) no-repeat left top';
		$('specialContent01').style.display = 'none';
		$('specialContent02').style.display = 'block';
		$('specialContent03').style.display = 'none';
		$('specialContent04').style.display = 'none';
//		$('specialContent05').style.display = 'none';
		$('specialBanner01').style.display = 'none';
		$('specialBanner02').style.display = 'block';
		$('specialBanner03').style.display = 'none';
		$('specialBanner04').style.display = 'none';
//		$('specialBanner05').style.display = 'none';		
		break;
	case 'special03':
		$('specialTabs').style.background = '#fff url(http://content.theplanet.com/images/layout/SpecialsTab03-Bkgd.jpg) no-repeat left top';
		$('specialContent01').style.display = 'none';
		$('specialContent02').style.display = 'none';
		$('specialContent03').style.display = 'block';
		$('specialContent04').style.display = 'none';
//		$('specialContent05').style.display = 'none';
		$('specialBanner01').style.display = 'none';
		$('specialBanner02').style.display = 'none';
		$('specialBanner03').style.display = 'block';
		$('specialBanner04').style.display = 'none';
//		$('specialBanner05').style.display = 'none';		
		break;
	case 'special04':
		$('specialTabs').style.background = '#fff url(http://content.theplanet.com/images/layout/SpecialsTab04-Bkgd.jpg) no-repeat left top';
		$('specialContent01').style.display = 'none';
		$('specialContent02').style.display = 'none';
		$('specialContent03').style.display = 'none';
		$('specialContent04').style.display = 'block';
//		$('specialContent05').style.display = 'block';
		$('specialBanner01').style.display = 'none';
		$('specialBanner02').style.display = 'none';
		$('specialBanner03').style.display = 'none';
		$('specialBanner04').style.display = 'block';
//		$('specialBanner05').style.display = 'block';		
		break;
	default:
		$('specialTabs').style.background = '#fff url(http://content.theplanet.com/images/layout/SpecialTab01-Bkgd.jpg) no-repeat left top';
		$('specialContent01').style.display = 'block';
		$('specialContent02').style.display = 'none';
		$('specialContent03').style.display = 'none';
		$('specialContent04').style.display = 'none';
//		$('specialContent05').style.display = 'none';
		$('specialBanner01').style.display = 'block';
		$('specialBanner02').style.display = 'none';
		$('specialBanner03').style.display = 'none';
		$('specialBanner04').style.display = 'none';
//		$('specialBanner05').style.display = 'none';		
		break;
	}
}

//var currentTab = 1;

function start_tabTimer(tab, start_tab, end_tab)
{
	return (function() {
		
		if (tab == end_tab) { tab = start_tab; } else { tab = tab + 1; }

		for (i = 0; i <= end_tab; i++)
		{
			if (i == tab) {
				currentTab = i;
				tabSwitch('tab'+ i);
			}
		}
		timeout = setTimeout(start_tabTimer(tab, start_tab, end_tab), duration);
	})
}

function stop_tabTimer()
{
	clearTimeout(timeout);
}