// if running on a fast connection nweb = 1, otherwise 0
var nweb = 1;
var NavApp = navigator.appName;
var NavIsIE =  (NavApp == "Microsoft Internet Explorer");
  if (NavIsIE)
  {
    if (navigator.onLine) nweb = 0;
  }
  else
  {
    nweb = 0;
  }
var notfound = 1;
var pcfound = 0;
var alerts = 0;
var month;
pcmain()

function fastweb(yn)
{
  nweb = yn
  // ie nweb = 1 if this has been called from index.htm
  alert("Thank you: but I have not worked out how to use it!")
}

function pcmain()
{
  if (alerts) alert(pcmain);
  breakout();
  if (nweb) document.all.PCM.src="music/pcwelcome2.wav";
//  if (nweb && notfound) document.all.PCM.src="music/pcwelcome2.wav";
  if (alerts) alert(document.all.PCM.src);
  welcome()
  if (NavIsIE)
  {
    if (pcfound) document.all.notfound.style.display="none";
  }
  else
  {
    if (pcfound) document.getElementById("notfound").style.display="none";
  }
}

function breakout()
{
// alert(notfound)
// alert(top.location.href)
// alert(window.location.href)
// alert(window.document.title)
// alert(window.document.all.tags("meta")[0].name)
// alert(window.document.all.tags("HEAD")[0].id)
// alert(parent.document.all.tags("HEAD")[0].id)
// alert(parent.document.all.tags("HEAD")[0].id)

//  if (window.document.all.tags("meta")[0].name == "Pure Chocolate") notfound = 0;
  if (NavIsIE)
  {
    if (parent.document.all.tags("meta")[0].name == "Pure Chocolate") notfound = 0;
//  if (top.document.all.tags("meta")[1].name == "description") notfound = 0;
// alert(notfound)
    if (parent.document.all.tags("HEAD")[0].id == "PCIndex") notfound = 0;
    if (parent.document.all.tags("HEAD")[0].id == "PC")
    {
      notfound = 0;
      pcfound = 1;
    }
  }
  else
  {
    if (alerts) alert("Not an IE browser");
    if (parent.document.getElementById("Pure Chocolate")) notfound = 0;
      if (parent.document.getElementById("PCIndex")) notfound = 0;
      if (parent.document.getElementById("PC"))
      {
        notfound = 0;
        pcfound = 1;
      }
  }
  if (window != top && notfound) top.location.href=location.href;
  defaultStatus = "Pure Chocolate "
}

function welcome()
{
// preceeding pages
  oldhtmpage = "index.htm";
  oldstatus = "The Shed";
// library
  libhtmpage = "pclibrary.htm";
  libstatus = "My library and links";
// new pages
  htmpage = "index.htm";
  htmstatus = "New";
  fastwebc = "Switch settings for fast connection"
  htmref = "<a href=new/" + htmpage + " onMouseOver='javascript:winstatus(htmstatus); return true'>"
  libhref = "<a href=htm/" + libhtmpage + " onMouseOver='javascript:winstatus(libstatus);return true'>"
  oldhref = "<a href=old/" + oldhtmpage + " onMouseOver='javascript:winstatus(oldstatus);return true'>"
  redirect = "This is the library of Pure Chocolate. "
  relinks = "Chocolate provides links from here to his favourite sites. <br>Please do take a look around before you go. <br><br>"

  if (!pcfound)
  {
    redirect = "This site has been updated. If you see this message, please be patient and you should be redirected to the new Record within about fifteen seconds.";
    redirect = "This site has been updated. Automatic redirection has been postponed in response to feedback. Click " + htmref +  "here</a> for the new Record or follow the links to the right.<br><center><font size=-1>Redirection to the new Record will be attempted after about five minutes.</font>"

    relinks = "Chocolate shall provide links to previous Records for a short time. "
      today = new Date();
      month = today.getMonth()
      date = today.getDate()


    if (month == 11)
    {
      redirect = redirect + "<BR><font size=-1><a href=http://www.moffattfamily.org.uk/purechocolate/deckhall/pcdeckhallnet.htm>Christmas greetings</a></font>"
    }
  }

  side_table()

  items = 10
  wText = new Array(items)
  i = 0
  wText[i] = "<table width=100%><tr><td width=20%></td><td width=60%><BR><BR><center><i>Welcome to Pure Chocolate. We hope you enjoy coming here.</i><br><br>"
  i = i + 1
  wText[i] = "<font face=arial><table width=80% border=1 class=pctable>"
  i = i + 1
  wText[i] =  "<tr><td colspan=2><p align=center><font size=-1 class=pcred>Remember that chocolate should never be less than 52% and always handled with care.</font><hr width=90%>"
  i = i + 1
  wText[i] = "<p align=center>" + redirect + " <br>"
  i = i + 1
  wText[i] = "<br><hr width=90%><font size=-1><p align=center>" + relinks
  i = i + 1
  wText[i] = "<span id=notfound><br>If you are looking for " + oldstatus + ", please click " + oldhref + "here</a>."
  i = i + 1
  wText[i] = "<br>If you are looking for our main pages, please click " + libhref + "here</a>."
  i = i + 1
  wText[i] = "<br>Alternatively click " + htmref + "here</a> for the new Record, but we do not promise it will be any quicker than waiting. Thank you for your patience.</p></font></span></td></tr></table></font>"
  wText[i] = "<br> Thank you.</p></font></span></td></tr></table></font>"
  i = i + 1
  wText[i] = "<table width=50%><tr><td><br><p align=left><i>Thank you for visiting Chocolate's Record.<p align=right>Pure Chocolate</i></td></tr></table></td><td width=20%>"+oldtable+"</td></tr></table><center>"
  i = i + 1
  wText[i] = "<p align=right class=smallss>If you have a fast connection click <a onMouseOver='javascript:winstatus(fastwebc);return true' onClick='javascript:fastweb(1)' style=cursor:hand class=pcred>here</a><br><script>PrintDateHere()</script></p>"

  for (i = 0;i<items;i++)
  {
    document.write(wText[i])
  }
}

function side_table()
{
// to set up side table //
  nrow = "<br><a href=new/index_"
  nrow2 = ".htm onMouseOver='javascript:winstatus(\""
  nrow3 = "\");return true'>"
  nrowe = "</a>"
  oldtable = "<table class=pctable>"
  oldtable = oldtable + "<tr><td class=pcvred><span class=smallss>Old Records:<hr>"
  oldtable = oldtable + nrow + "hand" + nrow2 + "Handy tool" + nrow3 + "The physiotherapy handy tool" + nrowe + "<br>"
  oldtable = oldtable + nrow + "BusTop" + nrow2 + "The adventures of BusTop" + nrow3 + "BusTop" + nrowe + "<br>"
  oldtable = oldtable + nrow + "farewell" + nrow2 + "We laid my father to rest in June" + nrow3 + "Farewell" + nrowe + ""
  oldtable = oldtable + nrow + "cbenews" + nrow2 + "Announcement 2006" + nrow3 + "The CBE for CJM from QEII" + nrowe + ""
  oldtable = oldtable + nrow + "swi" + nrow2 + "Silver wedding" + nrow3 + "The silver anniversary" + nrowe
  oldtable = oldtable + nrow + "C_M" + nrow2 + "Their wedding" + nrow3 + "Carmen und Mario" + nrowe
  oldtable = oldtable + nrow + "ahgs" + nrow2 + "Acklam Hall" + nrow3 + "The reunion" + nrowe
  oldtable = oldtable + nrow + "D_J" + nrow2 + "The wedding" + nrow3 + "Dan and Jane" + nrowe
  oldtable = oldtable + nrow + "S_D" + nrow2 + "The anniversary" + nrow3 + "Stephen and Dorothy" + nrowe
  if (month == 11)
  {
  oldtable = oldtable + nrow + "dh_net" + nrow2 + "Deck the hall with PureChocolate" + nrow3 + "Christmas greeting" + nrowe
  }
  oldtable = oldtable + nrow + "theshed" + nrow2 + "The building of the shed" + nrow3 + "The Shed" + nrowe
  oldtable = oldtable + nrow + "ttf" + nrow2 + "The end of an era" + nrow3 + "TTF evening" + nrowe
  oldtable = oldtable + nrow + "CDJL" + nrow2 + "The glory departs" + nrow3 + "DJ & Carolyn" + nrowe
  oldtable = oldtable + nrow + "ruth" + nrow2 + "Overture to the opera" + nrow3 + "Ruth" + nrowe
  oldtable = oldtable + "<br>" + nrow + "pcl" + nrow2 + "Main pages" + nrow3 + "PC Library" + nrowe
  oldtable = oldtable + "</span></td></tr></table>"
// side table set up //
}

function winstatus(statmsg)
{
  window.status = statmsg
}

function PrintDateHere()
{
    // -- made by A1javascripts.com, please keep these credits when using this script
    days = new Array(7)
    days[1] = "Sunday";
    days[2] = "Monday";
    days[3] = "Tuesday";
    days[4] = "Wednesday";
    days[5] = "Thursday";
    days[6] = "Friday";
    days[7] = "Saturday";
    months = new Array(12)
    months[1] = "January";
    months[2] = "February";
    months[3] = "March";
    months[4] = "April";
    months[5] = "May";
    months[6] = "June";
    months[7] = "July";
    months[8] = "August";
    months[9] = "September";
    months[10] = "October";
    months[11] = "November";
    months[12] = "December";
    today = new Date();
    day = days[today.getDay() + 1]
    month = months[today.getMonth() + 1]
    date = today.getDate()
    year=today.getYear();
    if (year < 2000)
      {
      year = year + 1900;
      }
    document.write ("<span class=smallss><span class=pcdblue> "+ day + ", " + month + " " + date + ", " + year + "</span></span>")
    // -- end hiding
}
