var rel2root;
var mainImagesDir;
var subsectiontextcolor;
var subsectionfooterblockimage;
var needsContactFooter;

/* this function should be called to initialize
   the vars needed for the other calls. 

   Parameters:
     subsection:  Type string..valid args are:
                  home,ministry,happening,prayer,worship,staff,event,about,contact
     rootlevel:   This indicates how deep the directory the file
                  is located.  If at the root level the directory
                  level would be 0.
*/
        
function init_infrastructure(subsection, rootlevel)
{
  var tmplevel="./";
  var diffFromSubsection;

  needsContactFooter = 0;
  for (i=0; i < rootlevel; i++)
  {
    tmplevel =   "../" + tmplevel;
  }
  rel2root = tmplevel;

  diffFromSubsection = rootlevel - 1;

  tmplevel="./";
  for (i=0; i < diffFromSubsection; i++)
  {
    tmplevel =   "../" + tmplevel;
  }
    mainImagesDir = tmplevel + "images/";
  if (subsection == "home")
  {
    /* home is a very special case */
    subsectiontextcolor = "#B00020";
  }
  else if (subsection == "happening")
  {
    subsectiontextcolor = "#EA7500";
    subsectionfooterblockimage = "<img src='" + rel2root + "footers/images/OrangeSquare.gif' border='0'>";
    needsContactFooter = 1;
  }
  else if (subsection == "prayer")
  {
    subsectiontextcolor = "#985898";
    subsectionfooterblockimage =  "<img src='" + rel2root + "footers/images/PurpleSquare.gif' border='0'>";
  }
  else if (subsection == "ministry")
  {
    subsectiontextcolor = "#B00020";
    subsectionfooterblockimage = "<img src='" + rel2root + "footers/images/RedSquare.gif' border='0'>";
    needsContactFooter = 1;
  }
  else if (subsection == "worship")
  {
    subsectiontextcolor = "#C0C86F";
    subsectionfooterblockimage = "<img src='" + rel2root + "footers/images/GreenSquare.gif' border='0'>";
    needsContactFooter = 1;
  }
  else if (subsection == "staff")
  {
    subsectiontextcolor = "#6D7AB6";
    subsectionfooterblockimage = "<img src='" + rel2root + "footers/images/BlueSquare.gif' border='0'>";
    needsContactFooter = 1;
  }
  else if (subsection == "event")
  {
    subsectiontextcolor = "#FBD24E";
    subsectionfooterblockimage = "<img src='" + rel2root + "footers/images/YellowSquare.gif' border='0'>";
    needsContactFooter = 1;
  }
  else if (subsection == "about")
  {
    subsectiontextcolor = "#0A7E07";
    subsectionfooterblockimage = "<img src='" + rel2root + "footers/images/BrightGreenSquare.gif' border='0'>";
    needsContactFooter = 1;
  }
  else if (subsection == "contact")
  {
    subsectiontextcolor = "#604820";
    subsectionfooterblockimage = "<img src='" + rel2root + "footers/images/BrownSquare.gif' border='0'>";
    needsContactFooter = 1;
  }
  else
  {
    subsectiontextcolor = "#FF0000";
  }


}

function writeStyle()
{
  document.write("<link rel='stylesheet' type='text/css' href='" + rel2root + "Style.css' />");
  document.write("<style>");
  document.write(".boldcolored {color: " + subsectiontextcolor + "}");
  document.write(".normalcolored {color: " + subsectiontextcolor + "}");
  document.write(".largecolored {color: " + subsectiontextcolor + "}");
  document.write(".largeboldcolored {color: " + subsectiontextcolor + "}");
  document.write(".hugecolored {color: " + subsectiontextcolor + "}");
  document.write(".hugeboldcolored {color: " + subsectiontextcolor + "}");
  document.write(".italicboldcolored {color: " + subsectiontextcolor + "}");
  document.write("</style>");
}

function writeHeaders()
{
  document.write("<table border='0' cellpadding='0' cellspacing='0' width='768'>");
  document.write("<tr>");
  document.write("<td><img border='0' src='" + mainImagesDir + "headertop.gif' width='768' height='55'></td>");
  document.write("</tr>");
  document.write("<tr>");
  document.write("<td><img border='0' src='" + mainImagesDir + "headerbottom.gif' width='768' height='52'></td>");
  document.write("</tr>");
  document.write("</table>");

  document.write("<table border='0' cellpadding='0' cellspacing='0' height=100%>");
  document.write("<tr>");
  document.write("<td valign=top width=162>");

  document.write("<table border='0' cellpadding='0' cellspacing='0'>");
  document.write("<tr>");
  document.write("<td><a href='" + rel2root + "Default.htm'><img border='0' src='" + mainImagesDir + "btn_home.gif' width='162' height='32'></a></td>");
  document.write("</tr>");
  document.write("<tr>");
  document.write("<td><a href='" + rel2root + "whatshappening/whatshappening.asp'><img border='0' src='" + mainImagesDir + "btn_whatshappening.gif' width='162' height='32'></a></td>");
  document.write("</tr>");
  document.write("<tr>");
  document.write("<td><a href='" + rel2root + "prayerrequests/prayerrequests.htm'><img border='0' src='" + mainImagesDir + "btn_prayerrequests.gif' width='162' height='32'></a></td>");
  document.write("</tr>");
  document.write("<tr>");
  document.write("<td><a href='" + rel2root + "ministries/ministries.htm'><img border='0' src='" + mainImagesDir + "btn_ministries.gif' width='162' height='32'></a></td>");
  document.write("</tr>");
  document.write("<tr>");
  document.write("<td><a href='" + rel2root + "worship/worship.htm'><img border='0' src='" + mainImagesDir + "btn_worship.gif' width='162' height='32'></a></td>");
  document.write("</tr>");
  document.write("<tr>");
  document.write("<td><a href='" + rel2root + "staff/staff.htm'><img border='0' src='" + mainImagesDir + "btn_staff.gif' width='162' height='32'></a></td>");
  document.write("</tr>");  
  document.write("<tr>");
  document.write("<td><a href='" + rel2root + "forms/forms.htm'><img border='0' src='" + mainImagesDir + "btn_forms.gif' width='162' height='32'></a></td>");
  document.write("</tr>");
  document.write("<tr>");
  document.write("<td><a href='" + rel2root + "about/about.htm'><img border='0' src='" + mainImagesDir + "btn_about.gif' width='162' height='32'></a></td>");
  document.write("</tr>");
  document.write("<tr>");
  document.write("<td><a href='" + "http://web.me.com/kayhorne/Angel_Food/Welcome.html' target=-blank><img border='0' src='" + mainImagesDir + "btn_angelfood.gif' width='162' height='32'></a></td>");
  document.write("</tr>");
  document.write("<tr>");
  document.write("<td><a href='" + rel2root + "ministries/Links/otherlinks.htm'><img border='0' src='" + mainImagesDir + "btn_links.gif' width='162' height='32'></a></td>");
  document.write("</tr>");  
  document.write("<tr>");
  document.write("<td><a href='" + rel2root + "contact/contact.htm'><img border='0' src='" + mainImagesDir + "btn_contact.gif' width='162' height='32'></a></td>");
  document.write("</tr>");
  document.write("</table>");
  document.write("<table border=0 cellpadding=0 cellspacing=0 height=100%>");
  document.write("<tr>");
  document.write("<td><img src='" + mainImagesDir + "bottom.gif' width='162' height=100%></td>");
  document.write("</tr>");
  document.write("</table>");

  document.write("</td>");

  document.write("<td valign='top' width=550>");

  document.write("<table border='0' cellpadding='0' cellspacing='0' width='100%'>");
  document.write("<tr>");
  document.write("<td width='100%'><img border='0' src='" + mainImagesDir + "peoplebecomingbanner.gif' width='529' height='70'></td>");
  document.write("</tr>");
  document.write("</table>");
  document.write("<table border='0' cellpadding='5' cellspacing='0' width='100%'>");
  document.write("<tr><td height='5' colspan='3'></td></tr>");
  document.write("<tr>");
  document.write("<td width='4%'></td>");
  document.write("<td class='normaltext' width='92%' align='center'>");

  /* the page specific info should go here after the call is made in the template */
}

function writeTrailers()
{

  /* this should be called to finish up the end tags for the main table
     after the page specific info is already done */
  document.write("</td>");
  document.write("<td width='4%'></td>");
  document.write("</tr>");

  /* write the contact info if it's needed */
  if (needsContactFooter == 1)
  {
    document.write("<tr><td width='239'>&nbsp</td><td  width='100%' height=100% valign=bottom align='center'>");
    writeContactTrailer();
    document.write("</td></tr>");
  }
  /* finish up the rest of the table closing */
  document.write("</table>");
  document.write("</td>");
  document.write("</tr>");
  document.write("</table>");

  document.write("</table>");
  document.write("</td>");
  document.write("</tr>");
}


/* this function is used to write the contact footer info if needed for that page */
function writeContactTrailer()
{
  document.write("<table border='0' cellpadding='0' cellspacing='0' width='100%'>");
  document.write("<tr>");
  document.write("<td align='center' class='normaltext' witdh='100%'> ");
  document.write("<br><br>");
  document.write("5134 Northwest Highway  &nbsp " + subsectionfooterblockimage + "  &nbsp Garland, Tx  &nbsp"  + subsectionfooterblockimage + " &nbsp 75043");
  document.write("</td>");
  document.write("</tr>");
  document.write("<tr>");
  document.write("<td align='center' class='normaltext' witdh='100%'> ");
  document.write("(972) 279-6145 &nbsp" + subsectionfooterblockimage + "&nbsp (972) 279-6180 Fax");
  document.write("</td>");
  document.write("</tr>");
  document.write("<tr>");
  document.write("<td align='center' class='normaltext' witdh='100%'> ");
  document.write("<a class='normalcolored' href='mailto:newworld@newworldumc.org'>NewWorld@NewWorldUMC.org</a><br />&nbsp");
  document.write("</td>");
  document.write("</tr>");
  document.write("</table>");
  document.write("</td>");
  document.write("</tr>");
  document.write("</table>");
}

