// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function showhide(layer_ref, state, link_ref, style) {

    if (document.all) {
        eval( "document.all." + layer_ref + ".style.display = state");
        eval( "document.all." + link_ref + ".className = style");
    }

    if (document.layers) { //IS NETSCAPE 4 or below
        document.layers[layer_ref].display = state;
        document.layers[link_ref].className = style;
    }
    if (document.getElementById && !document.all) {
        maxwell_smart = document.getElementById(layer_ref);
        maxwell_smart.style.display = state;
        
        maxwell_smart2 = document.getElementById(link_ref);
        maxwell_smart2.className = style;
    }
}

function show_div(layer_ref, link_ref) {
    showhide(layer_ref, 'block', link_ref, 'selected');
}

function hide_div(layer_ref, link_ref) {
    showhide(layer_ref, 'none', link_ref, '');
}

function highlight_row(checkbox_id, row_id, default_class) {
  
  if (document.all) {
      if (checkbox_id.checked) {
          eval( "document.all." + row_id + ".className = row_higlighted");
      } else {
          eval( "document.all." + row_id + ".className = " + default_class);
      }
  }

  if (document.layers) { //IS NETSCAPE 4 or below
      class_name = document.layers[checkbox_id].checked ? 'row_highlighted' : default_class;
      document.layers[row_id].className = class_name;
  }
  if (document.getElementById && !document.all) {
      maxwell_smart2_checkbox = document.getElementById(checkbox_id);
      class_name = maxwell_smart2_checkbox.checked ? 'row_highlighted' : default_class;
      maxwell_smart2 = document.getElementById(row_id);
      maxwell_smart2.className = class_name;
  }
}

function get_shifted_time(year, month, date, hour, minute) {
  m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  timezone_offset = (new Date()).getTimezoneOffset() / 60;
  time = new Date(year, month, date, hour + timezone_offset, minute);
  
  var curr_hour = time.getHours();
  if (curr_hour < 12) {
    a_p = "AM";
  } else {
    a_p = "PM";
  }

  if (curr_hour == 0) {
    curr_hour = 12;
  }
  if (curr_hour > 12) {
    curr_hour = curr_hour - 12;
  }

  var curr_min = time.getMinutes();
  curr_min = curr_min + "";

  if (curr_min.length == 1) {
    curr_min = "0" + curr_min;
  }
  
  return m_names[time.getMonth()] + " " + time.getDate() + ", " + time.getFullYear() + "<br />" + curr_hour + ":" + curr_min + " " + a_p;
}