// bbccfuncs.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",      "BBCC Home page"
                     ,"membership.html", "Membership Details"
                     ,"rally.html",      "Boat Rally"
                     ,"facilities.html", "Facilities"
        //           ,"workip.html",     "Work in progress"
                     ,"history.html",    "Club history"
                     ,"diary.html",      "Diary of club events"
                     ,"information.html", "Information"
                     ,"pictures.html",   "Picture gallery"
        //           ,"links.html",      "Web Links"
        //           ,"exchange.html",   "Members&#039; sales &amp; wants"
        //           "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>');
    // document.write('<a id="stylelinksmall" href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true">Back to previously viewed page</a> &#124; ');
    document.write('<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.blackbuoy.org.uk">';

  //  ought to have type="image/gif
  if (image == null) {
    sText += '<img src="bbccweblogo_104x104.gif" alt="BBCC 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">';
  sText += "&copy; Copyright Black Buoy Cruising Club Ltd. 2001, 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');


  sText = "<p id=\"stylesmallc\">This information is provided by Black Buoy Cruising Club";
  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";
  sText += " represent the official views of the Club, it's committee 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 = "bbcc1";
    } else {
      sText = "bbccie1";
    }
  } else {
    if ((navigator.appName == "Netscape") &&
        (parseInt(navigator.appVersion) >= 4)){
      if((navigator.appVersion.indexOf("Macintosh"))!= -1){
        sText = "bbcc1";
      } else {
        sText = "bbccns1";
      }
    } else {
      sText = "bbcc1";
    }
  }
  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);
  }
}
