function $RF(el, radioGroup) {
    if($(el).type && $(el).type.toLowerCase() == 'radio') {
        var radioGroup = $(el).name;
        var el = $(el).form;
    } else if ($(el).tagName.toLowerCase() != 'form') {
        return false;
    }

    var checked = $(el).getInputs('radio', radioGroup).find(
        function(re) {return re.checked;}
    );
    return (checked) ? $F(checked) : null;
}

function getProvinces(cntry, prov, selected) {
  var provinceAjax = new Ajax.Updater(
    prov,
    '/ajax/options_provinces.php',
    {
      method: 'post',
      parameters: { country: $F(cntry), selected: selected },
      onLoading: function() { $('province_ajax_indicator').show() },
      onComplete: function() { $('province_ajax_indicator').hide() }
    });        
}

function expandSchool(id) {
	var expandDiv = document.getElementById(id);
	expandDiv.style.display = ( expandDiv.style.display != "block" ) ? "block" : "none";		
}

function startList() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

function setCourseType(type)
{
  try {
    // handle exception in case of points controls missing
    $('do_not_use_points').checked = true;
    
    switch(type) {
      case 'onsite':
        $('use_points_online').hide();
        $('use_points_online_input').disabled = true;
        $('use_points_onsite').show();
        $('use_points_onsite_input').disabled = false;
        break;
      case 'online':
        $('use_points_online').show();
        $('use_points_online_input').disabled = false;
        $('use_points_onsite').hide();
        $('use_points_onsite_input').disabled = true;
        break;
    }
  } catch(error) {}
  
  checkPrice();
}

function calHideAll()
{
  var els = $$('.course-day');
  els.each(function(val, index) { val.setStyle({display: 'none'}) }); 	
}

function calClose(el)
{
  $(el).setStyle({display: 'none'}); 
}

function calShow(el)
{
  calHideAll();
  $(el).setStyle({display: 'block'}); 	
}

Event.observe(window, 'load', startList);	

