<!--

  document.write('<script type="text/javascript" src="/scripts/PieNG.js"></script>');
  document.write('<script type="text/javascript" src="/scripts/browserdetect_lite.js"></script>');

// accessibilizeLinks
// added 9-8-03
// copy mouse events to keyboard events if no keyboard event exists
// Author: Ryan Carver | fivesevensix.com
function accessibilizeLinks(){
  if (!document.getElementsByTagName) return;
 
  var events = {
  'onmousedown':  'onkeydown',
  'onmouseup':  'onkeyup',
  'onclick':   'onkeypress',
  'onmouseover':  'onfocus',
  'onmouseout':  'onblur'
  }
  var anchors = document.getElementsByTagName("a");
  for(var i=0; i < anchors.length; i++)
  {
    var a = anchors[i];
    for (var e in events)
    {
      if (a[e] && !a[events[e]])
      a[events[e]] = a[e];
    }
  }
}

// popup postcard links
function popPostcards()
{
  var anchors = document.getElementsByTagName("a");
  for(var i=0; i < anchors.length; i++)
  {
    var a = anchors[i];
    var href = a.href;
    if (href.indexOf("images") != -1)
    {
      href = "javascript:popImage('/popup.php?image=" + href + "');";
      a.setAttribute("href",href);
    } else if (href.indexOf("popup.php") != -1) { // it's a swf
      if (href.indexOf("motorcycleTrivia") != -1)
      {
        href = "javascript:popImage('" + href + "',700,550);";
        a.setAttribute("href",href);
      } else if (href.indexOf("bike") != -1) {
        href = "javascript:popImage('" + href + "',700,550);";
        a.setAttribute("href",href);
      }
    }
  }
}

// the popup
function popImage(href,width,height)
{
  if (!width)
  {
    width = 500;
  }
  if (!height)
  {
    height = 357;
  }
  var x = parseInt((screen.availWidth/2) - (width/2));
  var y = parseInt((screen.availHeight/2) - (height/2));
  var windowFeatures = "width=" + width + ",height=" + height + ",status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,left=" + x +",screenX=" + x +",top=" + y + ",screenY=" + y;
  var openWindow = this.open(href + "&#38;width=" + width + "&#38;height=" + height, "Popup", windowFeatures);
}


// fix inputs for IE
// fixes error where IE displays random colored backgrounds for inputs
// we'll just make 'em white as it doesn't support :focus for inputs
// and textareas anyway
function fixInputs()
{
  // grab all textareas
  var textareas = document.getElementsByTagName("textarea");
  for(var i=0; i < textareas.length; i++)
  {
    var t = textareas[i];
    t.style.backgroundColor = "#fff";
  }
  // grab all inputs
  var inputs = document.getElementsByTagName("input");
  for(var x=0; x < inputs.length; x++)
  {
    var input = inputs[x];
    if (input.type == "text") // make sure it is one which is type="text"
    {
      input.style.backgroundColor = "#fff";
    }
  }
}

// added 12-12-03
// used to open outside links in a new window
// Author: Travis Beckham | squidfingers.com
// Modified by Aaron Gustafson
function handleExternalLinks(){
  if (!document.getElementsByTagName) return null;
  var server = document.location.hostname;
  var anchors = document.getElementsByTagName("a");
  var i, href;
  for(i=0; i < anchors.length; i++){
    if(!anchors[i].href) continue;
    href = anchors[i].href;
    if(href.indexOf(server) == -1){ // Href is not a file on my server
      if(href.indexOf("javascript:") == -1){ // Href is not a javascript call
        if(!anchors[i].onclick){ // Href does not have an onclick event
          if(href.indexOf("mailto:") == -1){ // Href is not a mailto:
            if((href.indexOf("http://") != -1) || (href.indexOf("https://") != -1)){ // Href is not relative (for Safari)
              anchors[i].setAttribute("target","_blank");
            }
          }
        }
      }
    }
  }
  return null;
}

// onload
window.onload = function() {
  accessibilizeLinks();
  popPostcards();
  handleExternalLinks();
  if (browser.isIE && !browser.isIEMac)
  {
    fixPng();
    fixInputs();
  }
}

function highlightPostcard(thisNumber)
{
  for (var i = 1; i < 8; i++)
  {
    if (i == thisNumber)
    {
      var postcard = "postcard" + i;
      document.getElementById(postcard).style.backgroundColor = "#ccc";
    } else if (i != thisNumber) {
      var postcard = "postcard" + i;
      document.getElementById(postcard).style.backgroundColor = "transparent";
    }
  }
}

function charAlert(howMany,textField)
{
  if(textField.value.length > howMany)
  { 
  /* must be > 5, not == 5 or else the substring statement on the next line 
  will cause the function to run again if the user dismisses the alert
  by pressing the 'enter' key rather than clicking 'OK'. */ 
    textField.value = textField.value.substring(0,howMany);
	// set field's value equal to first five characters. 
	textField.blur() 
	/* move cursor out of form element 
	to keep it from placing itself at position zero, 
	causing an overwrite of the first character */
	alert("No more text can be entered")	
  }
}

// showMe
// added 8-6-02
// part of showHide
function showMe(what) {
  what = document.getElementById(what);
  what.style.display='inline';
}

// hideMe
// added 8-6-02
// part of showHide
function hideMe(what) {
  what = document.getElementById(what);
  what.style.display='none';
}

// showHide
// added 8-6-02
// used to show/hide layers/spans
function showHide(show,hide){
  var showArray = show.split(",")
  var s = showArray.length
  for(i = 0; i < s; i++) {
  	var imShowing = showArray[i];
	showMe(imShowing);
  }
  var hideArray = hide.split(",")
  var h = hideArray.length
  for(i = 0; i < h; i++) {
  	var imHiding = hideArray[i];
	hideMe(imHiding);
  }
}

// error suppression
//window.onerror = function() { return true; };

//-->
