// JavaScript: shared_scripts.js
// Written by: Chris R Ford

// 06/19/2010: Try email form for email contacts.
// 07/13/2008: Remove 'Puppies' from menu and nav line.
// 06/01/2008: Put 'Puppies' back into menu and nav line.
// 01/16/2007: Remove 'Puppies' from menu and nav line.
// 11/17/2006: Put 'Puppies' back into menu and nav line.
// 07/10/2005: Fix problem with email interpretation within gen_nav_line.
// 04/26/2005: Remove 'Puppies' from menu and nav line.
// 02/01/2005: Implementation

// Define global variables.

  var ref_name = new Array();
  var ref_path = new Array();
  pagetitle = document.title;
//pagetitle = pagetitle.replace(/ /g,'_');
  ourname   = "Inquiry";
  ourserver = "HeavensWelsh.com";

  var ref_pfx = "../";
  word_split = location.href.split("/");
  if (word_split[2] == "localhost:3810") {
      if (word_split[5] == null) {
          ref_pfx = "";
      }
  }

  ref_name[0] = "Home";             ref_path[0] = "index.html";
//ref_name[ ] = " Puppies";         ref_path[ ] = "puppies.htm";
  ref_name[1] = "About Heavens";    ref_path[1] = "about_heavens.htm";
  ref_name[2] = "About Welsh";      ref_path[2] = "about_welsh.htm";
  ref_name[3] = "Our Dogs";         ref_path[3] = "our_dogs.htm";
  ref_name[4] = " Cherub Photos";   ref_path[4] = "puppies/cherub.htm";
  ref_name[5] = " Halo Photos";     ref_path[5] = "puppies/halo.htm";
  ref_name[6] = " Flicka Photos";   ref_path[6] = "puppies/flicka.htm";
  ref_name[7] = "Pedigree Engine";  ref_path[7] = "data/index.html";
  ref_name[8] = "Just For Fun";     ref_path[8] = "just_for_fun.htm";
  ref_name[9] = "Links";            ref_path[9] = "links.htm";
  ref_name[10] = "Email Us";       ref_path[10] = "http://www.emailmeform.com/builder/form/elm135AT02J8p5";

// ref_name[10] = "E-Mail Us";       ref_path[10] = "";

//"mailto:Dawn &amp; Chris Ford <" + ourname + "@" + ourserver + ">?subject=" + pagetitle;

//-------------------------------------------------------------------------------------------
function show_email_addr(in_namex, in_name, in_server, in_subject, in_action)
{
  var wk_str = "mailto:" + in_namex + "<" + in_name + "@" + in_server + ">?subject=" + in_subject;

  document.write("<a href=\"" + wk_str + "\">" + in_action + "</a>");

  return;
}

//-------------------------------------------------------------------------------------------
function gen_nav_menu()
{
  for( var i = 0; i < ref_name.length; i++) {
    document.write("<p class=MsoNormal style='margin-bottom:6.0pt'>\n");
    document.write("<b><span style='font-size:10.0pt;font-family:Arial'>\n");
    if (ref_name[i].indexOf("E-Mail") > -1) {
        show_email_addr("Dawn Ford","Inquiry","HeavensWelsh.com",pagetitle,ref_name[i]);
    }
    else {
        ref_indent = "";
        if (ref_name[i].charAt(0) == " ") {
            ref_indent = "&nbsp;&nbsp;&nbsp; ";
        }
        if (document.title.indexOf(ref_name[i]) > -1) {
            document.write( ref_indent + ref_name[i] );
        }
        else {
            if (ref_path[i].indexOf("http:") > -1) {
                document.write(ref_indent + "<a href=\"" + ref_path[i] + "\">" + ref_name[i] + "</a>");
            }
            else {
                document.write(ref_indent + "<a href=\"" + ref_pfx + ref_path[i] + "\">" + ref_name[i] + "</a>");
            }
        }
    }
    document.write("</span></b>");
    document.write("</p>");
  }

  return;
}

//-------------------------------------------------------------------------------------------
function gen_nav_line(in_copy_year)
{
  var mod_year = '';

  var len = 0;
  
  document.write("<p class=MsoNormal style='margin-bottom:6.0pt'>\n");
  document.write("<center><span style='font-size:10.0pt;font-family:Arial'>\n");

  for( var i = 0; i < ref_name.length; i++) {
    if (len > 0) {
        document.write(" | ");
        len += 3;
    }
    if (ref_name[i].indexOf("E-Mail") > -1) {
        show_email_addr("Dawn Ford","Inquiry","HeavensWelsh.com",pagetitle,ref_name[i]);
    }
    else {
        if (document.title.indexOf(ref_name[i]) > -1) {
            document.write( ref_name[i] );
        }
        else {
            document.write("<a href=\"" + ref_pfx + ref_path[i] + "\">" + ref_name[i] + "</a>");
        }
    }
    len += ref_name[i].length;
    if (len > 55) {
        document.write("<br/>"); 
        len = 0;
    }
  }
  document.write("</center></span></p>");

  mod_year = document.lastModified.substr(6,4);

  if (in_copy_year == null) {
      out_copy_year = mod_year;
  }
  else { 
      if (in_copy_year == mod_year) {
          out_copy_year = in_copy_year;
      }
      else {
          out_copy_year = in_copy_year + "-" + mod_year;
      }
  }

  document.write("<p class=MsoNormal align=center style='text-align:center'><span ");
  document.write("style='font-size:10.0pt;font-family:Arial'>");
  document.write("HEAVENS! - &copy; " + out_copy_year + " - ");
  document.write("Christopher R. Ford - All Rights Reserved</span></p>");

  document.write("<p class=MsoNormal align=center style='text-align:center'><span ");
  document.write("style='font-size:10.0pt;font-family:Arial'>");
  document.write("Page last modified ");
  document.writeln(document.lastModified);
  document.write("</span></p>");
  
  return;
}

//-------------------------------------------------------------------------------------------
function display_logo1()
{
  document.write("<p class=MsoNormal><img width=106 height=78 ");
  document.write("src=\"" + ref_pfx + "shared_images/mercy_logo.gif\"></p>");
  return;
}

//-------------------------------------------------------------------------------------------
function display_logo2()
{
  document.write("<p class=MsoNormal><img width=539 height=78 ");
  document.write("src=\"" + ref_pfx + "shared_images/heavens_logo.jpg\"></p>");
  return;
}

//-------------------------------------------------------------------------------------------
function display_upd_date()
{
  document.writeln("Jul 13, 2008");
  return;
}

//-------------------------------------------------------------------------------------------
function check_vars()
{
  var href = "Href : " + location.href + "<br>";
  var prot = "Prot : " + location.protocol + "<br>";
  var host = "Host : " + location.host + "<br>";
  var path = "Path : " + location.pathname + "<br>";
  var hash = "Hash : " + location.hash + "<br>";
  
  document.writeln(href + prot + host + path + hash);
  for (var i = 1; i < 10; i++) {
      document.writeln(word_split[i].length + word_split[i] + "<br>");
  }
  return;
}

