// rnrfuncs.JS
//
// functions for rest of content

function NaviLinks(type) {
  // v2 - uses hr for left hand
  // !! The only list of page names and title which appear in the navigation links

  pages = new Array ("index.html",       "RNR Home page"
                     ,"join.html",       "Join Us"
                     ,"benefits.html",   "Membership Benefits"
                     ,"rally.html",      "Boat Rally"
                     ,"newsletter.html", "Newsletter"
                     ,"goodies.html",    "Merchandise"
                     ,"history.html",    "RN Story"
                     ,"archives.html",    "From the archives"
                     ,"property.html",    "RNR Property Ltd."
                     ,"http://www.russellnewbery.co.uk/", "RN Diesel Engine Company"
                     ,"links.html",       "Web Links"
        //           "test.html",         "Test page"
        //           "sub\\index.html",   "SubDirectory",
        //           "..\\index.html",    "ParentDirectory"
                     );

  slash = new String("/");
  backslash = new String("\\");

  if ((navigator.appName == "Microsoft Internet Explorer") &&
      (window.location.pathname.indexOf(backslash) != -1)) {
    slash = "\\";
  };
  j = window.location.pathname.lastIndexOf(".html");
  k = window.location.pathname.lastIndexOf(slash);
  if (j < 1) { j = window.location.pathname.length;}
  if (k < 1) {k = 0;}

  thisPage =  window.location.pathname.substring(k+1, j);
  if (thisPage == "") {
    thisPage = "index";
  }
  thisPage += ".html";

  if (type=='left') {
    // document.write('<hr/>');

    for (i=0; i < pages.length; i=i+2) {
      if (pages[i] == thisPage) {
        document.write('<a id="stylelinkt" href="',pages[i],'">',pages[i+1],'</a>');
      } else {
        document.write('<a id="stylelink" href="',pages[i],'">',pages[i+1],'</a>');
      }
      // document.write('<hr/>');
      document.write('<br/><br/>');
    }
  } else {
    // navigation style not left - so it is bottom
    document.write('<p><a id="stylelinksmall" href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true">Back to previously viewed page</a> &#124; <a id="stylelinksmall" href="#topofpage">Top of this page</a> ');

    for (i=0; i < pages.length; i=i+2) {
      if (pages[i] == thisPage) {
        // dont show a link to this page
      } else {
        document.write(' &#124; <a id="stylelinksmall" href="',pages[i],'">',pages[i+1],'</a>');
      }
    }
    document.write('</p>');
  }
}


function PageBody() {
  //v1
  var sText = '<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">';
  document.write(sText);
}

function PageSet() {
  //v1
  var sText = '<table id="mt" border="0" cellspacing="0" cellpadding="4"';
  // sText += ' width="100%"';
  sText += ' frame="void" rules="void"';
  sText += ' summary="table for main page layout - 3 rows and 3 cols">';
  document.write(sText);
  sText = '<tbody>';
  document.write(sText);
}

function PageEnd() {
  // v1
  var sText = "</tbody>";
  sText += "</table>";
  document.write(sText);
}

function TopLeft(image, width) {
  // v1
  // Main table cell A top left - logo
  var sText = '<tr>';
  sText += '<td id="mttl" width="';
  if (width != null) {
    sText += width;
  } else {
    sText += '126';
  }
  sText += '"  ><a href="http://www.russellnewbery.co.uk/Register">';

  //  ought to have type="image/gif
  if (image == null) {
    sText += '<img src="RNR_logo2b_128x95.gif" alt="RNR logo" hspace="0" border="0"/>';
  } else {
    sText += '<img src="';
    sText += image;
    sText += '" alt="logo image" hspace="0" border="0"/>';
  }
  sText += '</a></td>';
  document.write(sText);
}

function TopCenter(text1, text2, width) {
  // v1
  // Main table cell B top center - title
  var sText = '<td id="mttc"';
  if (width != null) {
    sText += ' width="';
    sText += width;
    sText += '" ';
  }
  sText += '>';

  sText += '<p>';
  if (text1 != null) {
    sText += text1;
  }
  sText += '</p><p id="bold">';
  if (text2 != null) {
    sText += text2;
   }
  sText += '</p>';
  // sText += '<p id="stylesmallc">Site under construction - some links may not work.</p>'
  sText += '</td>';
  document.write(sText);
}

function TopRight(image, width) {
  // v1
  // Main table cell C top right
  var sText = '<td id="mttr" width="';
  if (width != null) {
    sText += width;
  } else {
    sText += '10%';
  }
  sText += ' valign="center" align="center">';
  if (image == null) {
    sText += '<img src="transparent1x1.gif" alt="" hspace="0" border="0"/>';
  } else {
    sText += '<img src="';
    sText += image;
    sText += '" alt="" hspace="0" border="0"/>';
  }
  sText += '</td>';
  sText += '</tr>';
  document.write(sText);
}

function MiddleLeft() {
  // v1
  // Main table cell D middle left - Main navigation

  var sText = '<tr height="128">';
  sText += '<td id="mtml">';
  document.write(sText);

  NaviLinks('left');

  sText = ' </td>';
  document.write(sText);

}

function MiddleCenterOpen() {
  // v1
  // Main table cell E middle centre - main content start
  var sText = '<td id="mtmc" colspan="1">';
  // sText += " ";
  document.write(sText);
}

function MiddleCenterClose() {
  // v1
  // Main table cell E middle centre - main content end
  var sText = '';
  sText += '</td>';
  document.write(sText);
}


function MiddleRight() {
  // v1
  // Main table cell F middle right - not used
  var sText = '<td id="mtmr">';
  // sText += '&nbsp;';
  sText += '</td>';
  sText += '</tr>';
  document.write(sText); 
}

function BotLeft() {
  // v1
  // Main table cell G bottom left - copyright and temp content
  slash = new String("/");
  backslash = new String("\\");

  if ((navigator.appName == "Microsoft Internet Explorer") &&
      (window.location.pathname.indexOf(backslash) != -1)) {
    slash = "\\";
  };
  j = window.location.pathname.lastIndexOf(".html");
  k = window.location.pathname.lastIndexOf(slash);
  if (j < 1) { j = window.location.pathname.length;}
  if (k < 1) {k = 0;}

  thisPage =  window.location.pathname.substring(k+1, j);

  var sText = '<tr valign="top" height="128">';
  sText += '<td id="mtbl">';
  // sText += '<hr />';

  sText += '<p id="copyrite">';
  if (thisPage == "property") {
     sText += "&copy; Copyright RNR Property Ltd. 2005, 2010";
  } else {
    sText += "&copy; Copyright Russell Newbery Register Ltd. 2003, 2010";
  }
  sText += "</p>";
  sText += ' </td>';
  document.write(sText);
}

function BotCenter() {
  // v1
  // Main table cell H bottom center - navigation links
  var sText = '<td id="mtbc" colspan="1">';
  // sText += '<hr />';
  document.write(sText);

  if ((navigator.appName == "Microsoft Internet Explorer") &&
      (window.location.pathname.indexOf(backslash) != -1)) {
    slash = "\\";
  };
  j = window.location.pathname.lastIndexOf(".html");
  k = window.location.pathname.lastIndexOf(slash);
  if (j < 1) { j = window.location.pathname.length;}
  if (k < 1) {k = 0;}

  thisPage =  window.location.pathname.substring(k+1, j);

  monthNames = new Array ("January", "February", "March", "April",
                          "May", "June", "July", "August",
                          "September", "October", "November", "December");

  sText  = '<p id="styleupdate">';
  sText += 'This page last updated ';
  if (arguments.length > 0) {
    sText += arguments[0];
  } else {
    var mod = new Date (document.lastModified);
    sText += mod.getDate();
    sText += ' ';
    sText += monthNames[mod.getMonth()];
    sText += ' ';
    sText += mod.getFullYear();
  }
  sText += '.</p>';
  document.write(sText);

  NaviLinks('bot');

  if (thisPage == "property") {
    sText = "<p id=\"stylesmallc\">This information is provided by RNR Property Ltd.";
  } else {
    sText = "<p id=\"stylesmallc\">This information is provided by Russell Newbery Register Ltd.";
  }
  sText += " who make no representation of its accuracy or completeness.";
  sText += " Persons using this information do so entirely at their own risk,";
  sText += " no liability is accepted for any loss or injury incurred as a result";
  sText += " of acting upon this information. Subjective descriptions do not necessarily"; 
  if (thisPage == "property") {
    sText += " represent the official views of the company or it's directors.";
  } else {
    sText += " represent the official views of the Register, it's officers or members.";
  }
  
  // sText += " Rest of legal stuff to go here. ";
  sText += "</p>";
  document.write(sText);

  sText = ' </td>';
  document.write(sText);
}

function BotRight(image) {
  // v1
  var sText = '<td id="mtbr"';
  sText += ' valign="center" align="center">';
  // sText += '<div class="c1">';
  // sText += '<hr />';
  if (image == null) {
    sText += '<br />&nbsp;';
  } else {
    sText += '<img src="';
    sText += image;
    sText += '" alt="" hspace="0" border="0"/>';
  }
  // sText += '</div>';

  sText += ' </td>';
  sText += ' </tr>';
  document.write(sText); 
}

function SetStyle(trace) {
  // v1
  // Set css style
  var sText = '';

  if ((navigator.appName == "Microsoft Internet Explorer") &&
      (parseInt(navigator.appVersion) >= 4 )){
    if((navigator.appVersion.indexOf("Macintosh"))!= -1){
      sText = "rnr1";
    } else {
      sText = "rnrie1";
    }
  } else {
    if ((navigator.appName == "Netscape") &&
        (parseInt(navigator.appVersion) >= 4)){
      if((navigator.appVersion.indexOf("Macintosh"))!= -1){
        sText = "rnr1";
      } else {
        sText = "rnrns1";
      }
    } else {
      sText = "rnr1";
    }
  }
  document.write('<link rel="stylesheet" href="');
  document.write(sText);
  document.write('.css" type="text/css"/>');
  if (trace != null) {
    document.write('Using style sheet ');
    document.write(sText);
  }
}
