// JavaScript Tabs
var to = null;
function tab_switch(id) {

	$$('.tab_content').invoke('hide');
	$('section-' + id).setStyle('display:block');
	$('content-section-' + id).setStyle('display:block');
    
    clearInterval(to);
    
    switch(id){
        case 1: to = setInterval( "slideSwitch('slideshow-hvac')", 4000 );
            $('section-' + id).setStyle('background-image:none');
            break;
        case 2: to = setInterval( "slideSwitch('slideshow-electrical')", 4000 );
            $('section-' + id).setStyle('background-image:none');
            break;
        case 3: to = setInterval( "slideSwitch('slideshow-plumbing')", 4000 );
            $('section-' + id).setStyle('background-image:none');
            break;
        case 4: to = setInterval( "slideSwitch('slideshow-fire-protection')", 4000 );
            $('section-' + id).setStyle('background-image:none');
            break;
        case 5: to = setInterval( "slideSwitch('slideshow-controls')", 4000 );
            $('section-' + id).setStyle('background-image:none');
            break;
        case 6: to = setInterval( "slideSwitch('slideshow-service')", 4000 );
            $('section-' + id).setStyle('background-image:none'); 
            break;
    }

	var ourTabs = $$('#tab_anchors a');
	
	for(var i = 0; i < ourTabs.length; i++) {
		if ((i + 1) == id) {
			ourTabs[i].setStyle({backgroundColor : '#cccfd6'});
		}
		else {
			ourTabs[i].setStyle({backgroundColor : '#E5E5E5'});
		}
	}
	//.anchors .tabs-selected a.a_tab1:link, .anchors .tabs-selected a.a_tab1:visited,		
}

function management_tab_switch(id) {
	document.getElementById('section-' + lastTabId).style.display = 'none';
	document.getElementById('section-' + id).style.display = 'block';
	lastTabId = id;
	var ourTabs = document.getElementById('tab_anchors').getElementsByTagName("li");
	
	for(var i = 0; i < ourTabs.length; i++) {
		if ((i + 1) == id) {
			ourTabs[i].className = 'tabOn' + (i+1);
		}
		else {
			ourTabs[i].className = 'tab' + (i+1);
		}
	}
	//.anchors .tabs-selected a.a_tab1:link, .anchors .tabs-selected a.a_tab1:visited,		
}
