<!--
var siteAddress = "tarzier.com";
var d = document;

/* POPUP FUNCTIONS */

function popupWindow(url,name,w,h,centered) {
  var screenHeight = 600; // default to 800x600 screen
  var screenWidth  = 800;
  var top = 0, left = 0;
  if (window.screen && window.screen.height && window.screen.height) {
    screenHeight = window.screen.height;
    screenWidth  = window.screen.width;
    }
  screenHeight = screenHeight-40;  // allow room for taskbars, etc.
  screenWidth  = screenWidth-40;
  if ((h == 0) || (screenHeight < h))
    h = screenHeight;
  if ((w == 0) || (screenWidth < w))
    w = screenWidth;
  if (centered) {
    var left = (screen.width - w) / 2;
    var top  = (screen.height - h) / 2;
    }
  var winProps = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width=" + w + ",height=" + h + ",left=" + left + ",top=" + top + "";
  var popupWin = window.open(url,name,winProps);
  if (parseInt(navigator.appVersion) >= 4)
    popupWin.window.focus();
  }

function openInNewWindow(whichLink,whichLinkText) {
  if (openInNewWindow.arguments.length < 2) whichLinkText = "this link";
  if (window.confirm("Would you like to open " + whichLinkText + " in a new browser window, so that the " + siteName + " site can remain open?\n\nIf so, you may need to disable any pop-up blockers you have installed.")) {
    if (!whichLink.oTarget) whichLink.oTarget = whichLink.target;
    whichLink.target = "_blank";
    }
  else {
    if ((whichLink.oTarget) && (whichLink.oTarget != "_blank")) whichLink.target = whichLink.oTarget;
    else whichLink.target = "";
    }
  }

function writeEmailAddress(addressee,subject) {
  var emailAddress = addressee + "@" + siteAddress;
  if (writeEmailAddress.arguments.length < 2) {
    subject = "Inquiry from " + siteAddress;
    }
  document.write("<a href=\"mailto:" + emailAddress + "?subject=" + subject + "\">" + emailAddress + "</a>");
  }

/* MOUSEOVER SCRIPT */

var mouseoverExt   = "_ON";
var mouseoverClass = "mouseover";

function createMouseovers() {
  var i, dotAt, imgFile, imgExt;
  var imgs = getElementsByClass(mouseoverClass,document,'IMG');
  for (i = 0; i < imgs.length; i++) {
    if (imgs[i].className && imgs[i].className == "mouseover") {
      dotAt  = imgs[i].src.lastIndexOf(".");
      if (dotAt > 0) {
        imgFile = imgs[i].src.substr(0,dotAt);
        imgExt  = imgs[i].src.substr(dotAt+1);
        if (imgFile.lastIndexOf(mouseoverExt) == imgFile.length - mouseoverExt.length) {
          // do nothing; image is already on
          }
        else {
          // save original image src and mouseover src to image
          imgs[i].outSrc  = imgs[i].src;
          imgs[i].overSrc = imgFile + mouseoverExt + "." + imgExt;
          // add new mouseover actions
          addEvent(imgs[i],'mouseover',function() {this.src = this.overSrc},false);
          addEvent(imgs[i],'mouseout', function() {this.src = this.outSrc}, false);
          // preload image
          if (!document.preloads)
            document.preloads = new Array();
          else
            var p = document.preloads.length;
          d.preloads[p]     = new Image;
          d.preloads[p].src = imgs[i].overSrc;
          }
        }
      }
    }
  }

/* HELPER FUNCTIONS */

// From http://www.dustindiaz.com/top-ten-javascript
function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp('(^|\\s)'+(searchClass instanceof Array ? searchClass.join('|') : searchClass )+'(\\s|$)');
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className)) {
      classElements[j] = els[i];
      j++;
      }
    }
  return classElements;
  }

// Following two functions from http://www.dustindiaz.com/rock-solid-addevent

function addEvent(obj, type, fn) {
  if (obj == null)
    obj = window;
  if (obj.addEventListener) {
    obj.addEventListener( type, fn, false );
    EventCache.add(obj, type, fn);
    }
  else if (obj.attachEvent) {
    obj["e"+type+fn] = fn;
    obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
    obj.attachEvent( "on"+type, obj[type+fn] );
    EventCache.add(obj, type, fn);
    }
  else {
    obj["on"+type] = obj["e"+type+fn];
    }
  }

var EventCache = function() {
  var listEvents = [];
  return {
    listEvents : listEvents,
    add : function(node, sEventName, fHandler){
      listEvents.push(arguments);
      },
    flush : function() {
      var i, item;
      for(i = listEvents.length - 1; i >= 0; i = i - 1){
        item = listEvents[i];
        if(item[0].removeEventListener){
          item[0].removeEventListener(item[1], item[2], item[3]);
        };
        if(item[1].substring(0, 2) != "on"){
          item[1] = "on" + item[1];
        };
        if (item[0].detachEvent){
          item[0].detachEvent(item[1], item[2]);
          };
        item[0][item[1]] = null;
        };
      }
    };
  } ();

/* ON LOAD EVENTS */
addEvent(window,'load',createMouseovers,false);
addEvent(window,'unload',EventCache.flush);
// -->
