// JavaScript Document

var browser = navigator.userAgent.toLowerCase();
var browserIE = ( browser.indexOf("msie") != -1 );
var browserFirefox = ( browser.indexOf("firefox") != -1 );
if ( browserFirefox )
{
    document.write('<style type="text/css" media="print">'); 
    document.write('div#footer a { margin-left: -0.5em; padding-left: 0; }'); 
    document.write('b { margin-left: -0.5em; padding-left: 0; }</style>'); 
    document.write('</style>'); 
}

/*
 * --------------------------------------------------------------------------------
 */

function f_element( p_index, p_deliminator, p_string ) {
  /* 
   * JavaScript version of OpenVMS DCL F$ELEMENT lexical
   */
  var currIndex = p_string.indexOf(p_deliminator);
  var i = 0;
  var outChar = '';
  var outPoint = 0;
  var outString = p_string;
  var trackIndex = 0;

  if ( currIndex >= 0 ) {
      while ( ( trackIndex != p_index ) && ( currIndex != -1 ) ) {
        outPoint = ++currIndex;
        currIndex = p_string.indexOf(p_deliminator,outPoint);
        trackIndex++;
      } // end while ( ( trackIndex != p_index ) && ( currIndex != -1 ) )
      if ( trackIndex != p_index ) {
        outString = p_deliminator;
      } else {
        outString = '';
        for ( i=outPoint; i<p_string.length; i++ ) { 
          outChar = p_string.charAt(i);
          if ( outChar == p_deliminator ) {
            break;
          } else {
            outString = ( outString + outChar );
          } // end if ( outChar == p_deliminator )
        } // for ( i=outPoint; i<p_string.length; i++ )
      } // end if ( trackIndex != p_index )
    } else if ( p_index >= 1 )
      outString = p_deliminator;
    // end if ( currIndex >= 0 )
  
  return outString;
  } // end f_element function
  
/*
 * --------------------------------------------------------------------------------
 */

function replace(p_string,p_text,p_by) {
// Replaces p_text with p_by in p_string
// From:  http://tech.irt.org/articles/js037/
    var strLength = p_string.length, txtLength = p_text.length;
    if ((strLength == 0) || (txtLength == 0)) return p_string;

    var i = p_string.indexOf(p_text);
    if ((!i) && (p_text != p_string.substring(0,txtLength))) return p_string;
    if (i == -1) return p_string;

    var newstr = p_string.substring(0,i) + p_by;

    if (i+txtLength < strLength)
        newstr += replace(p_string.substring(i+txtLength,strLength),p_text,p_by);

    return newstr;
}  // end replace function

/*
 * --------------------------------------------------------------------------------
 * The following functions control the left column menu display
 * --------------------------------------------------------------------------------
 */

function displayOption( pPageId, pOption, pColumn ) {
  tdClass = ""
  pageName = f_element( 0, '.', pPageId );
  pageType = '.'+f_element( 1, '.', pPageId );
  if ( pageType == '..' )
     pageType = '.html';
  if ( pPageId == 'index' )
    pageFile = homePage 
  else 
    pageFile = ( pageName + pageType );
  /* pageFile = '#' */
  if ( PgID == pageName ) {
    aValue = 'class="URHere" title="You are here"'
	tdClass = ' class="URHere"'
	}
  else
    aValue = ( 'href="' + pageFile + '" title="Link to the ' + pOption + ' page"' );
  if ( pColumn != null )
     tdClass = ( tdClass + f_element((tdClass==""),"-","- ") + 'width="50%"' );
  if ( pColumn == null )
    document.write('<tr><td' + tdClass + '><a ' + aValue + '>' + pOption + '</a></td></tr>\n')
  else if ( pColumn == 1 )
    if ( pPageId == 'empty' )
      document.write('<tr><td></td>')
	else
      document.write('<tr><td' + tdClass + '><a ' + aValue + '>' + pOption + '</a></td>')
  else
    if ( pPageId == 'empty' )
      document.write('<td></td></tr>\n')
	else
      document.write('<td' + tdClass + '><a ' + aValue + '>' + pOption + '</a></td></tr>\n');
  return;
}

function displayMenu() {
  document.write('<table id="menu" cellpadding="0" cellspacing="1" align="center" width="100%" border="0">\n');
  document.write('<tbody>\n');
  displayOption( 'index', 'Home' );
  displayOption( 'sendmsgform.php?id=1', 'Contact' );
  document.write('</tbody>\n');
  document.write ('</table>\n');
  return;
}

/*
 * --------------------------------------------------------------------------------
 */

function getPassedValue(p_id) {
  /* 
   * +++
   *
   * Function Name: getPassedValue
   *        Author: Alvin Orzechowski MyFirstWebPage.net
   * Creation Date: 15-Aug-2004
   *      Abstract: To return the passed value or the specified portion of it
   *   Description: 
   *    Parameters: p_id - Value found to the left of an equal sign.  If this is
   *                    found, this function will return the value found to the
   *                    right of the equal sign.  If this parameter is not 
   *                    provided, this function will return the whole value 
   *                    passed.
   *       History: 
   * 
   * ---
   */

  // [ getPassedValue Constants ]
  var passedValue = unescape(location.search.substring(1));

  // [ getPassedValue Variables ]
  var allSubValues = location.search.substring(1,location.search.length).split('&');
  var i;
  var idValue = passedValue;
  var subValue;

  // [ getPassedValue Main Line ]
  for (i=0; i<allSubValues.length; i++) {
    subValue = allSubValues[i].split('=');
    if ( subValue[0] == p_id ) {
      idValue = unescape(subValue[1]);
      i = allSubValues.length;
    } // end if ( subValue[0] == p_id )  
  } // end for (i=0; i<allSubValues.length; i++)

  // [ getPassedValue End of Job ]
  return idValue;

} // end getPassedValue function

/*
 * --------------------------------------------------------------------------------
 */

function include_rpc(script_filename, p1) {
  /* 
   * +++
   *
   * Function Name: include_rpc
   *        Author: Stoyan Stefanov, phpied.com (original)
   *                Alvin Orzechowski, MyFirstWebPage.net (modifications)
   * Creation Date: 20-Mar-2007
   *      Abstract: To call and execute a server script
   *   Description: 
   *    Parameters: script_filename - the name of the script to be called 
   *                                  (required)
   *                p1 - value to be passed (optional)
   *       History: 
   * 
   * ---
   */

  // [ include_rpc Constants ]
  var html_doc = document.getElementsByTagName('head').item(0);
  var js = document.createElement('script');
  
  // [ include_rpc Main Line ]
  if ( p1 != null )
      script_filename += ( '?' + p1 );
  js.setAttribute('language', 'javascript');
  js.setAttribute('type', 'text/javascript');
  js.setAttribute('src', script_filename);
  html_doc.appendChild(js);
  return;
} // end include_rpc function

/*
 * --------------------------------------------------------------------------------
 * MyFirstWebPage.net specific functions
 * Leave this section at the end
 * --------------------------------------------------------------------------------
 */

function get_mfwpnLogo(pTM) {
  var mfwpnLogo = '<span class="MFWPNlogo">' +
  '<span style="color: #000000;">My</span>' +
  '<span style="color: #ff0000;">First</span>' +
  '<span style="color: #00ff00;">Web</span>' +
  '<span style="color: #0000ff;">Page</span>' +
  '<span style="color: #000000;">.net';

  if ( pTM == 'tm' )
    mfwpnLogo = ( mfwpnLogo + '&#153;' );
  mfwpnLogo = ( mfwpnLogo + '</span></span>' );

return mfwpnLogo;
} // end get_mfwpnLogo function