/**
 * Accordeon view
 * © Paul Grau, 2011
 */
$(function(){
	var anchor = '';
	anchor = self.document.location.hash.substring(1);
	if (!anchor) anchor = default_section;
	$('.section:not(#section-'+anchor+')').hide();
	if (anchor!=default_section)getSection(anchor);
	$('h2').bind('click',function(e){
		var name = $(this).attr('rel')
		getSection(name);
	});
});

function getSection(name) {
	location.href = orig_path +'#'+name;
	var new_section = $('#section-'+name);
	var cur_section = $('.section:visible');
	var h2 = new_section.prev();
	var offset = h2.offset().top;
	if (!new_section.is(":visible")) {
		$('.section').slideUp(450);
		new_section.slideDown(500);
		if (new_section.prevAll('.section').length>cur_section.prevAll('.section').length)
			offset = offset - cur_section.outerHeight();
	}
	$('html, body').animate({scrollTop: offset}, 700);
}

var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-7373818-1']);
  _gaq.push (['_gat._anonymizeIp']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
