
// This JavaScript file contains functions written by Peter Wright
// version 9 [ 6 August 2005 - 07:30 ]

var imageDir="images/";			// path to background image and 'red-square'
var myName="online.js";			// name of this file for nesting purposes
var good;

var ePost="chiefe" + "ngineer@trolley" + "bus.net";

// -------------------------------

// Remember to addd mouse click

var message="Web Pages and Images\nŠ2006 Simon Smiler\n----------------------------------\n\nSimon may be contacted on       \n+44 1252 706933";

function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;

// -------------------------------

function pagebase() {
rdbol = document.title .substring (22 ,99)
   nn=""
   nn+='<br><center>';
   nn+='<p class="mailme">';
   nn+=document.title;
   nn+='<br>If you wish to comment on the content of this page please drop me an <a href="mailto:' + ePost + '?Subject=EATM 2006">email</a>';
   nn+='<br>Site visitors input is always appreciated<br>';
   nn+='<a href="http://validator.w3.org/check/referer" target="_w3c" onmouseover="self.status=\'This WEB page has been designed to work under all operating sytems and with all WEB Browsers\'; return true" onmouseout="self.status=\'\'; return true"><img src="logos/w3c-401.gif" alt=" An interoperable WEB page with valid HTML 4.01 " border="0" height="31" width="93" vspace="3"></a>';
   nn+='<a href="http://jigsaw.w3.org/css-validator/check/referer" target="_w3c" onmouseover="self.status=\'Valid CSS\'; return true" onmouseout="self.status=\'\'; return true"><img src="logos/w3c-css.gif" alt=" Valid CSS " border="0" height="31" width="93" vspace="3"></a>';
   nn+='<a href="http://www.anybrowser.org/campaign/index.html" target="_new" onmouseover="self.status=\'Viewable With Any Browser\'; return true" onmouseout="self.status=\'\'; return true"><img src="logos/anybrowser.jpg" alt=" Viewable With Any Browser " border="0" height="32" width="96" vspace="3" hspace="10"></a>';
   nn+='<a href="javascript:emailPage()" onmouseover="self.status=\'Have a nice day\'; return true" onmouseout="self.status=\'\'; return true"><img src="logos/tell-a-friend.gif" alt=" Feature sends an email to your friend " border="0" height="32" width="130" vspace="3" hspace="1"></a>';
   nn+='<br>Page URL: ' + location.toString();
   nn+=lastMod();
   nn+='</p><br><br>';
   return nn;
}

function lastMod() {
  var x = new Date (document.lastModified);
  Modif = new Date(x.toGMTString());
  Year = takeYear(Modif);
  Month = Modif.getMonth();
  Day = Modif.getDate();
  Mod = (Date.UTC(Year,Month,Day,0,0,0))/86400000;
  x = new Date();
  today = new Date(x.toGMTString());
  Year2 = takeYear(today);
  Month2 = today.getMonth();
  Day2 = today.getDate();
  now = (Date.UTC(Year2,Month2,Day2,0,0,0))/86400000;
  daysago = now - Mod;
  if (daysago < 0) return '';
  unit = 'days';
  if (daysago > 730)
  {
  daysago = Math.round(daysago/365);
  unit = 'years';
  }
  else if (daysago > 60)
  {
  daysago = Math.round(daysago/30);
  unit = 'months';
  }
  else if (daysago > 14)
  {
  daysago = Math.round(daysago/7);
  unit = 'weeks'
  }
  towrite = '<br>Last updated ';
  if (daysago == 0) towrite += 'today';
  else if (daysago == 1) towrite += 'yesterday';
  else towrite += daysago + ' ' + unit + ' ago';
  towrite += '. &nbsp; All pictures &copy;' + Year + ' Simon Smiler';
  return towrite;
}

function takeYear(theDate) {
  y = theDate.getYear();
  y += (y < 1900) ? 1900 : 0;
  return y;
}

function checkEmailAddress(field) {
// the following expression must be all on one line...
var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail) {
good = true;
}
else {
alert('Please enter a valid e-mail address.');
field.focus();
field.select();
good = false;
   }
}
u = window.location;
s="  "
m = "David Bradley Online";
function mailThisUrl() {
good = false
checkEmailAddress(document.eMailer.address);
if (good) {
// the following expression must be all on one line...
window.location = "mailto:"+document.eMailer.address.value+"?subject="+m+"&body="+"I think you will be interested in this web page showing scenes of trolleybuses on route 630: http://www.trolleybus.net/654.htm"+"   "+s;
   }
}

function emailPage(){
document.location = 'mailto:?subject=EATM 2006 &bcc=xmas@cyberpictures.net&body=Hello, %0D%0DI found this page on the Internet - EATM September Trolley Weekend - and thought it would be of interest to you: ' + document.location + ' %0D%0DThe site is a collection of images of that day.';
   }

function eLink( text, who, where, why) {
   nn="";
   nn+='<a href="mailto:' + who + '@' + where;
   if (why!="" && why!=null) { nn+='?Subject=' + why }
   nn+='">' + text + '</a>';
   return nn;
}

function meLink( text, subject) {
   nn="";
   nn+='<a href="mailto:' + ePost;
   if (subject!="" && subject!=null) { nn+='?Subject=' + subject }
   nn+='">' + text + '</a>';
   return nn;
}

function dateNarrative() {
   var xx="th"
   mydate = new Date();
   myday = mydate.getDay();
   myweekday= mydate.getDate();
   mymonth = mydate.getMonth();
   year = mydate.getYear();
   year+=(year<1900) ? 1900 : 0;
   if (myweekday==1 || myweekday==21 || myweekday==31) { xx="st" }
   if (myweekday==2 || myweekday==22) { xx="nd" }
   if (myweekday==3 || myweekday==23) { xx="rd" }
   arday = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
   armonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
   return arday[myday] + ", " + myweekday + xx + " " + armonth[mymonth] + " " + year;
}


function javahere() {
   if (navigator.javaEnabled()) {
      return 1
  } else {
      return 2
  }
}

function verFlash(vHi) {
      if (navigator.appName.indexOf('Microsoft') >=0) {
         for (fv=vHi; fv>0; fv--) {
            if (eval("activeXDetect('ShockwaveFlash.ShockwaveFlash."+fv+"')")) return fv
         }
      } else {
         for (pn=0; pn<navigator.plugins.length; pn++) {
            if (navigator.plugins[pn].name.indexOf('Flash')>=0) {
               for (fv=vHi; fv>0; fv--) {
                  if (navigator.plugins[pn].description.indexOf(fv+'.')>=0) return fv
               }
            }
         }
      }
      return '0';
}

