build_checkboxes = function (num) {
	if( isNaN(num) ) throw "Repetition must be a number";

	parent_node = document.getElementById('check_array');

	childs_num = parent_node.childNodes.length;
	for (var i = 0; i<childs_num; i++){
		parent_node.removeChild(parent_node.lastChild);
	}

	li_node = document.getElementById('base_li');
	check_node = document.getElementById('base_check');
	for (var j = 0; j<num; j++){
		node = parent_node.appendChild(li_node.cloneNode(1));
		node = node.appendChild(check_node.cloneNode(1));
		node.setAttribute('name', 'stat_array[' + j + ']');
		if (stat_array[j] == 1){
			node.checked = true;
		}
	}
	
	// Hides the Show days button, in the Group pattern template, by default.
	document.getElementById('show_days_btn').style.visibility = 'hidden';
};

initPattern = function() {
	document.getElementById('start_date').value = start_date;
	document.getElementById('rep_period').value = rep_period;
	build_checkboxes(rep_period);	
};

// Makes the Show days button, in the Group pattern template, visible.
show_show_days_button = function() {
	document.getElementById('show_days_btn').style.visibility = 'visible';
}