// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var MSIE = false;
if (navigator.userAgent.indexOf("MSIE") != -1) {
	MSIE = true;
}

function clearKeywords() {
  document.getElementById("keywords").value = "";
}

function setSidebar(uri) {
  window.parent.side.location.href = uri;
}

function setContent(uri) {
  window.parent.content.location.href = uri;
}

function setHeader(uri) {
  window.parent.header.location.href = uri;
}

function setEnabled(inputElement, enabled) {
  if (enabled) {
    if (MSIE) {
      inputElement.setAttribute("disabled", false);
    }
    else {
      inputElement.removeAttribute("disabled");
    }
    inputElement.style.backgroundColor = "#FFFFFF";
  }
  else {
    inputElement.setAttribute("disabled", "disabled");
    inputElement.style.backgroundColor = "#e0e0e0";
  }
}

function clearOptions(select) {
  var opts = select.options;
  var len = opts.length;
  for (var i = 0; i < len; i++) {
    select.removeChild(opts[0]);
  }
}

function setOptions(select, array) {
  var len = array.length;
  for (var i = 0; i < len; i++) {
    var opt = document.createElement("option");
    opt.setAttribute("value", array[i][0]);
    opt.appendChild(document.createTextNode(array[i][1]));
    select.appendChild(opt);
  }
}

function selectOption(select, value) {
  var opts = select.getElementsByTagName("option");
  for (var i = 0; i < opts.length; i++) {
    if (opts[i].value == value) {
      opts[i].setAttribute("selected", "selected");
    }
    else {
      opts[i].removeAttribute("selected");
    }
  }
}

function showRestProducts() {
  document.getElementById("rest_products").style.display = "block";
  var button = document.getElementById("toggle_button");
  button.innerHTML = '<img src="/images/content/drug/dc_minus.gif" alt="-"> 隠す'
  button.onclick = hideRestProducts
}

function hideRestProducts() {
  document.getElementById("rest_products").style.display = "none";
  var button = document.getElementById("toggle_button");
  button.innerHTML = '<img src="/images/content/drug/dc_plus.gif" alt="+"> その他' + restCount + '件を表示'
  button.onclick = showRestProducts
}
