// ----- カートボタン商品数選択 -----

function changeLista (id){
   document.getElementById('a1').style.display = (id=='a1') ? 'inline' : 'none';
   document.getElementById('a2').style.display = (id=='a2') ? 'inline' : 'none';
   document.getElementById('a3').style.display = (id=='a3') ? 'inline' : 'none';
   document.getElementById('a4').style.display = (id=='a4') ? 'inline' : 'none';
   document.getElementById('a5').style.display = (id=='a5') ? 'inline' : 'none';
   document.getElementById('a6').style.display = (id=='a6') ? 'inline' : 'none';
   document.getElementById('a7').style.display = (id=='a7') ? 'inline' : 'none';
   document.getElementById('a8').style.display = (id=='a8') ? 'inline' : 'none';
   document.getElementById('a9').style.display = (id=='a9') ? 'inline' : 'none';
   document.getElementById('a10').style.display = (id=='a10') ? 'inline' : 'none';
   document.getElementById('a11').style.display = (id=='a11') ? 'inline' : 'none';
}


// ----- 価格表一覧表の行をクリックリンクにする -----

//if (window.addEventListener) { window.addEventListener("load", PricesViewInit, false); }
//else if (window.attachEvent) { window.attachEvent("onload", PricesViewInit); }

document.observe("dom:loaded", PricesViewInit);

function PricesViewInit(){
  if (!document.getElementById) return false;
  if (!document.getElementsByName) return false;
  if (!document.getElementsByTagName) return false;

  var TablesBlk        = document.getElementById("pricesviewtables"); if (!TablesBlk) return false;
  var TableBodies      = TablesBlk.getElementsByTagName("tbody");
  var TableBodiesCount = TableBodies.length;
  for (var t=0; t<TableBodiesCount; t++){
       var TableRows      = TableBodies.item(t).getElementsByTagName("tr");
       var TableRowsCount = TableRows.length; if (TableRowsCount == 0) break;
       for (var i=0; i<TableRowsCount; i++){
            TableRows.item(i).oldClassName = TableRows.item(i).className;
            TableRows.item(i).onmouseover  = function () { addClass(this,"hover"); this.style.cursor = "pointer"; 
                                                           /*this.style.backgroundColor = "#cfc";*/ };
            TableRows.item(i).onmouseout   = function () { this.className = this.oldClassName; 
                                                           /*this.style.backgroundColor = "transparent";*/ };

            var RowAnchors      = TableRows.item(i).getElementsByTagName("a");
            var RowAnchorsCount = RowAnchors.length;
            if (RowAnchorsCount != 0) {
                TableRows.item(i).onclick = function () {
                        var LinkAnchors = this.getElementsByTagName("a");
                        //alert("リンク先：" + LinkAnchors[0].getAttribute("href"));
                        location.href = LinkAnchors[0].getAttribute("href");
                        return false;
                };
                TableRows.item(i).setAttribute("title",RowAnchors[0].getAttribute("title"));
            }
       }
  }
}	// function PricesViewInit() end

function addClass(element,value) {
  if (!element.className) {
      element.className = value;
  } else {
      newClassName = element.className;
      newClassName += " ";
      newClassName += value;
      element.className = newClassName;
  }
}
