var site_url = "../route/";

function show_route( sub_dir, file_name, label, option )
{
	var msg = site_url + "RideServer.php?";
	
	if ( label )
	{
		msg = msg + "Label=" + label;
	}
	else
	{
		return false;
	}
	
	if ( sub_dir )
	{
		msg = msg + "&SubDir=" + sub_dir;
	}
	if ( file_name )
	{
		if ( file_name=="Calendar" )
		{
			file_name="general";
		}
		msg = msg + "&FileName=" + file_name;
	}
	
	if ( option > 0 )
	{
		msg = msg + "&Option=" + option;
	}
	
	location.href = msg;
	return false;
}	

function show_weekly( )
{
	today = new Date();
	var tm = today.getMonth() + 1;
	if (today.getDate() > 15)
	{
		if (++tm > 12)
		{
			tm = 1;
		}
	}
	return show_route("", "weekly-" + tm , "none", 5);
}	

function show_this_week()
{
	site_url = "route/";
	return show_weekly();
}

function get_archive()
{
	var m;
	var y;
	var p;
	with (document.coaster)
	{
		mm=month.selectedIndex;
		yy=year.selectedIndex;
		m=month.options[mm].value;
		y=year.options[yy].value;
		if ( yy == 0 )
		{
			var today = new Date();
			var tm = today.getMonth();
			if (tm < mm)
			{
				window.alert("Newsletter edition for this month not yet added to archives.");
				return false;
			}
		}
	}
	p='newsletter-pdf/' + y + '/' + y + '-' + m + '.pdf';
	location.href = p;
	return false;
}
