// JUST A FIRST TEST of animating jump targets

/**
 * Get the hash portion (the jump target, anything after the # sign) out of the URL.
 *
 * @method getHash
 * @return {string} The hash portion of the document's location or null
 */
function getHash() {
  var i, href, hash;
  href = top.location.href;
  i = href.indexOf("#");
  hash = (i >= 0 ? href.substr(i + 1) : '');
  return (hash.match(/^[a-zA-Z0-9_]+$/) ? hash : null);
}
/** Unsets animated attributes. */
function unmark_target() {
  var id = getHash();
  YAHOO.util.Dom.setStyle(id, 'color', '');
  YAHOO.util.Dom.setStyle(id, 'backgroundColor', '');
}

/** Marks an existing hash target. */
function mark_target() {
  var id = getHash();
  if (! id) { return; }
  id = document.getElementById(id);
  if (! id) { return; }
  if ((id.nodeName != 'A') && (id.nodeName != 'SPAN')) { return; }
  var att_in = {
    color: { from: '#000', to: '#f00' },
    backgroundColor: { from: '#fff', to: '#ff0' }
  };
  var att_out = {
    color: { from: '#f00', to: '#000' },
    backgroundColor: { from: '#ff0', to: '#fff' }
  };
  var ani1 = new YAHOO.util.ColorAnim(id, att_in, 0.5);
  var ani2 = new YAHOO.util.ColorAnim(id, att_out, 0.5);
  var ani3 = new YAHOO.util.ColorAnim(id, att_in, 0.5);
  var ani4 = new YAHOO.util.ColorAnim(id, att_out, 0.5);
  var ani5 = new YAHOO.util.ColorAnim(id, att_in, 0.5, YAHOO.util.Easing.easeInStrong);
  var ani6 = new YAHOO.util.ColorAnim(id, att_out, 5, YAHOO.util.Easing.easeInStrong);
  ani1.onComplete.subscribe(function() { ani2.animate(); });
  ani2.onComplete.subscribe(function() { ani3.animate(); });
  ani3.onComplete.subscribe(function() { ani4.animate(); });
  ani4.onComplete.subscribe(function() { ani5.animate(); });
  ani5.onComplete.subscribe(function() { ani6.animate(); });
  ani6.onComplete.subscribe(function() { unmark_target(); });

  ani1.animate();
}

// Activate the script
YAHOO.util.Event.onDOMReady(mark_target);
