var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17832565-1']);
_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);
})();

(function($) { 
 $.log = function(msg) {
   if (typeof(console) != 'undefined') {
     console.log(msg);
   }
   else {
     $('#debug').append(msg + '<br />');
   }
 }
})(jQuery);

function setActiveLinks() {
  var path = window.location.pathname;
  var pathparts = path.replace(/index.html/, '').split('/');
  pathparts.shift(); //get rid of empty first element
  for(var i in pathparts) {
    parseActiveLinks(i, pathparts[i])
  }
}
function parseActiveLinks(index, val) {
  var menuIndex = new Array('#nav', '#subnav');
  $(menuIndex[index]+' li').each(function() {
    if ($(this).children('a').eq(0).length) {
      var href = $(this).children('a').eq(0).attr('href').replace('index.html', '').split('/');
      href.shift();
      href[index] == val ? $(this).addClass('active') : false;
    }
  });
}

$(document).ready(function(){
   setActiveLinks();
});
