$(document).ready(function(){

// Accordion

$('#nav-primary').accordion({ 
    active: false, 
    header: '.accordion', 
    navigation: true, 
    event: 'click', 
    fillSpace: false, 
    animated: 'slide' 
	});

// Firewood type switcher
	$('div#re-sale').hide();
	$('div#domestic').show();
	$('#firewood li#t-1 a').addClass('active');

	$("#firewood li a").click(function(){
	var openWindow = $(this).attr("href");
	
	$("#firewood li a").removeClass("active");
	$(this).addClass("active");
	$('#domestic').hide();
	$('#re-sale').hide();
	$(openWindow).show();
	return false;
	
    });

// Contact switcher
	$('div#department').hide();
	$('div#location').show();
	$('#contact-switch li.end a').addClass('active');

	$("#contact-switch li a").click(function(){
	var openWindow = $(this).attr("href");
	
	$("#contact-switch li a").removeClass("active");
	$(this).addClass("active");
	$('#location').hide();
	$('#department').hide();
	$(openWindow).show();
	return false;
	
    });
	
	// setting the tab to hide and show, setting the current link
	$('#location div').hide();
	$('#head-office').show();
	$('#location li#t-1 a').addClass('selected');
	
	$("#location li a").click(function(){
	var officeLocation = $(this).attr("href");
	
	$("#location li a").removeClass("selected");
	$(this).addClass("selected");
	$('#location div').hide();
	$(officeLocation).show();
	return false;

    });
		
	$('div.dept').hide();
	$('#department h3 a:first').addClass('active');
	$('div.dept:first').show();
	$('#department h3 a').click(function(){
	if($(this).hasClass('active')) { // check if link clicked has class of current
	$(this).removeClass('active'); // if active set to inactive
	$(this).parent().next('div.dept').toggle('slow'); // toggle div
	return false;
	} else {
	$('div.dept:visible').toggle('slow'); // close all visible divs
	$('#department h3 a').removeClass('active'); // remove the class current from all links
	$(this).toggleClass('active');
	$(this).parent().next('div.dept').toggle('slow'); // toggle div
	return false;
		}
			});

	});