function selectRadio(prefix, name, counter, value)
{
	document.getElementById(prefix + name).value = value;
	$("div[id^='" + prefix + name + "_div_']").html("<br/>");
	document.getElementById(prefix + name + "_div_" + counter).innerHTML = '<img src="../images/select_arrow.png" class="form_select_arrow" />';
}

function selectCheckbox(prefix, name, value, small, callback, callback_attributes)
{
	var small = small || "";
	var callback = callback || "";
	var callback_attributes = callback_attributes || [];
	
	if(0 == document.getElementById(prefix + name).value)
	{
		document.getElementById(prefix + name).value = value;
		document.getElementById(prefix + name + "_div").innerHTML = '<img src="../images/select_arrow.png" class="form_select_arrow' + small + '" />';
	} else
	{
		document.getElementById(prefix + name).value = 0;
		document.getElementById(prefix + name + "_div").innerHTML = '<br/>';
	}
	
	if("" != callback)
	{
		attributes_string = "";
		for(var ic = 0; ic < callback_attributes.length; ic ++)
		{
			attributes_string += "'" + callback_attributes[ic] + "',";
		}
		attributes_string += "0";
		eval(callback + "(" + attributes_string + ")");
	}
}

function open_closeSelect(prefix, name)
{
	if("none" == document.getElementById(prefix + name + "_div_options").style.display)
	{
		document.getElementById(prefix + name + "_div_options").style.display = "block";
	} else
	{
		document.getElementById(prefix + name + "_div_options").style.display = "none";
	}
}
function selectOption(prefix, name, value, text, class_extra)
{
	var class_extra = class_extra || "";
	
	document.getElementById(prefix + name).value = value;
	document.getElementById(prefix + name + "_div").innerHTML = text;
	document.getElementById(prefix + name + "_div_options").style.display = "none";
	
	$("div[id^='" + prefix + name + "_div_option_']").removeClass("div_form_option" + class_extra + "_selected");
	$("div[id^='" + prefix + name + "_div_option_']").addClass("div_form_option" + class_extra);
	document.getElementById(prefix + name + "_div_option_" + value).className = "div_form_option" + class_extra + "_selected";
}


/*
* agenda filter functions
*/
function filterAgenda(prefix, education_chapter_prefix, location_prefix)
{
	var chapter_elements = $("input[id^='" + prefix + education_chapter_prefix + "']");
	var location_elements = $("input[id^='" + prefix + location_prefix + "']");

	var educations_selected = [];
	for(var ice = 0; ice < chapter_elements.length; ice ++)
	{
		if(0 != chapter_elements[ice].value)
		{
			educations_selected.push(chapter_elements[ice].value);
		}
	}
	var locations_selected = [];
	for(var ice = 0; ice < location_elements.length; ice ++)
	{
		if(0 != location_elements[ice].value)
		{
			locations_selected.push(location_elements[ice].value);
		}
	}
	
	var all_items = $("div[id^='items_']");
	for(var ii = 0; ii < all_items.length; ii ++)
	{
		var id = all_items[ii].id;
		var alt = all_items[ii].getAttribute("alt");
		
		var to_show = false;
		
		var to_show_locations = true;
		var to_show_educations = true;
		//var to_show_educations = false;
		//var to_show_locations = false;
		/*for(var ice = 0; ice < educations_selected.length; ice ++)
		{
			if(-1 != new String(id).indexOf("_" + educations_selected[ice] + "_"))
			{
				to_show_educations = true;
			}
		}
		for(var ice = 0; ice < locations_selected.length; ice ++)
		{
			if(-1 != new String(alt).indexOf("_" + locations_selected[ice] + "_"))
			{
				to_show_locations = true;
			}
		}*/
		
		to_show = to_show_educations && to_show_locations;
		if(to_show)
		{
			$("#" + id).css("display", "block");
			//$("#" + id).fadeTo(200, 1);
		} else
		{
			$("#" + id).css("display", "none");
			//$("#" + id).fadeTo(200, 0);
		}
	}
}


/*
* agenda / open days functions
*/
function openAgendaDay(category_prefix, items_prefix, category_open, item_open, info_open)
{
	$("#div_filter").css("display", "none");
	$("#div_back_list").css("display", "block");
	$("div[id^='" + items_prefix + "']").css("display", "none");
	$("div[id^='" + category_prefix + "']").slideToggle(100, function()
	//$("div[id^='" + category_prefix + "']").fadeTo(200, 0, function()
		{
			//$("#" + category_open).fadeTo(200, 1);
			
			$("#" + item_open + "_a").css("display", "none");
			$("#" + item_open + "_span").css("display", "block");
			$("#" + item_open).css("display", "block");
			$("#" + info_open).css("display", "block");
			//$("#" + info_open + "_description").css("display", "block");
		}
	);
	$("#" + category_open).slideToggle(100);
}
function openAgendaList(category_prefix, items_prefix, info_prefix, prefix, education_chapter_prefix, location_prefix)
{
	$("#div_filter").css("display", "block");
	$("#div_back_list").css("display", "none");
	$("div[id^='" + info_prefix + "']").css("display", "none");
	$("div[id^='" + items_prefix + "']").css("display", "block");
	$("a[id^='" + items_prefix + "']").css("display", "block");
	$("span[id^='" + items_prefix + "']").css("display", "none");
	
	$("div[id^='" + category_prefix + "']").hide(1).slideToggle(100, function()
	//$("div[id^='" + category_prefix + "']").fadeTo(200, 1, function()
		{
			//$("div[id^='" + category_prefix + "']").css("display", "block");
			filterAgenda(prefix, education_chapter_prefix, location_prefix);
		}
	);
}
