function $(s, byTagName) {
 if (byTagName) {
  return document.getElementsByTagName(s);
 } else {
  return document.getElementById(s);
 };
};
function prev(obj) {
 while (obj.nodeType != 1) {
  obj = obj.previousSibling;
 };
 return obj;
};
function insertAfter(parent, node, referenceNode) {
 if(referenceNode.nextSibling) {
  parent.insertBefore(node, referenceNode.nextSibling);
 } else {
  parent.appendChild(node);
 };
};
function lyrics() {
 var DOMsupport = document.getElementById && document.getElementsByTagName && document.createElement;
 if (!DOMsupport) return;
 var forms = $('form', true);
 for (var i = 0; i < forms.length; i++) {
  forms[i].onsubmit = function() {
   // Let's. Validate. Later.
  };
 };
 var inputs = $('input', true);
 for (var i = 0; i < inputs.length; i++) {
  if (inputs[i].type == 'text' || inputs[i].type == 'password') {
   inputs[i].onfocus = function() {
    this.select();
   };
  };
 };
 if ($('chkMessAroundWithThisLyric')) {
  var chk = $('chkMessAroundWithThisLyric');
  $('trMessAroundWithThisLyric').style.display = 'none';
  chk.disabled = false;
  chk.onclick = function() {
   if (this.checked) {
    if (!window.editableLyric) {
     window.editableLyric = document.createElement('textarea');
     window.editableLyric.value = $('lyric').innerHTML;
     $('lyric').parentNode.insertBefore(window.editableLyric, $('lyric'));
     window.editableLyric.id = 'lyric-edit';
    }
    $('lyric').style.display = 'none';
    prev(this.parentNode.previousSibling).className = 'y';
    $('lyric-edit').style.display = 'block';
    $('lyric-edit').focus();
    $('lyric-edit').style.borderColor = 'red';
    $('editLyricSubmit').disabled = false;
   } else {
    $('lyric').style.display = 'block';
    prev(this.parentNode.previousSibling).className = '';
    $('lyric-edit').style.display = 'none';
    $('editLyricSubmit').disabled = true;
   };
  };
  $('lyric').ondblclick = function() {
   chk.click();
  };
  $('lyric').style.cursor = 'pointer';
 };
 if ($('editLyricSubmit')) {
  $('editLyricSubmit').onclick = function() {
   var hi = document.createElement('input');
   hi.setAttribute('type', 'hidden');
   hi.setAttribute('name', 'newLyric');
   hi.setAttribute('value', $('lyric-edit').value);
   $('frmEditLyric').appendChild(hi);
  };
 };
 if ($('artists')) {
  var lab = document.createElement('label');
  lab.className = 'generated';
  lab.setAttribute('for', 'sorting');
  lab.appendChild(document.createTextNode('Display artists as ‘Lastname, Firstname’'));
  var inp = document.createElement('input');
  inp.setAttribute('type', 'checkbox');
  inp.id = 'sorting';
  inp.className = 'checkbox';
  inp.onclick = function() {
   var ol = $('ol', true)[0];
   if (this.checked) {
    ol.className = 'sorted';
    Cookie.create('sorting', 'yes', 7);
   } else {
    ol.className = '';
    Cookie.erase('sorting');
   };
  };
  if (Cookie.read('sorting') == 'yes') {
   inp.checked = true;
   $('ol', true)[0].className = 'sorted';
  };
  lab.appendChild(inp);
  insertAfter($('artists').parentNode, lab, $('artists'));
 };
 if (($('artists') || $('artist')) && $('ol', true).length > 0) {
  var lab = document.createElement('label');
  lab.className = 'generated';
  var previous = 'Real-Time Filter…';
  var inp = document.createElement('input');
  inp.setAttribute('type', 'text');
  inp.className = 'filter';
  inp.setAttribute('value', previous);
  inp.onfocus = function() {
   this.select();
  };
  inp.onkeyup = function() {
   if (this.value.toLowerCase() != previous.toLowerCase()) {
    var ol = $('ol', true)[0];
    for (var x = 0; x < ol.childNodes.length; x++) {
     if (ol.childNodes[x].nodeType == 1) {
      var showOL = false;
      var lis = ol.childNodes[x].getElementsByTagName('li');
      for (var j = 0; j < lis.length; j++) {
       if (lis[j].innerHTML.toLowerCase().indexOf(this.value.toLowerCase()) != -1) {
        lis[j].className = '';
        showOL = true;
       } else {
        lis[j].className = 'filter-not-found';
       };
      };
      if (showOL) {
       ol.childNodes[x].className = '';
      } else {
       ol.childNodes[x].className = 'filter-not-found';
      };
     };
    };
   };
   previous = this.value;
  };
  lab.appendChild(inp);
  if ($('artists')) {
   insertAfter($('artists').parentNode, lab, $('artists'));
  } else {
   insertAfter($('artist').parentNode, lab, $('artist'));
  };
 };
 if ($('spamcheck') && $('txtSpamCheck')) {
  $('txtSpamCheck').value = 'no';
  $('spamcheck').style.display = 'none';
 };
 if ($('footer')) {
  $('footer').innerHTML += '<li>Developed by <a href="/">Krijn Hoetmer</a> and <a href="http://mathiasbynens.be/">Mathias Bynens</a>!</li><li>All lyrics provided for educational purposes only!</li><li>Buy the original album if you like the lyrics!</li><li>Lyrics and web standards can go hand in hand!</li><li>Ow, and <a href="http://browsehappy.com/">please</a>; <a href="http://www.opera.com/">use</a> <a href="http://www.apple.com/safari/">good</a> <a href="http://www.mozilla.org/products/firefox/">browsers</a>!</li>';
 };
};

var Cookie = {
 create: function(name, value, days) {
  if (days) {
   var date = new Date();
   date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
   var expires = '; expires=' + date.toGMTString();
  } else {
   var expires = '';
  };
  document.cookie = name + '=' + value + expires + '; path=/';
 },
 read: function(name) {
  var nameEQ = name + '=';
  var ca = document.cookie.split(';');
  for (var i = 0; i < ca.length; i++) {
   var c = ca[i];
   while (c.charAt(0) == ' ') {
    c = c.substring(1,c.length);
   };
   if (c.indexOf(nameEQ) == 0) {
    return c.substring(nameEQ.length, c.length);
   };
  };
  return null;
 },
 erase: function(name) {
  this.create(name, '', -1);
 }
};

google_ad_client = 'pub-3888385239967217';
google_ad_width = 160;
google_ad_height = 600;
google_ad_format = '160x600_as';
google_ad_type = 'text';
google_ad_channel = '';
google_color_border = 'ffffff';
google_color_bg = 'ffffff';
google_color_link = '6666ff';
google_color_url = '6666ff';
google_color_text = '000000';
