/**
 * @fileOverview This file contains the Router for verunkavlkova.com
 * @author Jacob Fierro
 */

VV.Router = Backbone.Router.extend({
	routes : {
		'' : 'root',
		'tab/:panel' : 'tabSwitcher'
	},

	root : function() {
		this.goToTab($('#main-nav').find('ul li:first a').attr('href'));
	},

	goToTab : function(tab) {
		this.navigate("tab/"+tab.slice(1), true);
	},

	tabSwitcher : function(panel) {
		var old = $('.active');
		var clicked = $("a[href^='#"+panel+"']");

		if (old !== clicked) {
			old.removeClass('active');
			clicked.addClass('active');

			$(old.attr('href')).addClass('hide');
			$(clicked.attr('href')).removeClass('hide');

			$('body').removeClass().addClass("body-"+panel);
		}
	}
	
});
VV.router = new VV.Router;
Backbone.history.start();
