$(document).ready(function() {
	$('div.products> div').hide(); // collapse products menu by default
	$('div#leftmenu> div').hide(); // collapse main links menu by default
	
	var current = $(this).find("a").filter(function() { return this.href == location.href; }); // find link corresponding to current product page
	current.addClass('selected'); // add 'selected' class to current product link
	current.parent().parent().parent().addClass('selected').show(); // show product box based on selected link and add 'selected' class
	current.parent().parent().parent().prev().addClass('selected'); // add 'selected' class to previous h3 tag of selected link's div
	current.parent().parent().parent().parent().show(); // show main link box, too
	
	// make products links collapsible
	$('div.products> h3').click(function() {
		$(this).next('div').slideToggle('fast')
			.siblings('div:visible').slideUp('fast');
	});
	
	// make main links collapsible
	$('div#leftmenu> h3').click(function() {
		$('div#leftmenu> h3').find("a").click();
		$(this).next('div').slideToggle('fast')
			.siblings('div:visible').slideUp('fast');
	});
})
