﻿$(function() {
	$('#year-select').change(function() {
		if ($('#year-select')[0].selectedIndex == 0) {
			var action = $('#year-switch').attr('action');
			action = action.replace('archive/', '');
			$('#year-switch').attr('action', action);
		}
		$('#year-switch').submit();
	});
	$('#month-select').change(function() {
		if ($('#year-select')[0].selectedIndex == 0) {
			var action = $('#year-switch').attr('action');
			action = action.replace('archive/', '');
			$('#year-switch').attr('action', action);
		}
		$('#year-switch').submit();
	});
	$('#prev-year').click(function() {
		if ($('#year-select')[0].selectedIndex > 0) {
			$('#year-select')[0].selectedIndex--;
			$('#year-switch').submit();
		}
		return false;
	});
	$('#next-year').click(function() {
		if ($('#year-select')[0].selectedIndex < $('#year-select')[0].options.length - 1) {
			$('#year-select')[0].selectedIndex++;
			$('#year-switch').submit();
		}
		return false;
	});

});
