function toggle_report(id) {
	var report = $('report_' + id);

	if (report) {
	  report.toggle();

	  toggle_button(id);
	}
}

function collapse_all_reports() {
  for (id = 0; ; id++) {
    var report = $('report_' + id);

    if (!report) {
      break;
    }

    report.hide();

    expand_button(id);
  }
}

function expand_all_reports() {
  for (id = 0; ; id++) {
    var report = $('report_' + id);

    if (!report) {
      break;
    }

    report.show();

    collapse_button(id);
  }
}

function toggle_button(id) {
  var button = $('button_' + id);

  if (button) {
		if(button.src.indexOf('/images/collapse.png') == -1) {
		    collapse_button(id);
		} else {
		    expand_button(id);
		}
	}
}

function collapse_button(id) {
  var button = $('button_' + id);

  if (button) {
    button.src = '/images/collapse.png';
  }
}

function expand_button(id) {
  var button = $('button_' + id);

  if (button) {
    button.src = '/images/expand.png';
  }
}

