// site.js - global javascript code (for every dang page)
//
function xLinks ()
// make all links with rel="x"  into target="_blank"
//                   href="exp" and "con" into tglHid calls
{  if (! document.getElementsByTagName)  return;  // old browser?
  var aLst = document.getElementsByTagName ("a");
   for (var i = 0; i < aLst.length; i++) {
     var an = aLst [i];
     var r  = an.getAttribute ("rel");
      if (r && (r == "x"))  {an.target = "_blank";}
      if (r && (r.substr(0,3) == "exp")) {
         an.href = "javascript:tglHid('" + r.substr(3) + "');";
         an = document.getElementById (r.substr(3));
         an.style.display = "none";
      }
      if (r && (r.substr(0,3) == "con")) {
         an.href = "javascript:tglHid('" + r.substr(3) + "');";
         an = document.getElementById (r.substr(3));
         an.style.display = "block";
      }
   }
}
function catchph ()
// write a random one of our catchphrases
{  ph = new Array (
      "no rules just piano",
      "learning piano - whatever it takes",
      "practice bliss",
      "piano play the OPTIMAL way",
      "...it figures...",
      "...DEAL with it",
      "Saving the world from the crap on the radio",
      "...good grief...",
      "whoooooah!!  Who busted the grumpy??",
      "the world needs MORE piano players",
      "piano practice session compression",
      "piano play with a digital display",
      "all's fair in love, war and PIANO",
      "no heroes just 1337 skillz"
   );
   document.write (ph [parseInt (Math.random () * ph.length)]);
}
function tglHid ()
{  for (var i = 0; i < tglHid.arguments.length; i++) {
     var s = document.getElementById (tglHid.arguments [i]).style;
      s.display = (s.display && (s.display == "block")) ? "none" : "block";
   }
}
window.onload = xLinks;
