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

function popup(obj, id) {
    var elm = document.getElementById(id);
    elm.style.display='block';
    elm.style.position='absolute';
    /* 吹き出しの横軸を設定 */
    elm.style.left = obj.offsetLeft + 30 + "px";
    /* 吹き出しの縦軸を設定, 吹き出し自体の高さを引いて設定 */
    elm.style.top = obj.offsetTop + 30 + "px";
	elm.style.backgroundColor = '#FFFFCC';
	elm.style.border = '1px #FFCC00 solid';
}

function popdown(id) {
    document.getElementById(id).style.display='none';
}


function showpopup(i){
  if($('search_field[' + i + ']').value == '名称')   popup($('search_field[' + i + ']'),'name_search_help');
  if($('search_field[' + i + ']').value == '薬効')   popup($('search_field[' + i + ']'),'class_search_help');
  if($('search_field[' + i + ']').value == '副作用') popup($('search_field[' + i + ']'),'adverse_search_help');
  if($('search_field[' + i + ']').value == '全文')   popup($('search_field[' + i + ']'),'whole_search_help');
}
function hidepopup(){
  popdown('name_search_help');
  popdown('class_search_help');
  popdown('adverse_search_help');
  popdown('whole_search_help');
}

//
//
//

function ToggleSearch (type) {
  var f = window.document.forms[0];
  f.action = '/kusuri/japic_med/list';
  if (type == 'normal') {
    $('search_type').value = 'normal';
  } else {
    $('search_type').value = 'advanced';
  }
  f.submit();
}

// var ShowMax = 3;
// function ShowAdvancedSearch(a) {
//   if (a == '+' && ShowMax < 10) ShowMax++;
//   if (a == '-' && ShowMax > 1)  ShowMax--;
//
//   for(var i = 1; i <= 10; i++) {
//     if (i <= ShowMax) {
//       $('tr_ad' + i).show();
//     } else {
//       $('tr_ad' + i).hide();
//       ClearAdvancedField('search_keyword[' + i + ']')
//     }
//   }
// }

function ClearAdvancedField(id) {
  $(id).value = '';
}

/*
Event.observe(window, "load", function(){
    $('th_japic', 'th_kegg', 'th_name', 'th_class').each(function(e){
      Event.observe(e, 'click', function(){
        alert("th_japic = " + $('th_japic').getWidth() + "\n" +
              "th_kegg  = " + $('th_kegg').getWidth()  + "\n" +
              "th_name  = " + $('th_name').getWidth()  + "\n" +
              "th_class = " + $('th_class').getWidth() + "\n"
              );
      }, false);
    });
});  // Event.observe(window, "load" 終わり
*/

