//-------------------------------------------------------
// Home page slides
//-------------------------------------------------------
var visible_slide = 1;
var rotation_timeout = null;
var SLIDE_DELAY = 10000;

function show_slide(slide_number) {
  if (slide_number == visible_slide) return;
  
  new Effect.Parallel([
    new Effect.Appear('home_page_slide_'+slide_number, {duration: 1, sync: true}),
    new Effect.Fade('home_page_slide_'+visible_slide, {duration: 1, sync: true})
  ], {queue:'end'});
  
  visible_slide = slide_number;
  rotate_slides();
}

function rotate_slides() {
  var next_slide = visible_slide == 5 ? 1 : visible_slide +1;
  if (rotation_timeout != null) clearTimeout(rotation_timeout);
  rotation_timeout = setTimeout('show_slide('+next_slide+')', SLIDE_DELAY);
}




//-------------------------------------------------------
// Report functions
//-------------------------------------------------------
function set_order(order) {
  $('report_order').value = order;
  $('new_report').submit();
}


function check_or_uncheck_all(obj, group_no) {
  is_checked = obj.checked ? 'checked' : ''
  checkboxArray = $('group_'+group_no).getElementsByTagName('input');
  for(i=0; i<checkboxArray.length; i++){
    checkboxArray[i].checked = is_checked
  }
}

function uncheck_parent_if_unchecked(obj, group) {
  if(obj.checked == false) {
    $('select_group_'+group).checked = '';
  }
}