$(function(){
	$('.nav li ul').hide();
	$('.nav li a').click(function(){
        if($(this).parent('li').children('ul:hidden').length) {
			$(this).find('span').html('-');
			$(this).parent('li').children('ul:hidden').slideDown(100);
			return false;
		} else if($(this).parent('li').find('ul').length) {
			$(this).find('span').html('+');
			$(this).parent('li').find('ul').slideUp(100);
			return false;
		}
		return true;
	})
});

function fixCharts() {
    $('#main .chart img').each(function() {
        var h = $(this).height();
        var w = $(this).width();
        var max = 600;
        if(w > max) {
            newW = 600;
            newH = (h * newW) / w;
            $(this).height(newH);
            $(this).width(newW);
        }
    });
}

function crumbsToNav() {
	$('a[name=openCategory]').click(function() {
		target = '#category_' + $(this).attr('class');
		$(target).parents('ul:hidden').each(function() {
			$(this).find('span').html('-');
			$(this).slideDown(100);
		});
		$(target).find('span').html('-');
		$(target).children('ul:hidden').slideDown(100);
		return false;
	});
}
