var separator = '-';

function enableThemes()
{
	var mode = document.forma.all_themes.checked;
	var elementsCount = document.forma.elements.length;
	for (i = 0; i < elementsCount; i++)
		if (document.forma.elements[i].name.search(/^t_\d+/) >= 0)
			document.forma.elements[i].disabled = mode;
}

function checkData()
{
	if (DATA_SENT) return false;

	if (!checkActiveDate('from'))  return false;
	if (!checkActiveDate('to'))  return false;

	elementsCount = document.forma.elements.length;

	// check genre list
	themeCount = selThemes = 0;
	themeList = '';

	//if (!document.forma.all_themes.checked)
	for (i = 0; i < elementsCount; i++)
	// calculate selected items then disable it
	if (document.forma.elements[i].name.search(/^t_\d+/) >= 0)
	{
		themeCount++;
		if (document.forma.elements[i].checked)
		{
			selThemes++;
			num = document.forma.elements[i].name.match(/\d+/);
			themeList += (themeList ? separator : '') + num[0];
		}
	}

	/*if (!document.forma.all_themes.checked)
	{
		// check user selection
		if (!selThemes)
			if (confirm(noThemes)) document.forma.all_themes.checked = true; else return false;*/

		// disable selection if everithing is checked
		if (selThemes == themeCount) themeList = '';
	//}

	with (document.forma.themes) if (themeList) value = themeList; else disabled = true;

	// construct date_from
	if (document.forma.date_filter_from.checked)
		document.forma.date_from.value
			= 	document.forma.year_from.value
			+ '-' + document.forma.month_from.selectedIndex
			+ '-' + document.forma.day_from.value;
	else
		document.forma.date_from.disabled = true;

	// construct date_to
	if (document.forma.date_filter_to.checked)
	{
		document.forma.date_to.value
			= 	document.forma.year_to.value
			+ '-' + document.forma.month_to.selectedIndex
			+ '-' + document.forma.day_to.value;
	}
	else
	{
		document.forma.date_to.disabled = true;
	}

	//document.forma.all_themes.disabled = true;

	// disable all rubrication elements
	for (i = 0; i < elementsCount; i++)
		if (document.forma.elements[i].name.search(/(^t_)|(^date_filter_)|(^year_)|(^month_)|(^day_)/) >= 0)
			document.forma.elements[i].disabled = true;

	return DATA_SENT = 1;
}