function debug() {
  msg = '';
  msg = msg + fval('created_from_yyyy') + '/' + fval('created_from_mm') + '/' + fval('created_from_dd') + '\n';
  msg = msg + fval('created_to_yyyy') + '/' + fval('created_to_mm') + '/' + fval('created_to_dd') + '\n\n';
  msg = msg + fval('authorized_from_yyyy') + '/' + fval('authorized_from_mm') + '/' + fval('authorized_from_dd') + '\n';
  msg = msg + fval('authorized_to_yyyy') + '/' + fval('authorized_to_mm') + '/' + fval('authorized_to_dd') + '\n\n';
  msg = msg + fval('lastmodified_from_yyyy') + '/' + fval('lastmodified_from_mm') + '/' + fval('lastmodified_from_dd') + '\n';
  msg = msg + fval('lastmodified_to_yyyy') + '/' + fval('lastmodified_to_mm') + '/' + fval('lastmodified_to_dd') + '\n';

  alert(msg);
}

function sync_dateselector(basename) {
  y = basename + '_yyyy';
  m = basename + '_mm';
  d = basename + '_dd';

  if (elem(y).selectedIndex == 0) {
    elem(m).selectedIndex = 0;
    elem(m).disabled = true;
  }
  else {
    elem(m).disabled = false;
  }
  if (elem(m).selectedIndex == 0) {
    elem(d).selectedIndex = 0;
    elem(d).disabled = true;
  }
  else {
    elem(d).disabled = false;
  }
}

/*
function togglecheckbox(classid) {
  checks = document.getElementsByClassName(classid);
  for (i = 0; i < checks.length; i ++) {
    checks[i].checked = (checks[i].checked == false);
  }
}
*/

// prototype.js の getElementsByClassName が使えない Mac IE5 対策
function togglecheckbox(form) {
  for (i = 0; i < form.length; i++)
    form.elements[i].checked = (form.elements[i].checked == false);
}

// prototype.js の $() が使えない Mac IE5 対策
function elem(id) {
  return document.getElementById(id);
}

// prototype.js の $F() が使えない Mac IE5 対策
function fval(id) {
  return document.getElementById(id).value;
}

function popup(url, width, height) {
  w = window.open(url, "", "WIDTH=" + width + ",HEIGHT=" + height);
  return w;
}

function popup_medialogo(url) {
  return popup(url, 250, 150);
}

function popup_mediaimage(url) {
  return popup(url, 200, 200);
}

function in_array(the_needle, the_haystack){
  var the_hay = the_haystack.toString();
  if(the_hay == ''){
    return false;
  }
  var the_pattern = new RegExp(the_needle, 'g');
  var matched = the_pattern.test(the_haystack);
  return matched;
}