// Copyright 2002, David Schachter. ALL RIGHTS RESERVED.

// Contact ds@queernet._REMOVE_THIS_ANTI_SPAM_org for more information.


new_window = 1

// On the bicycle machines at my gym, only one page can be viewed. But on other,
// more capable web browsers, I like to have new pages pop up over the current page
// in a separate window. On my pages, I put a button that sets "new_window" to 0,
// causing new pages to replace the current page, for the gym machines.
//
// The "width" and "height" parameters let me specify the window size when a new
// window is created. I use this so that photos can appear in a trimmed window,
// while other documents can get default window sizes.

function update(new_page, name, width, height) {
  if (new_window == 0) {
    document.location = new_page
    return

  } else {
    if (width == -2) {
      window.open(new_page, name)

    } else {
      options = "resizable=yes"
  
      if (width > 0) {
        options += ",width=" + width + ",height=" + height
      }
  
      window.open(new_page, name, options)
    }
  }
}

// This function writes the button to set the global variable 'new_window' for
// the gym machine and other restricted function devices.

function writeGymMachineButton() {
  message = '<small><small>' +
              'If the links above don\'t work,' +
              ' <input type=button value="click" onClick="javascript:new_window=0">' +
              ' and try again.<br>\n' +
              '<small>' +
                '(You\'ll have to click each time you see this page,' +
                ' since I\'m not doing cookies.)' +
              '</small>' +
            '</small></small>'

  document.write(message)
}


// Given a number between 0 and 15 (inclusive), return the hex digit 0-9, a-f.
// NO ERROR CHECKING FOR numbers outside the valid range

function giveHex(number) {
  return "0123456789abcdef".substr(number, 1)
}


// This function hides my email address (perhaps) from spam harvesters.
// DON'T use this function, 'cause it probably doesn't hide the address well enough.

function writeMailToLink(prefix, middle, suffix) {
  username     = 'ds'
  domainFront  = 'queernet'
  domainSuffix = 'org'

  message = prefix +
            '<a href="mailto:' +
              username +
              '@' +
              domainFront +
              '.' +
              domainSuffix +
              '">' +
            middle +
            '</a>' +
            suffix

  document.write(message)
}


// This function resets the document location to do a mail link.
// The intent is to hide my email address from spam harvesters.
// Will it work? We'll find out...

function doMailTo(subject) {
  username     = 'ds'
  domainFront  = 'queernet'
  domainSuffix = 'org'

  url = 'mailto:' + username + '@' + domainFront + '.' + domainSuffix + '?Subject=' +
        ((subject == null) ? 'Comment on ' + document.location : subject)
        
  document.location = url
}
