var mydate=new Date()
var year=mydate.getYear()
if (year<200) year=1900+year
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function todayText() {
    document.writeln("<Center><font class=todayText>"+dayarray[day]+", "+daym+" "+montharray[month]+" "+year+"</font></center>")
}


function dateText() {
    var today=new Date();
    var month=today.getMonth()
    var months=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")   
    var thisDate=today.getDate()+months[month]
    //alert(thisDate);

    switch (thisDate) {
    case "1Jan":  text="Happy New Year!"; break;
    case "1Mar":  text="During March 1966 the Austin Countryman & Morris Traveller were launched at Geneva Motor Show"; break;
    case "19Jun": text="On this day in 1974 the last Vanden Plas Princess 1300 rolled off the production line"; break;
    case "15Aug": text="On this day in 1962 the Morris 1100 was launched"; break;
    case "6Sep":  text="On this day in 1963 the Austin 1100 was launched"; break;
    case "1Oct":  text="On this day in 1969 the Austin/Morris 1300 GT was launched."; break;
    case "2Oct":  text="Alec Issigonis passed away on this day in 1988."; break;
    case "14Oct": text="On this day in 1971 the Austin 1300 Mk 3 was launched."; break;
    case "18Nov": text="Alec Issigonis was born this day in Izmir in 1906."; break;
    case "22Nov": text="On this day in 1975 BL announced it would be selling remaining ADO16 body shells"; break;
    case "21Dec": text="On this day in 1967 the Morris 1300 was launched."; break;
    case "24Dec": text="It's Christmas Eve!"; break;
    case "25Dec": text="Merry Christmas."; break;
    default: text="ADO16: Without a doubt Britain’s best selling car between 1963 - 1974"; break;
}
document.writeln("<Center><font class=dateText>" + text + "</font></Center>")
}

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

var pageID = new Array(
    "1100club",
    "1800",
    "aboutado16",
    "ado16convind",
    "ado16cor",
    "ado16history",
    "ado16kitcar",
    "ado16mystery",
    "ado16proto",
    "ado16van",
    "ado22",
    "ado74",
    "aerodynamic",
    "alexander",
    "allegro",
    "americaind",
    "americanaus11",
    "austcut",
    "austinamerica",
    "ausindex",
    "aussalesfigs",
    "before",
    "bon835k",
    "britbstsellind",
    "bro",
    "broadspeed",
    "buildbritbstsell",
    "buying",
    "cars",
    "cavallo",
    "changes",
    "chile",
    "cjones",
    "Colorchrt",
    "commer",
    "copcars",
    "cortina",
    "crayfordcon",
    "crayfordestat",
    "dashboards",
    "dealermat",
    "dervan",
    "downton",
    "dyngrp",
    "events",
    "fea1300countryman",
    "feaaustin130gt",
    "feaaustinamerica",
    "feaaustinapache",
    "feacars",
    "feamg11mk1",
    "feamor1300",
    "feamormk1",
    "fearilkes13",
    "featravmk1",
    "feavp13",
    "feawols11mk1",
    "fixyourcar",
    "fleet",
    "ght397k",
    "histofado16",
    "hustler",
    "huv390k",
    "insurance",
    "invash",
    "italy",
    "itb",
    "jensenado16",
    "kcind",
    "kcrebuild2000",
    "kcrebuild2003",
    "kcrespray",
    "khall",
    "lookalikes",
    "magenta",
    "makes",
    "mangoletsi",
    "metro",
    "mgduotone",
    "mgprincess",
    "mgsportssed",
    "morris1100s",
    "morris1500",
    "mxc222h",
    "natral",
    "natral02",
    "natral03",
    "natral04",
    "navajo",
    "newwar",
    "nwe655k",
    "onehitwond",
    "ourado16",
    "overseaind",
    "owning",
    "price",
    "pgaustin",
    "pgmg",
    "pgmorris",
    "pgriley",
    "pgvanden",
    "pgwolseley",
    "presspics",
    "productionfigs",
    "psrv",
    "pubmat",
    "rallycars",
    "ranger",
    "reasonswhy",
    "report",
    "resind",
    "resremframes",
    "resrps",
    "rileyduotone",
    "rjv",
    "sechandwar",
    "serv3k",
    "serv6k",
    "serv12k",
    "serv24k",
    "servind",
    "servother",
    "servweek",
    "southafrica",
    "spain",
    "speedwell11",
    "speedwell13",
    "spotted",
    "srb420f",
    "srv5",
    "srvind",
    "supremo",
    "tl62",
    "tl63",
    "tl64",
    "tl65",
    "tl66",
    "tl67",
    "tl68",
    "tl69",
    "tl70",
    "tl71",
    "tl72",
    "tl73",
    "tl74",
    "trivia",
    "udt",
    "updates",
    "vidsads",
    "vidsfilms",
    "vidsothers",
    "vidssafety",
    "viva",
    "wcs03",
    "wcs04",
    "wcs05",
    "wcsind",
    "whybc",
    "whycjr",
    "whydb",
    "whydb2",
    "whyem",
    "whyhg",
    "whyka",
    "whykn",
    "whymh",
    "whymt",
    "whynp",
    "whypw",
    "whytm",
    "wolsduotone",
    "writers",
    "wtps",
    "xwb157g"
     );


function rnd() 
{
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
}


function rand(Ndx)

{
        return Math.ceil(rnd()*(Ndx-1));
}


function randPage(curPage)

{
    curPage = extract(curPage);
    newPno=rand(pageID.length);
    do {newPno=rand(pageID.length);}
    while (pageID[newPno] == undefined )
    newPage = pageID[newPno]
    if (newPage == undefined) {newPage = curPage}
    self.parent.main.location.href = newPage + '.shtml';
}

function extract(what) {
    if (what.indexOf('/') > -1)
        answer = what.substring(what.lastIndexOf('/')+1,what.length);
    else
        answer = what.substring(what.lastIndexOf('€€')+1,what.length);
    answer = answer.substring(answer,answer.length-6)	
	
    return answer
}

function contactMe(who, where) {
    prefix = '<A class=tbar HR' + 'EF="ma' + 'ilto:'
    midfix = who + '&#64' + where
    suffix = '">Email</A>'
    document.write(prefix+midfix+suffix)
}

function comments() {
    window.location = "mailto:webmaster@ado16.info"+"?subject=Comments on www.ado16.info" + "&body=I have something I'd like to comment on: "+document.title+" "+window.location;
}

function reportError() {
    window.location = "mailto:webmaster@ado16.info"+"?subject=Error on www.ado16.info" + "&body=I have found an error on: "+document.title+" "+window.location;
}

function coverStar() {
    window.location = "mailto:register@ado16.info"+"?subject=Web site cover star" + "&body=Please find below my web site cover star submission: "+document.title+" "+window.location;
}

///// Cookie code (borrowed & adapted from Duncan Crombie) /////

var cookee = document.cookie;

function getCookie(name) { // use: getCookie("name");
    var index = cookee.indexOf(name + "=");
    if (index == -1) return null;
    index = cookee.indexOf("=", index) + 1;
    var endstr = cookee.indexOf(";", index);
    if (endstr == -1) endstr = cookee.length;
    return unescape(cookee.substring(index, endstr));
  }


function setCookie(name, value) { 
    var cToday = new Date();
    var cExpiry = new Date(cToday.getTime() + 1 * 24 * 60 * 60 * 1000);
    if (value != null && value != "") {
    document.cookie=name + "=" + escape(value) + "; expires=" + cExpiry.toGMTString();
    cookee = document.cookie;}
  }


function deleteCookie(cookieName) {
    var cToday = new Date();
    var cExpired = new Date(cToday.getTime() - 48 * 60 * 60 * 1000);
    document.cookie=cookieName + "=null; expires=" + cExpired.toGMTString();
    cookee = document.cookie;
  }

function welcome() {
    if (getCookie("beenb4") == null) {
    document.write("Welcome")
    setCookie ("beenb4","true") }
    else {document.write("Welcome back") }
  }

function lastModd()

{

      //lastmod = self.parent.main.document.lastModified     // get string of last modified date
      lastmod = document.lastModified     // get string of last modified date
      lastmoddate = Date.parse(lastmod)   // convert modified string to date
      if(lastmoddate == 0){               // unknown date (or January 1, 1970 GMT)
         lmText = ""
      } else {
        d = new Date(lastmoddate);
        lmday=dayarray[d.getDay()];
        lmmon=montharray[d.getMonth()];
        lmdte=d.getDate(); lmyr=d.getFullYear();
        lmh=d.getHours(); if (lmh < 10) {lmh = "0"+lmh}
	lmm=d.getMinutes(); if (lmm < 10) {lmm = "0"+lmm}
        lmText = "<P CLASS=comments>This page was last modified on " + lmday + ", " + lmdte + " " + lmmon + " " + lmyr + " at " + lmh + ":" + lmm + "</P>";
      }

	document.write(lmText)
}

function pageTurner(newPage)

{
    switch (newPage)
    {
    case 0: if (pageno > 1) {pageno = pageno - 1; break;} else {break;}
    case 99: if (pageno < maxpage) {pageno = pageno + 1; break;} else {break;} 
    default: pageno = newPage;
    }
    document.brochure.src = bropage[pageno].src
}

function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

//=============================================================================
// Window Object
//=============================================================================

function Window(el) {

  var i, mapList, mapName;

  // Get window components.

  this.frame           = el;
  this.titleBar        = winFindByClassName(el, "titleBar");
  this.titleBarText    = winFindByClassName(el, "titleBarText");
  this.titleBarButtons = winFindByClassName(el, "titleBarButtons");
  this.clientArea      = winFindByClassName(el, "clientArea");

  // Find matching button image map.

  mapName = this.titleBarButtons.useMap.substr(1);
  mapList = document.getElementsByTagName("MAP");
  for (i = 0; i < mapList.length; i++)
    if (mapList[i].name == mapName)
      this.titleBarMap = mapList[i];

  // Save colors.

  this.activeFrameBackgroundColor  = this.frame.style.backgroundColor;
  this.activeFrameBorderColor      = this.frame.style.borderColor;
  this.activeTitleBarColor         = this.titleBar.style.backgroundColor;
  this.activeTitleTextColor        = this.titleBar.style.color;
  this.activeClientAreaBorderColor = this.clientArea.style.borderColor;
  if (browser.isIE)
    this.activeClientAreaScrollbarColor = this.clientArea.style.scrollbarBaseColor;

  // Save images.

  this.activeButtonsImage   = this.titleBarButtons.src;
  this.inactiveButtonsImage = this.titleBarButtons.longDesc;

  // Set flags.

  this.isOpen      = false;
  this.isMinimized = false;

  // Set methods.

  this.open       = winOpen;
  this.close      = winClose;
  this.minimize   = winMinimize;
  this.restore    = winRestore;
  this.makeActive = winMakeActive;

  // Set up event handling.

  this.frame.parentWindow = this;
  this.frame.onmousemove  = winResizeCursorSet;
  this.frame.onmouseout   = winResizeCursorRestore;
  this.frame.onmousedown  = winResizeDragStart;

  this.titleBar.parentWindow = this;
  this.titleBar.onmousedown  = winMoveDragStart;

  this.clientArea.parentWindow = this;
  this.clientArea.onclick      = winClientAreaClick;

  for (i = 0; i < this.titleBarMap.childNodes.length; i++)
    if (this.titleBarMap.childNodes[i].tagName == "AREA")
      this.titleBarMap.childNodes[i].parentWindow = this;

  // Calculate the minimum width and height values for resizing
  // and fix any initial display problems.

  var initLt, initWd, w, dw;

  // Save the inital frame width and position, then reposition
  // the window.

  initLt = this.frame.style.left;
  initWd = parseInt(this.frame.style.width);
  this.frame.style.left = -this.titleBarText.offsetWidth + "px";

  // For IE, start calculating the value to use when setting
  // the client area width based on the frame width.

  if (browser.isIE) {
    this.titleBarText.style.display = "none";
    w = this.clientArea.offsetWidth;
    this.widthDiff = this.frame.offsetWidth - w;
    this.clientArea.style.width = w + "px";
    dw = this.clientArea.offsetWidth - w;
    w -= dw;     
    this.widthDiff += dw;
    this.titleBarText.style.display = "";
  }

  // Find the difference between the frame's style and offset
  // widths. For IE, adjust the client area/frame width
  // difference accordingly.

  w = this.frame.offsetWidth;
  this.frame.style.width = w + "px";
  dw = this.frame.offsetWidth - w;
  w -= dw;     
  this.frame.style.width = w + "px";
  if (browser.isIE)
    this.widthDiff -= dw;

  // Find the minimum width for resize.

  this.isOpen = true;  // Flag as open so minimize call will work.
  this.minimize();
  // Get the minimum width.
  if (browser.isNS && browser.version >= 1.2)
    // For later versions of Gecko.
    this.minimumWidth = this.frame.offsetWidth;
  else
    // For all others.
    this.minimumWidth = this.frame.offsetWidth - dw;

  // Find the frame width at which or below the title bar text will
  // need to be clipped.

  this.titleBarText.style.width = "";
  this.clipTextMinimumWidth = this.frame.offsetWidth - dw;

  // Set the minimum height.

  this.minimumHeight = 1;

  // Restore window. For IE, set client area width.

  this.restore();
  this.isOpen = false;  // Reset flag.
  initWd = Math.max(initWd, this.minimumWidth);
  this.frame.style.width = initWd + "px";
  if (browser.isIE)
    this.clientArea.style.width = (initWd - this.widthDiff) + "px";

  // Clip the title bar text if needed.

  if (this.clipTextMinimumWidth >= this.minimumWidth)
    this.titleBarText.style.width = (winCtrl.minimizedTextWidth + initWd - this.minimumWidth) + "px";

  // Restore the window to its original position.

  this.frame.style.left = initLt;
}

//=============================================================================
// Window Methods
//=============================================================================

function winOpen() {

  if (this.isOpen)
    return;

  // Restore the window and make it visible.

  this.makeActive();
  this.isOpen = true;
  if (this.isMinimized)
    this.restore();
  this.frame.style.visibility = "visible";
}

function winClose() {

  // Hide the window.

  this.frame.style.visibility = "hidden";
  this.isOpen = false;
}

function winMinimize() {

  if (!this.isOpen || this.isMinimized)
    return;

  this.makeActive();

  // Save current frame and title bar text widths.

  this.restoreFrameWidth = this.frame.style.width;
  this.restoreTextWidth = this.titleBarText.style.width;

  // Disable client area display.

  this.clientArea.style.display = "none";

  // Minimize frame and title bar text widths.

  if (this.minimumWidth)
    this.frame.style.width = this.minimumWidth + "px";
  else
    this.frame.style.width = "";
  this.titleBarText.style.width = winCtrl.minimizedTextWidth + "px";

  this.isMinimized = true;
}

function winRestore() {

  if (!this.isOpen || !this.isMinimized)
    return;

  this.makeActive();

  // Enable client area display.

  this.clientArea.style.display = "";

  // Restore frame and title bar text widths.

  this.frame.style.width = this.restoreFrameWidth;
  this.titleBarText.style.width = this.restoreTextWidth;

  this.isMinimized = false;
}

function winMakeActive() {

  if (winCtrl.active == this)
    return;

  // Inactivate the currently active window.

  if (winCtrl.active) {
    winCtrl.active.frame.style.backgroundColor    = winCtrl.inactiveFrameBackgroundColor;
    winCtrl.active.frame.style.borderColor        = winCtrl.inactiveFrameBorderColor;
    winCtrl.active.titleBar.style.backgroundColor = winCtrl.inactiveTitleBarColor;
    winCtrl.active.titleBar.style.color           = winCtrl.inactiveTitleTextColor;
    winCtrl.active.clientArea.style.borderColor   = winCtrl.inactiveClientAreaBorderColor;
    if (browser.isIE)
      winCtrl.active.clientArea.style.scrollbarBaseColor = winCtrl.inactiveClientAreaScrollbarColor;
    if (browser.isNS && browser.version < 6.1)
      winCtrl.active.clientArea.style.overflow = "hidden";
    if (winCtrl.active.inactiveButtonsImage)
      winCtrl.active.titleBarButtons.src = winCtrl.active.inactiveButtonsImage;
  }

  // Activate this window.

  this.frame.style.backgroundColor    = this.activeFrameBackgroundColor;
  this.frame.style.borderColor        = this.activeFrameBorderColor;
  this.titleBar.style.backgroundColor = this.activeTitleBarColor;
  this.titleBar.style.color           = this.activeTitleTextColor;
  this.clientArea.style.borderColor   = this.activeClientAreaBorderColor;
  if (browser.isIE)
    this.clientArea.style.scrollbarBaseColor = this.activeClientAreaScrollbarColor;
  if (browser.isNS && browser.version < 6.1)
    this.clientArea.style.overflow = "auto";
  if (this.inactiveButtonsImage)
    this.titleBarButtons.src = this.activeButtonsImage;
  this.frame.style.zIndex = ++winCtrl.maxzIndex;
  winCtrl.active = this;
}

//=============================================================================
// Event handlers.
//=============================================================================

function winClientAreaClick(event) {

  // Make this window the active one.

  this.parentWindow.makeActive();
}

//-----------------------------------------------------------------------------
// Window dragging.
//-----------------------------------------------------------------------------

function winMoveDragStart(event) {

  var target;
  var x, y;

  if (browser.isIE)
    target = window.event.srcElement.tagName;
  if (browser.isNS)
    target = event.target.tagName;

  if (target == "AREA")
    return;

  this.parentWindow.makeActive();

  // Get cursor offset from window frame.

  if (browser.isIE) {
    x = window.event.x;
    y = window.event.y;
  }
  if (browser.isNS) {
    x = event.pageX;
    y = event.pageY;
  }
  winCtrl.xOffset = winCtrl.active.frame.offsetLeft - x;
  winCtrl.yOffset = winCtrl.active.frame.offsetTop  - y;

  // Set document to capture mousemove and mouseup events.

  if (browser.isIE) {
    document.onmousemove = winMoveDragGo;
    document.onmouseup   = winMoveDragStop;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", winMoveDragGo,   true);
    document.addEventListener("mouseup",   winMoveDragStop, true);
    event.preventDefault();
  }

  winCtrl.inMoveDrag = true;
}

function winMoveDragGo(event) {

  var x, y;

  if (!winCtrl.inMoveDrag)
    return;

  // Get cursor position.

  if (browser.isIE) {
    x = window.event.x;
    y = window.event.y;
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    x = event.pageX;
    y = event.pageY;
    event.preventDefault();
  }

  // Move window frame based on offset from cursor.

  winCtrl.active.frame.style.left = (x + winCtrl.xOffset) + "px";
  winCtrl.active.frame.style.top  = (y + winCtrl.yOffset) + "px";
}

function winMoveDragStop(event) {

  winCtrl.inMoveDrag = false;

  // Remove mousemove and mouseup event captures on document.

  if (browser.isIE) {
    document.onmousemove = null;
    document.onmouseup   = null;
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", winMoveDragGo,   true);
    document.removeEventListener("mouseup",   winMoveDragStop, true);
  }
}

//-----------------------------------------------------------------------------
// Window resizing.
//-----------------------------------------------------------------------------

function winResizeCursorSet(event) {

  var target;
  var xOff, yOff;

  if (this.parentWindow.isMinimized || winCtrl.inResizeDrag)
    return;

  // If not on window frame, restore cursor and exit.

  if (browser.isIE)
    target = window.event.srcElement;
  if (browser.isNS)
    target = event.target;
  if (target != this.parentWindow.frame)
    return;

  // Find resize direction.

  if (browser.isIE) {
    xOff = window.event.offsetX;
    yOff = window.event.offsetY;
  }
  if (browser.isNS) {
    xOff = event.layerX;
    yOff = event.layerY;
  }
  winCtrl.resizeDirection = ""
  if (yOff <= winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "n";
  else if (yOff >= this.parentWindow.frame.offsetHeight - winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "s";
  if (xOff <= winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "w";
  else if (xOff >= this.parentWindow.frame.offsetWidth - winCtrl.resizeCornerSize)
    winCtrl.resizeDirection += "e";

  // If not on window edge, restore cursor and exit.

  if (winCtrl.resizeDirection == "") {
    this.onmouseout(event);
    return;
  }

  // Change cursor.

  if (browser.isIE)
    document.body.style.cursor = winCtrl.resizeDirection + "-resize";
  if (browser.isNS)
    this.parentWindow.frame.style.cursor = winCtrl.resizeDirection + "-resize";
}

function winResizeCursorRestore(event) {

  if (winCtrl.inResizeDrag)
    return;

  // Restore cursor.

  if (browser.isIE)
    document.body.style.cursor = "";
  if (browser.isNS)
    this.parentWindow.frame.style.cursor = "";
}

function winResizeDragStart(event) {

  var target;

  // Make sure the event is on the window frame.

  if (browser.isIE)
    target = window.event.srcElement;
  if (browser.isNS)
    target = event.target;
  if (target != this.parentWindow.frame)
    return;

  this.parentWindow.makeActive();

  if (this.parentWindow.isMinimized)
    return;

  // Save cursor position.

  if (browser.isIE) {
    winCtrl.xPosition = window.event.x;
    winCtrl.yPosition = window.event.y;
  }
  if (browser.isNS) {
    winCtrl.xPosition = event.pageX;
    winCtrl.yPosition = event.pageY;
  }

  // Save window frame position and current window size.

  winCtrl.oldLeft   = parseInt(this.parentWindow.frame.style.left,  10);
  winCtrl.oldTop    = parseInt(this.parentWindow.frame.style.top,   10);
  winCtrl.oldWidth  = parseInt(this.parentWindow.frame.style.width, 10);
  winCtrl.oldHeight = parseInt(this.parentWindow.clientArea.style.height, 10);

  // Set document to capture mousemove and mouseup events.

  if (browser.isIE) {
    document.onmousemove = winResizeDragGo;
    document.onmouseup   = winResizeDragStop;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", winResizeDragGo,   true);
    document.addEventListener("mouseup"  , winResizeDragStop, true);
    event.preventDefault();
  }

  winCtrl.inResizeDrag = true;
}

function winResizeDragGo(event) {

 var north, south, east, west;
 var dx, dy;
 var w, h;

  if (!winCtrl.inResizeDrag)
    return;

  // Set direction flags based on original resize direction.

  north = false;
  south = false;
  east  = false;
  west  = false;
  if (winCtrl.resizeDirection.charAt(0) == "n")
    north = true;
  if (winCtrl.resizeDirection.charAt(0) == "s")
    south = true;
  if (winCtrl.resizeDirection.charAt(0) == "e" || winCtrl.resizeDirection.charAt(1) == "e")
    east = true;
  if (winCtrl.resizeDirection.charAt(0) == "w" || winCtrl.resizeDirection.charAt(1) == "w")
    west = true;

  // Find change in cursor position.

  if (browser.isIE) {
    dx = window.event.x - winCtrl.xPosition;
    dy = window.event.y - winCtrl.yPosition;
  }
  if (browser.isNS) {
    dx = event.pageX - winCtrl.xPosition;
    dy = event.pageY - winCtrl.yPosition;
  }

  // If resizing north or west, reverse corresponding amount.

  if (west)
    dx = -dx;
  if (north)
    dy = -dy;

  // Check new size.

  w = winCtrl.oldWidth  + dx;
  h = winCtrl.oldHeight + dy;
  if (w <= winCtrl.active.minimumWidth) {
    w = winCtrl.active.minimumWidth;
    dx = w - winCtrl.oldWidth;
  }
  if (h <= winCtrl.active.minimumHeight) {
    h = winCtrl.active.minimumHeight;
    dy = h - winCtrl.oldHeight;
  }

  // Resize the window. For IE, keep client area and frame widths in synch.

  if (east || west) {
    winCtrl.active.frame.style.width = w + "px";
    if (browser.isIE)
      winCtrl.active.clientArea.style.width = (w - winCtrl.active.widthDiff) + "px";
  }
  if (north || south)
    winCtrl.active.clientArea.style.height = h + "px";

  // Clip the title bar text, if necessary.

  if (east || west) {
    if (w < winCtrl.active.clipTextMinimumWidth)
      winCtrl.active.titleBarText.style.width = (winCtrl.minimizedTextWidth + w - winCtrl.active.minimumWidth) + "px";
    else
      winCtrl.active.titleBarText.style.width = "";
  }

  // For a north or west resize, move the window.

  if (west)
    winCtrl.active.frame.style.left = (winCtrl.oldLeft - dx) + "px";
  if (north)
    winCtrl.active.frame.style.top  = (winCtrl.oldTop  - dy) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function winResizeDragStop(event) {

  winCtrl.inResizeDrag = false;

  // Remove mousemove and mouseup event captures on document.

  if (browser.isIE) {
    document.onmousemove = null;
    document.onmouseup   = null;
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", winResizeDragGo,   true);
    document.removeEventListener("mouseup"  , winResizeDragStop, true);
  }
}

//=============================================================================
// Utility functions.
//=============================================================================

function winFindByClassName(el, className) {

  var i, tmp;

  if (el.className == className)
    return el;

  // Search for a descendant element assigned the given class.

  for (i = 0; i < el.childNodes.length; i++) {
    tmp = winFindByClassName(el.childNodes[i], className);
    if (tmp != null)
      return tmp;
  }

  return null;
}

//=============================================================================
// Initialization code.
//=============================================================================

var winList = new Array();
var winCtrl = new Object();

function winInit() {

  var elList;

  // Initialize window control object.

  winCtrl.maxzIndex                        =   0;
  winCtrl.resizeCornerSize                 =  16;
  winCtrl.minimizedTextWidth               = 100;
  winCtrl.inactiveFrameBackgroundColor     = "#c0c0c0";
  winCtrl.inactiveFrameBorderColor         = "#f0f0f0 #505050 #404040 #e0e0e0";
  winCtrl.inactiveTitleBarColor            = "#808080";
  winCtrl.inactiveTitleTextColor           = "#c0c0c0";
  winCtrl.inactiveClientAreaBorderColor    = "#404040 #e0e0e0 #f0f0f0 #505050";
  winCtrl.inactiveClientAreaScrollbarColor = "";
  winCtrl.inMoveDrag                       = false;
  winCtrl.inResizeDrag                     = false;

  // Initialize windows and build list.

  elList = document.getElementsByTagName("DIV");
  for (var i = 0; i < elList.length; i++)
    if (elList[i].className == "window")
      winList[elList[i].id] = new Window(elList[i]);
}

window.onload = winInit;  // run initialization code after page loads.

function tyres(){
win2=window.open("videos/tyres.html","","width=420,height=400")
win2.creator=self
}

function kyd2(){
win3=window.open("videos/kyd2.html","","width=420,height=400")
win3.creator=self
}

function kyd(){
win4=window.open("videos/kyd.html","","width=420,height=400")
win4.creator=self
}

function pelican(){
win5=window.open("videos/pelican.html","","width=420,height=400")
win5.creator=self
}

function lateBus(){
win6=window.open("videos/late_bus.html","","width=420,height=400")
win6.creator=self
}

function mrsBlunders(){
win7=window.open("videos/mrs_blunders.html","","width=420,height=400")
win7.creator=self
}

function mrBlunders(){
win8=window.open("videos/mr_blunders.html","","width=420,height=400")
win8.creator=self
}

function billyBlunders(){
win9=window.open("videos/billy_blunders.html","","width=420,height=400")
win9.creator=self
}

function ad1(){
win10=window.open("videos/ad1.html","","width=420,height=400")
win10.creator=self
}

function ad2(){
win11=window.open("videos/ad2.html","","width=420,height=400")
win11.creator=self
}

function ad3(){
win12=window.open("videos/ad3.html","","width=420,height=400")
win12.creator=self
}

function ad4(){
win13=window.open("videos/ad4.html","","width=420,height=400")
win13.creator=self
}

function ad5(){
win14=window.open("videos/ad5.html","","width=420,height=400")
win14.creator=self
}

function ad6(){
win15=window.open("videos/ad6.html","","width=420,height=400")
win15.creator=self
}

function ad7(){
win16=window.open("videos/ad7.html","","width=420,height=400")
win16.creator=self
}

function changePage(tabID) {
  switch(tabID) {
  //History & Development//
  case "Ado74": pageName="ado74.php"; break;   
  case "BritainsBest": pageName="britains_best_seller.shtml"; break;   
  case "BuildingBritains": pageName="building_britains_best_seller.shtml"; break;   
  case "Commercial": pageName="ado16_van.shtml"; break;   
  case "History": pageName="ado16_history.shtml"; break;   
  case "IfAmerican": pageName="american_market.shtml"; break;   
  case "IfAustralian": pageName="australian_market.shtml"; break;   
  case "IfChilean": pageName="chilean_market.shtml"; break;   
  case "IfItalian": pageName="italian_market.shtml"; break;   
  case "IfSpanish": pageName="spanish_market.shtml"; break; 
  case "IfSouth": pageName="south_african_market.shtml"; break; 
  case "MakesModels": pageName="makes_models.shtml"; break; 
  case "ProductionFigs": pageName="production_figures.shtml"; break; 
  case "PropADO22": pageName="ado22.shtml"; break; 
  case "PropAero": pageName="aerodynamic.php"; break; 
  case "ProtoGlass": pageName="glass_fibre_morris_1300.php"; break; 
  case "SRV5": pageName="srv5.php"; break; 
  //Cars//
  case "Brochures": pageName="brochures.php"; break;   
  case "CinemaAdverts": pageName="videos_adverts.php"; break; 
  case "ColourCharts": pageName="colour_charts.php"; break;    
  case "Conversions": pageName="conversions.php"; break;  
  case "CoverStars": pageName="coverstars.php"; break;  
  case "DER": pageName="der_vans.shtml"; break;
  case "DuoTone": pageName="duo_tone.php"; break;  
  case "KitCars": pageName="kit_cars.php"; break;  
  case "LookaLikes": pageName="look_a_likes.shtml"; break;
  case "MeetOur": pageName="our_ado16s.php"; break;
  case "PoliceCars": pageName="police_cars.shtml"; break;
  case "RallyCars": pageName="rally_cars.shtml"; break;
  case "SafetyVideos": pageName="videos_safety.php"; break;
  case "ServiceBulletins": pageName="service_bulletins.php"; break;
  case "Spotted": pageName="spotted.php"; break;  
  case "Trivia": pageName="trivia.shtml"; break;
  case "WebsiteCoverStars": pageName="web_site_cover_stars.php"; break;
  //Menu structure//
  case "Tab1": pageName="index.php"; break;
  case "Tab2": pageName="hist_dev.php"; break;
  case "Tab3": pageName="cars.php"; break;
  case "Tab4": pageName="owning_an_ado16.php"; break;
  case "Tab5": pageName="community.php"; break;
  case "Tab6": pageName="http://www.ado16forums.info/index.html"; break;
  case "TL62": pageName="timeline_1962.php"; break; 
  case "TL63": pageName="timeline_1963.php"; break;
  case "TL64": pageName="timeline_1964.php"; break;
  case "TL65": pageName="timeline_1965.php"; break;
  case "TL66": pageName="timeline_1966.php"; break;
  case "TL67": pageName="timeline_1967.php"; break;
  case "TL68": pageName="timeline_1968.php"; break;
  case "TL69": pageName="timeline_1969.php"; break;
  case "TL70": pageName="timeline_1970.php"; break;
  case "TL71": pageName="timeline_1971.php"; break;
  case "TL72": pageName="timeline_1972.php"; break;
  case "TL73": pageName="timeline_1973.php"; break;
  case "TL74": pageName="timeline_1974on.php"; break;
  }
  location.href = pageName;
}