
// This JavaScript file contains functions written by Peter Wright
// Version 1 [ 3rd October 2003 - 09:42 ]

var imageDir="images/";			// path to background image'
var myName="tbus.js";			// name of this file for nesting purposes
var good;

var ePost="bruce." + "lake@trolle" + "ybus.net";

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

// Remember to addd mouse click

var message="WEB Site © Copyright 2003\nDavid Bradley Online\n----------------------------------\n\nCoding is not in the Public Domain       \n\nContact No. +44 1252 704000\n\nwww.trolleybus.net";

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 captionStyle(txt) {
   while (txt.indexOf("{#")>0) {		// replace custom format commands {#?} with <p class="CF?>
      txtP=txt.indexOf("{#");
      txtL=txt.substring(0, txtP);
      txtS=txt.charAt(txtP+2);
      txtR=txt.substring(txtP+4);
      txt=txtL + '<p class="CF' + txtS + '">' + txtR;
   }
   while (txt.indexOf("{/#}")>0) {		// replace custom format end commands {/#} with </p>
      txtP=txt.indexOf("{/#}");
      txtL=txt.substring(0, txtP);
      txtR=txt.substring(txtP+4);
      txt=txtL + '</p>' + txtR;
   }
   return txt;
}

function popBig(filename, winname, description, imageW, imageH, closeParent) {
   if (description.indexOf("|")>0) { var describe = description.split("|"); description=describe[1] }
   description=captionStyle(description);
   nn="";
   nn+='<html><head><title>Bruce Lake Image Library - Picture ' + winname + '</title>';
   nn+='<meta http-equiv="imagetoolbar" content="no">';
   nn+='<meta name="MSSmartTagsPreventParsing" content="TRUE">';
   nn+='<style type="text/css">';
   nn+=' BODY { background-image: url(' + imageDir + '75.gif); margin: 5px; }';
   nn+=' .descriptive { font-family: "Trebuchet MS", sans-serif; font-size: 24px; font-weight: bold; text-align: center; color: #804000; }';
   if (description.indexOf('<h6>')>0) { nn+=' h6 { font-family: Verdana, Arial, sans-serif; font-size: 12pt; font-weight: bold; text-align: justify; color: #804000; margin: 4px 30px 0; }'; }
   if (description.indexOf('class="CFj"')>0) { nn+=' .CFj { font-family: Verdana, Arial, sans-serif; font-size: 12pt; font-weight: bold; text-align: justify; color: #804000; margin: 4px 30px 0; }'; }
   if (description.indexOf('class="CFc"')>0) { nn+=' .CFc { font-family: Verdana, Arial, sans-serif; font-size: 12pt; font-weight: bold; text-align: center; color: #804000; margin: 0 0 0; }'; }
   nn+='</style></head><body><center>';
   nn+='<table border=0 cellpadding=0 cellspacing=0 align="center" width="100%">';
   nn+=' <tr>';
   nn+='  <td align="center"><a href="javascript:window.close()"><img src="' + filename + '" width=' + imageW + ' height=' + imageH + ' border=0 alt=" Click to close window "></a></td>';
   nn+=' </tr>';
   nn+=' <tr valign="middle">';
   nn+='  <td height=50 class="descriptive">' + description + '</td>';
   nn+=' </tr>';
   nn+='</table></center></body></html>';
   window2=window.open("", "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=0,top=0,width=" + (screen.availWidth-10) + ",height=" + (screen.availHeight-30));
   window2.document.open();
   window2.document.write(nn);
   window2.document.close();
   if (closeParent) { parent.window.close() };
   window2.focus()
}

function popUp(filename, winname, description, imageW, imageH) {
   bigURL="popBig('" + filename + "', '" + winname + "', '" + description + "', " + imageW + ", " + imageH + ", ";
   if (description.indexOf("|")>0) { var describe = description.split("|"); description=describe[0] }
   if (navigator.appName=="Opera" || document.layers || (screen.availWidth>=imageW && screen.availHeight>=imageH)) { eval(bigURL+"false)"); return } else { bigURL+= "true)" }
   winH=screen.availHeight-28;			// set popup window height to max available
   winW=screen.availWidth-9;			// set popup window width to max available
   imgH=winH-52;					// calculate maximum image height
   imgW=parseInt(imageW*(imgH/imageH));		// calculate proportional image width
   if (imgW>(winW-8)) {				// if resulting image is too wide
      imgW=winW-8;				// reduce image width
      imgH=parseInt(imageH*(imgW/imageW));		// calculate proportional image height
   }
   nn="";
   nn+='<html><head><title>Bruce Lake Image Library - Picture ' + winname + '</title>';
   nn+='<meta http-equiv="imagetoolbar" content="no">';
   nn+='<meta name="MSSmartTagsPreventParsing" content="TRUE">';
   nn+='<style type="text/css">';
   nn+=' BODY { background-image: url(' + imageDir + '75.gif); margin: 5px; }';
   nn+=' .descriptive { font-family: "Trebuchet MS", sans-serif; font-size: 24px; font-weight: bold; text-align: center; color: #804000; }';
   nn+=' .click { font-family: Arial, sans-serif; font-size: 11px; font-weight: normal; text-align: left; color: #000000; }';
   nn+='</style></head><body><center>';
   nn+='<script language="JavaScript" type="text/javascript" src="' + myName + '"></script>';
   nn+='<table border=0 cellpadding=0 cellspacing=0 align="center" width=' + (winW-14) + '>';
   nn+=' <tr>';
   nn+='  <td height=' + imgH + ' colspan=2 align="center"><a href="javascript:window.close()"><img src="' + filename + '" width=' + imgW + ' height=' + imgH + ' border=0 alt=" Picture ' + winname + ' "></a></td>';
   nn+=' </tr>';
   nn+=' <tr valign="bottom">';
   nn+='  <td width=' + (winW-214) + ' height=40 class="descriptive">' + description + '</td>';
   nn+='  <td width=200 class="click">Click on the image to close this window<br><a href="javascript:' + bigURL + '"><img src="' + imageDir + 'redsq.gif" width=9 height=9 border=0 alt=""></a> &nbsp; See image at maximum resolution</td>';
   nn+=' </tr>';
   nn+='</table></center></body></html>';
   window1=window.open('', '', "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,left=0,top=0,width=" + winW + ",height=" + winH);
   window1.document.open();
   window1.document.write(nn);
   window1.document.close();
   window1.focus()
}

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 += '. &copy; ' + Year + '  Bruce Lake';
  return towrite;
}

function takeYear(theDate) {
  x = theDate.getYear();
  var y = x % 100;
  y += (y < 38) ? 2000 : 1900;
  return y;
}

function popUpold(filename, winname, description, width) {
   nn="";
   nn+='<html><head><title>Bruce Lake Image Library - Picture '+ winname + '</title>';
   nn+='<meta http-equiv="imagetoolbar" content="no">';
   nn+='<meta name="MSSmartTagsPreventParsing" content="TRUE">';
   nn+='</head>';
   nn+='<body background="' + imageDir + '75.gif" topmargin=5 leftmargin=2 rightmargin=2 marginheight=5 marginwidth=2>';
   nn+='<a href="javascript:window.close()"><img src="' + filename + '" border=0 alt=" Click to close window "></a>';
   nn+='<center><font color="#804000" size=5 face="Trebuchet MS">';
   nn+='<p><b>' + description + '</b></p><p>&nbsp;</p></font></center>';
   nn+='</body></html>';
   window2 = window.open("", "", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,left=0,top=0,width="+ width);
   window2.document.open();
   window2.document.write(nn);
   window2.document.close();
   window2.focus()
}

function pagebase() {
   nn=""
   nn+='<br><center><b>';
   nn+='<p>';
   nn+=document.title;
   nn+=' <br>If you wish to comment on the content of this page please <a href="mailto:' + ePost + '?Subject=' + document.title + '">email</a> me';
   nn+=' <br>Site visitors input is always appreciated';
   nn+=' </b></center><br><br><br><font size=1>Page URL: ' + location.toString();
   nn+=lastMod();
   nn+='</font></p>';
   return nn;
}

