function prepare_archive()
{
	if(document.getElementById('calendar'))
	{
		var days=document.getElementById('calendar').getElementsByTagName('tbody')[0].getElementsByTagName('a');
		for(i=0;days.length>i;i++) days[i].onclick=aday_clicked;
	}
}
function aday_clicked()
{
	var sayear=document.getElementById('ayear').options[document.getElementById('ayear').selectedIndex].value;
	var samonth=document.getElementById('amonth').options[document.getElementById('amonth').selectedIndex].value;
	var additional='ayear='+sayear+'&amonth='+samonth+'&aday='+this.innerHTML;
	return redirect_archive(additional);
}
function redirect_archive(additional)
{
	var parts_of_url=location.href.split('?');
	if(parts_of_url.length>1)
	{
		parts_of_url[1]=parts_of_url[1].replace(/(&ayear=[0-9]*&amonth=[0-9]*&aday=[0-9]*)|(ayear=[0-9]*&amonth=[0-9]*&aday=[0-9]*&*)/,'');
		parts_of_url[1]=parts_of_url[1].replace(/show_calendar=[0-9]*/,'');
		if(parts_of_url[1].length>0) parts_of_url[1]=parts_of_url[1]+'&';
		window.location.href='?'+parts_of_url[1]+additional;
	}
	else window.location.href='?'+additional;
	return false;
}
function show_archive_help()
{
	window.open('data/archive_help.htm','','width=570,height=500,resizeable=yes,scrollbars=yes');
	return false;
}