//
// NOTE: These scripts NOT for use on any site other than Bart Hubbard's.
//       All scripts are copyright 1999.
//
//
// file        : bart.js
// description : JavaScript for use on my personal web page
// author      : bart hubbard
//
//

//
// Allocate vars for the title images, and preload them
//
//var titleImage1 = new Image();
//var titleImage2 = new Image();
//var titleImage3 = new Image();
//var currentTitleIndex = 1;

//titleImage1.src = "images/title3.gif";
//titleImage2.src = "images/title2.gif";
//titleImage3.src = "images/title1.gif";

//
// function    : rotateTitleImage()
// description : displays the next title image in the sequence
//
function rotateTitleImage()
{

    // increment the title image index
    currentTitleIndex = currentTitleIndex + 1;
    if ( currentTitleIndex > 3 )
    {
        currentTitleIndex = 1;
    }

    // display the image at the new index
    displayTitle(currentTitleIndex);

}

//
// function    : displayTitle(index)
// description : display the title image for the given index in the title frame
//
function displayTitle(index)
{

    if ( index==1 )
    {
        parent.TitleFrame.document.images[0].src = titleImage1.src;
    }
    if ( index==2 )
    {
        parent.TitleFrame.document.images[0].src = titleImage2.src;
    }
    if ( index==3 )
    {
        parent.TitleFrame.document.images[0].src = titleImage3.src;
    }

}


//
// function    : docdate()
// description : print out the date of the document calling this function
//
function docdate()
{
    document.writeln( document.lastModified );
}


//
// function    : curtime()
// description : print out the formatted current time
//
function curtime()
{
    // show the current time
    var today  = new Date();
    var hour   = today.getHours();
    var minute = today.getMinutes();

    nowtime = " " + hour;
    if ( hour>12 )
    {
        nowtime = " " + (hour - 12);
    }
    nowtime += ":" + ((minute < 10) ? "0" + minute : minute);
    nowtime += ((today.getHours() > 12) ? " pm" : " am");

    document.write(nowtime);

    //document.forms[0].elements[0].value = nowtime;
    //setTimeout("curtime()", 1000);
}

//
// function: mailBart()
// send me an e-mail
//
function mailBart() {
  window.location = "mailto:bart@barthubbard.com";
}


//
// function    : mailTo (string, string)
// description : A function that pieces together a mailto tag in such a way that robots
//               and crawlers can't scalp my email address.
//
function mailTo (nameStr, domainStr) {
  window.location = "mailto:" + nameStr + "@" + domainStr;
}

//
// function    : openImg(String)
// description : Opens a new window w/a black background, and the image with
//                name that is passed in as an arg
// date(s)     : 6-21-98 - Added document.close() call to resolve minor bug
//               1-??-98 - Creation
//
function openImg(image_arg) {
    var imageWindow;

    imageWindow = window.open("", "", "directories=0,copyhistory=0,width=500,height=570,resizable=1");
    imageWindow.document.open();
    var stuff;

    // generate html header tags
    var stuff = "<html><head><title>Viewing: " + image_arg;
    stuff += "</title></head><body bgcolor=000000 text=c0c0c0>";
    stuff += "<center>";
    stuff += "<h2\>" + image_arg + "</h2><br>";
    stuff += "<img src=\"" + image_arg + "\">";
    stuff += "</center></body></html>";
    imageWindow.document.writeln(stuff);

    // close layout stream
    imageWindow.document.close() ;
}


function printBrowser()
{

    document.writeln("<p>Browser: " + navigator.appName + "</p>");
    document.writeln("<p>Version: " + navigator.appVersion + "</p>");

}

function printDimensions()
{

    document.write("Width = " + screen.width + ",  Height = " + screen.height);

}

var highlightColor  = "ffcc66";
var standardColor   = "996600";
var tblBackgroundColor = "000033";
var backgroundColor = "212121";

//
// function    : bodyTagStart()
// description : detect the current browser, and setup the body tag appropriately if not IE;
//                Why? Because only IE seems to properly support the colors set in a CSS
//
function bodyTagStart()
{
    document.writeln("<body bgcolor=\"#" + backgroundColor + "\" text=\"#" + standardColor + "\" >");
    /*
    //
    // Style sheet seems to be working correctly in all browsers, now, so discard code below
    //
    if ( navigator.appName == "Microsoft Internet Explorer" )
    {
        document.write("<body bgcolor=\"#" + backgroundColor + "\" text=\"#" + standardColor + "\" >");
    }
    else
    {
        document.write("<body bgcolor=\"#" + backgroundColor + "\" link=\"#" + highlightColor + "\" vlink=\"#" + highlightColor + "\" text=\"#" + standardColor + "\">");
    }
    */
}

//
// header stuff
//
function header()
{

    //document.write("<P ALIGN=\"CENTER\" >");

}

//
// footer stuff
//
function footer()
{

    document.write("<br><br>");

    //document.write("<br><hr width=75%><br>");
    //document.writeln("</P>");

}

//------------------------------------------------------------------------
//
// Below are the cool table functions.  A cool table is a table that is
// used to draw a sizeable, rounded-corner rectangle on a web page.
// 
//
//------------------------------------------------------------------------


//
// Constants for the colors used in the table functions
//
var tableBg = "404040";
var tableFg = "c0c0c0";
var titleFg = "c6eff7";

//
// for Christmas
//
/**
    var tableBg = "336600";
    var tableFg = "ffffff";
    var titleFg = "ff0000";
**/

//
// constants for the images used in the table functions
//
var tlImage = "/images/tl6.gif";
var trImage = "/images/tr6.gif";
var blImage = "/images/bl6.gif";
var brImage = "/images/br6.gif";
var blankImage = "/images/null.gif";
var fillerText = "";

/**
    //
    // For Christmas...
    //
    var tlImage = "/images/tl_xmas.gif";
    var trImage = "/images/tr_xmas.gif";
    var blImage = "/images/bl_xmas.gif";
    var brImage = "/images/br_xmas.gif";
    var bgImage = "/images/tablebg.gif";
    var blankImage = "/images/null.gif";
    var fillerText = "";
**/

//
// constants for image dimensions
//
var picHeight    = 6;
var picWidth     = 6;
var lineThick    = 2;
var fillerHeight = picHeight - lineThick;
var fillerWidth  = picWidth  - lineThick;

//
// function    : tableTop()
// description : start the cool table; this function would be private if this were Java,
//               as it should not be called directly from a web page
//               'w' is the width of the table's center cell
//
function tableTop()
{
    document.writeln("<table align=\"center\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">");
    document.writeln("  <tr>");
    document.writeln("      <td colspan=\"2\" align=\"absleft\" valign=\"top\" height=\"" + picHeight + "\" width=\"" + picWidth + "\" align=\"left\"><img border=\"0\" src=\"" + tlImage + "\" width=\"" +picWidth+ "\"height=\"" +picHeight+ "\"></td>");
    document.writeln("      <td bgcolor=\"#"+ tableBg +"\" valign=top height=" + picHeight + " width=\"100%\">");
    document.writeln("        <table bgcolor=\"#" + tableBg + "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"absleft\" width=\"100%\">");
    document.writeln("           <tr height=" + lineThick + " valign=top><td bgcolor=\"#" + tableFg + "\" width=\"100%\"><img src=\"" + blankImage + "\" height=" + lineThick + " border=0></td></tr>");
    document.writeln("           <tr height=" + fillerHeight + " valign=top><td width=\"100%\"><img src=\"" + blankImage + "\" height=" + fillerHeight + " border=0></td></tr>");
    document.writeln("        </table>");
    document.writeln("      </td>");
    document.writeln("      <td colspan=2 valign=top height=" + picHeight + " width=" + picWidth + " align=right><img border=0 valign=top align=absright src=\"" + trImage + "\" height=\"" +picHeight+ "\"width=\"" +picWidth+ "\"></td>");
    document.writeln("  </tr>");
    document.writeln("  <tr>");
    document.writeln("       <td width=\"" + lineThick + "\" align=\"left\" valign=\"top\" bgcolor=\"#" + tableFg +"\"><img src=\"" + blankImage + "\" width=\"" + lineThick + "\" border=\"0\"></td>");
    document.writeln("       <td bgcolor=\"#"+ tableBg +"\" align=\"right\" width=\"" + fillerWidth + "\"><img src=\"" + blankImage + "\" border=\"0\"></td>");
}

//
// function    : tableBottom()
// description : end the cool table; this function would be private if this were Java,
//               as it should not be called directly from a web page
//               'w' is the width of the table's center cell
//
function tableBottom()
{
    document.writeln("       <td bgcolor=\"#"+ tableBg +"\" align=\"left\"><img src=\"" + blankImage + "\" width=\"" + fillerWidth + "\" border=\"0\"></td>");
    document.writeln("       <td width=\"" + lineThick + "\" align=\"right\" valign=\"top\" bgcolor=\"#" + tableFg + "\"><img src=\"" + blankImage + "\" width=\"" + lineThick + "\" border=\"0\"></td>");
    document.writeln("  </tr>");
    document.writeln("  <tr>");
    document.writeln("      <td colspan=\"2\" align=\"absleft\" valign=\"bottom\" height=\"" + picHeight + "\" width=\"" + picWidth + "\"><img border=\"0\" src=\"" + blImage + "\" height=\"" +picHeight+ "\" width=\"" +picWidth+ "\"></td>");
    document.writeln("      <td bgcolor=\"#"+ tableBg +"\" valign=\"bottom\" height=\"" + picHeight + "\" width=\"100%\">");
    document.writeln("         <table height=\"" + picHeight + "\" bgcolor=\"#" + tableBg + "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">");
    document.writeln("           <tr height=" + fillerHeight + " valign=bottom><td bgcolor=\""+ tableBg +"\" width=\"100%\"><img src=\"" + blankImage + "\" height=" + fillerHeight + " border=0></td></tr>");
    document.writeln("           <tr height=" + lineThick + " valign=bottom><td bgcolor=\"#" + tableFg + "\" width=\"100%\"><img src=\"" + blankImage + "\" height=" + lineThick + " border=0></td></tr>");
    document.writeln("         </table>");
    document.writeln("      </td>");
    document.writeln("      <td colspan=2 valign=bottom height=" + picHeight + " width=" + picWidth + " align=right><img border=0 valign=bottom align=absright src=\"" + brImage + "\" width=\"" +picWidth+ "\" height=\"" +picHeight+ "\"></td>");
    document.writeln("  </tr>");
    document.writeln("</table>");
}

//
// function    : startCoolTable()
// description : start the cool table; this function is the one to call from a web page
//               to start a cool table
//
function startCoolTable()
{
    tableTop();
    document.write("<td bgcolor=\"#"+ tableBg +"\" align=\"left\" valign=\"bottom\" width=\"100%\">");
}

//
// function    : startCoolTableCentered()
// description : start the cool table; this function is the one to call from a web page
//               to start a cool table that centers its data
//
function startCoolTableCentered()
{
    tableTop();
    document.write("<td bgcolor=\"#"+ tableBg +"\" align=\"center\" valign=\"bottom\" width=\"100%\">");
}

//
// function    : endCoolTable()
// description : end the cool table; this function is the one to call from a web page
//               to end a cool table
//
function endCoolTable()
{
    document.writeln("</td>");
    tableBottom();
}

//
// Functions that generate the tables used to draw rounded rectangles
// around text in an HTML document
//

function titleBarTableStart()
{
    startCoolTableCentered();
}

function titleBarTableEnd()
{
    endCoolTable();
}

function sideBarTableStart()
{
    startCoolTable();
}

function sideBarTableEnd()
{
    endCoolTable();
}

function textTableStart()
{
    document.writeln("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">");
    document.writeln("    <tr>");
    document.write("        <td>");
}

function textTableEnd()
{
    document.writeln("        </td>");
    document.writeln("    </tr>");
    document.writeln("</table>");
}

//
// function    : tabledTitle(titleText)
// description : Writes out to the current document a table with a border containing the given text
// author      : Bart Hubbard
// date(s)     : 6-29-00 - Creation
//
function tabledTitle(titleText)
{

    tableTop();
    document.writeln("<td bgcolor=\"#"+ tableBg +"\" align=\"center\" valign=\"bottom\" width=\"100%\"><font face=\"Century Gothic, Arial\" size=\"4\" color=\"#" + 
                     titleFg + "\"><b>" + titleText + "</b></font></td>");
    tableBottom();

}


