var months_names = ['Януари', 'Февруари', 'Март', 'Април', 'Май', 'Юни', 'Юли', 'Август', 'Септември',
	'Октомври', 'Ноември', 'Декември'];
function onIssueYearChange () {
	var year_select = document.getElementById('issue_year');
	var year = year_select.options[year_select.selectedIndex].value;
	var months = Issues[year];
	var month_select = document.getElementById('issue_month');
	for (var i = month_select.options.length; i > 0; i --) {
		month_select.removeChild(month_select.options[0]);
	}
	for (i = 11; i >= 0; i --) {
		if (months[i]) {
			var option = document.createElement ('option');
			option.value = months[i];
			option.innerHTML = months_names[i];
			month_select.appendChild(option);
		}
	}
}

function init () {
	onIssueYearChange ();
	if (issue_selected_id) { 
		var month_select = document.getElementById('issue_month');
		for (var i = 0, c = month_select.options.length; i < c; i ++)
			if (month_select.options[i].value == issue_selected_id) {
				month_select.selectedIndex = i;
				break;
			}
	}
}

if (window.addEventListener) {
	window.addEventListener("load", init, false);
} else if (window.attachEvent) {
	window.attachEvent('onload', init);
} else {
	window.onload = init;
}