$(document).ready(function () {
	// mark current pages current
	var location = window.location.href;
	location = location.split('/');
	var full_url = '/' + location[3] + '/' + location[4];
	var page = location[location.length-1];
	if (location.length > 4) {
	    page = location[location.length-2];
	}
	
	$("a").each(function () {
		var href = $(this).attr('href');
		if (href == page || href == '/' + page || href == './' + page || href == full_url) {
			$(this).addClass('on');
			if($(this).closest('#sub_nav').length) {
				var parent_href = '/page/' + $(this).closest('#sub_nav').attr('class');
				$("#nav a").each(function () {
					var this_href = $(this).attr('href');
					if(this_href == parent_href || this_href == '/' + parent_href || this_href == './' + parent_href || this_href == full_url) {
						$(this).addClass('on');
					}
				});
			}
		}
	});
	
});
