document.documentElement.className += ' js ';

/**
 * Склонятор чисел
 *
 *  1, 21, 91 дама
 *  2, 4, 24, 92 дамы
 *  5, 9, 11, 19, 25, 95 дам
 *
 * assert(declineRusNums(1, ['дама','дамы','дам']) == 'дама', '1 дама');
 * assert(declineRusNums(2, ['дама','дамы','дам']) == 'дамы', '2 дамы');
 * assert(declineRusNums(5, ['дама','дамы','дам']) == 'дам', '5 дам');
 */
function declineRusNums(n, s){
	var d=0, h=0;
	return s[(!(d=(h=n%100)%10)||(h>4&&(h<21||d>4)))?2:Number(d!=1)];
}


/**
 * Добовляет класс 'current' ссылкам ведущим сами на себя
 * @param options
 */
window.highlight_current_links = function(options) {
	if (options && options.remove_old_current_class) {
		$('a').removeClass('current')
	}
	$('a[href='+ location.pathname + location.hash +']').addClass('current')
	var paths = location.pathname.split('/');

	if( paths.length > 2 && /\d+/.test(paths[2]) ) {
   	$('a[href='+ '/' + paths[1] +']').addClass('sub-current')
  }
}

$(function(){
	window.highlight_current_links()
})