 // starts the warnings if you want to see them
alerts = 0;

// if on the internet nweb must equal zero!
var nweb = 1;
var nweb2 = 0;
var NavApp = navigator.appName;
var NavIsIE =  (NavApp == "Microsoft Internet Explorer");
  if (NavIsIE)
  {
    if (navigator.onLine) nweb = 0;
  }
  else
  {
    nweb = 0;
  }
var url="http://purechocolate.org.uk";
var title="Pure Chocolate - Home page";
var mssgfav = "Add to favourites";
var PCstatus = "Pure Chocolate";
var writetome = "Write to the webmaster";
var emailto = "E-mail ";
var copynoticeshort = "Copyright Stuart Moffatt &copy; 1997-2004"
var copyrightnotice = "<font class=pcblue><B class=vsmallss><span onMouseOver=lowerbar()>"+copynoticeshort+"</span><p align=justify>You may use any of my material for any nonprofit purpose, providing that you acknowledge that I am the author and, if what you have used is visible or audible, provide a link to this site. You may not use my material in any context which may be considered defamatory or libellous.<p align=justify>Please let me know if you do use anything.<p align=justify>Any requests for profit making purposes will be considered. It is likely that I shall ask you to make a donation to my favourite charity. If you find that I have infringed anyone else's copyright, please let me know.<p align=justify>If you arrange to perform any of the music, please let me know where and when, and provide me with a copy of the programme.<p align=justify>Thank you.<p align=right><a href='mailto:copyright@purechocolate.org.uk' onMouseOver='winstatus(writetome);return true'>Stuart Moffatt</a></b></font>";
var disclaimerA = "Chocolate does not necessarily endorse or agree with any views or theological statements,"
var disclaimerB = "which belong solely to the authors thereof, expressed in any of the content of this web page."
var disclaimer = disclaimerA + disclaimerB
var disclaimer2 = disclaimerA + "<br>" + disclaimerB
var CloseButton = "<table width=90%><tr><td width=10%><input type=\"button\" value=\"Close\" name=\"Close\" onClick=\"window.close();\"></td><td align=right><img src=../images/0-logo.gif height=30></table>"
var NWP = "Noteworthy Player"
var NWPI = "Noteworthy Composer Browser plug in"
var NWC = "Noteworthy Composer"
var NWCNotice = "<div class=smallb>You will need the <a href=../download/setup_player.exe onMouseOver='winstatus(NWP);return true'>player <IMG SRC=../images/nwpicon.gif WIDTH=12 HEIGHT=12 VSPACE=0 HSPACE=0 BORDER=0></a> or the <a href=../download/plugin_nwc.exe onMouseOver='winstatus(NWPI);return true'>browser plug-in <IMG SRC=../images/nwciplug.gif WIDTH=12 HEIGHT=12 VSPACE=0 HSPACE=0 BORDER=0></a> to read and hear the Noteworthy files. You may download them from here or you may prefer to visit the <a href=http://www.ntworthy.com/ onMouseOver='winstatus(NWC);return true' target=NewWindow>Noteworthy Composer<IMG SRC=../images/nwcicon.gif WIDTH=12 HEIGHT=12 alt='NoteWorthy Composer' VSPACE=0 HSPACE=0 BORDER=0></a> site for copies.<br><B>Warning:</b> the file you download from here may not be the latest version of Noteworthy Player, but it will read my files.</div>"
var NWCPlayer = "<div class=smallb>You will first need to install the <a href=../download/setup_player.exe onMouseOver='winstatus(NWP);return true'>player <IMG SRC=../images/nwpicon.gif WIDTH=12 HEIGHT=12 VSPACE=0 HSPACE=0 BORDER=0></a>.</div>"
var nwcfile;
var items = 30
// there are presently 27 items, but I want to keep the last two off for the time being - 28/12/02 so reduce this to 23 on publishing it
var parts = 5
     MusicA = new Array( items * parts + 1 )
// used in plcmusic.js
     MusicD = new Array( items * parts + 1 )
// used in plcdaymusic.js
//     old_MusicArray()
var litems = 10;
var lparts = 4
     LinksA = new Array( litems * lparts + 1 )
     _LinksArray()
var globalh = 0
// set to 1 if wav files available - this chooses whether to autoplay wav or nwc
var playwav = 0
var imax;

_pclmain()

function _pclmain()
{
  if (alerts) alert(_pclmain);
  notfound = 1
  notmusic = 1

  if (NavIsIE)
  {
    if (notfound)
    {
//    if (top.document.all.tags("HEAD")[0].id == "PC")
      if (parent.document.all.tags("HEAD")[0].id == "PC")
      {
        notfound = 0;
        nweb2 = 0;
      }
    }
    if (notfound)
    {
// alert(notfound)
// alert(parent.document.all.tags("META")[1].name)
//    if (top.document.all.tags("META")[1].name == "description")
    if(parent.document.all.tags("META")[1].name)
      {
        if (parent.document.all.tags("META")[1].name == "description")
        {
          notfound = 0;
          nweb2 = 1;
        }
        if (parent.document.all.tags("META")[1].name == "music")
        {
          notmusic = 0;
          nweb2 = 1;
        }
      }
    }
  }
  else
  {
    if (notfound)
    {
      if (parent.document.getElementById("HEAD") == "PC")
      {
        notfound = 0;
        nweb2 = 0;
      }
    }
    if (notfound)
    {
    if(parent.document.getElementById("META"))
      {
        if (parent.document.getElementById("META") == "description")
        {
          notfound = 0;
          nweb2 = 1;
        }
        if (parent.document.getElementById("META") == "music")
        {
          notmusic = 0;
          nweb2 = 1;
        }
      }
    }
  }

if(notmusic)
  {
    if(window.parent.frames.length == 1 + nweb2) notfound = 0;
    if (alerts && 0)
    {
      for (i = 0 ; i < top.document.all.length ; i++)
      {
         if (alerts) alert(i + " " + notfound);
         if (alerts) alert(top.document.all[i].tagName);
         if (alerts) alert(top.document.all[i].id);
         if (alerts) alert(top.document.all[i].name);
         if (top.document.all[i].id == "PC" ) notfound = 0;
         if (alerts) alert(notfound)
      }
    }
 //     alert(top.document.all.PureChocolateFrameSet.id)
    if (notfound && nweb)
    {
      top.location.href="pclibrary.htm";
 // The first thing to do is to close any preexisting frames
 // if (window != top) top.location.href="pclibrary.htm";
 // || window.parent.frames.length==1 //
    }
 // The second thing to do is to make sure the document is in a frame
    if (window == top || window.parent.frames.length==1 ) initialiseframes();
 // breakout()
  }
}

function breakout()
{
// not used
  alert (top.location.href == window.parent.location)
  alert(top.location)
  if (frames)
  {
    t$ = "Hello"
    if (top.document.all.tags("PureChocolateFrameSet")) alert(t$ + "Hit");
    alert(top.document.all.tags("PureChocolateFrameSet").length)
    alert(top.document.all.tags("PureChocolate").length)
    alert(t$)
    for (i=0;i<10;i++)
    {
      alert(top.document.all.tags[i])
    }
  }
  alert ("made it")
  alert (top.document.all.PureChocolateFrameSet.id)
  if (top.document.all.PureChocolateFrameSet.id != "PC")
  {
    if (window != top) top.location.href=location.href;
  }
  defaultStatus = PCstatus
}

function winstatus(statmsg)
{
  window.status = statmsg
}

// initialiseframes
function initialiseframes()
{
  pframe = "<FRAMESET ID=PC NAME=PureChocolateFrameSet ROWS=90%,10% BORDER=0><FRAMESET COLS=24%,76% BORDER=0><FRAMESET ROWS=73%,27% BORDER=0><FRAME SCROLLING=AUTO  NAME=pclsidebar SRC=pclsidebar.htm><FRAME SCROLLING=AUTO  NAME=pclsidebot SRC=pclsidebot.htm></FRAMESET><FRAME SCROLLING=AUTO  NAME=pclmain SRC=pclmain.htm></FRAMESET><FRAME SCROLLING=AUTO  NAME=pclbase SRC=pclbase.htm></FRAMESET>"
  if (alerts) alert(pframe);
/* the frames are set up as above */
  if (window == top || window.parent.frames.length == 1 ) document.write(pframe);
// fill in the lower sidebar
  lowerbar();
  closebar();
}
function closebar()
{
  defaultStatus = PCstatus
  if (alerts) alert(top.location.href);
// initialise variables for later reference
  if (parent.frames.length - nweb2)
  {
    maintarg = parent.pclmain
    targ = maintarg.document
    sidebartarg = parent.pclsidebar
    targs = sidebartarg.document
    sidebottarg = parent.pclsidebot
    with(maintarg)
    {
      B=document.all;
      C=document.layers;
    }
  }
}

function lowerbar()
{
  if (alerts) alert(lowerbar);
  bgsoundsrc = "../music/nosound.au"
  sbimage = "../images/bground.png"
  sbimage2 = "../images/goldglobe.gif"
  sbimage3 = "../images/chocolate.jpg"
  sidebarframe = ""
  sidebarframe = sidebarframe + "<HEAD><LINK rel=stylesheet type=text/css href='../bin/pcstyle.css'></head><BODY></body>"
  sidebarframe = sidebarframe + "<bgsound id=bgmus src='" + bgsoundsrc + "' loop=-1 balance=-10000>"
  sidebarframe = sidebarframe + "<IMG SRC=" + sbimage + " name=topl HEIGHT=70 WIDTH=70 HSPACE=0 VSPACE=0 onMouseOver=document.topl.src='" + sbimage3 + "';document.botr.src='" + sbimage2 + "' onMouseOut=javascript:document.topl.src='" + sbimage + "'>"
  sidebarframe = sidebarframe + "<P ALIGN=RIGHT>"
  sidebarframe = sidebarframe + "<IMG src=" + sbimage2 + " name=botr HEIGHT=30 WIDTH=30 HSPACE=0 VSPACE=0 onMouseOver=javascript:document.botr.src='" + sbimage + "';document.topl.src='" + sbimage2 + "' onMouseOut=javascript:document.topl.src='" +  sbimage + "';document.botr.src='" + sbimage2 + "'></p>"
  sidebarframe = sidebarframe + ""
  if (alerts) alert(sidebarframe);
  // this causes problems on the web as parent.frames.length is always true
  if (alerts) alert(frames.length);
  if (window.parent.frames.length - nweb2) parent.pclsidebot.document.write(sidebarframe);
  if (frames.length && nweb2) pclsidebot.document.write(sidebarframe);
}


//Date functions
function PrintDateHere()
{
    // -- made by A1javascripts.com, please keep these credits when using this script
    // -- I have split this into two:
    //     - to setup the arrays (and use them elsewhere)
    //     - to show the date (or just calculate its parts for use elsewhere)
    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
}

function startScroller(msg)
{
// msg must be defined in the document //
   if ( document.scrollForm ) document.scrollForm.scrolling_message.value = msg;
   if ( document.scroll_Form ) document.scroll_Form.scrolling_message.value = msg;

   msg = msg.substring(1, msg.length) + msg.substring(0, 1)
// This editable setting dictates how quickly
// each character moves across the scroll box
// (ex. 150=.15 seconds).
   mssg = msg
   setTimeout("startScroller(mssg)", 150)

}

function favourites()
{
    if (document.all)
    {
        document.write("<br><font class=vsmallss><a href='javascript:addfavourites()' onMouseOver='javascript:winstatus(mssgfav); return true'>" + mssgfav + "</a></font>")

    }
    else
    {
        document.write('<br><font class=vsmallss>Press <B>Ctrl-D</B> to add this page to your Bookmarks.')
    }
}

function addfavourites()
{
    if (document.all)
    {
        window.external.AddFavorite(url,title);
    }
}

function showPic(picid,pic,vb)
{
  with (picid)
  {
   newpic=pic
   if (vb) style.visibility="hidden";
   src=newpic
   filters.item(0).apply()
   style.visibility="visible"
   filters.item(0).play()
  }
}

function playSound(locn,sound,silence)
{
  with(locn)
  {
    if (alerts) alert(bgmus.src+" "+sound);
    bgmus.loop = 0
    bgmus.src = sound
    if (!silence)
// This silences anything that may be playing already //
// Requires a field called embed //
    {
      embedsound("","",10,playwav)
  }
    if (silence == 2 || silence == 4)
    {
    if (alerts) alert(midembed.src);
      sound = midembed.src
    if (alerts)
    {
      alert(sound)
      alert(sound.substring(sound.lastIndexOf("/")+1,sound.lastIndexOf(".")))
      }
    sound = sound.substring(sound.lastIndexOf("/")+1,sound.lastIndexOf("."))
    if (alerts) alert("Before " + sound + " after");
    embedsound(sound,"",globalh,silence)
  }

  }
}

function showText(locn,text)
{
  with(locn)
  {
  style.visibility = "visible"
  innerText = text
  if (text.indexOf('<')>-1) innerHTML = text;
  }
}

function hideText(locn,text)
{
// be careful this cannot unhide itself
  with(locn)
  {
  style.visibility = "hidden"
  innerText = text
  }
  if (alerts) alert(locn.innerText);
}

function testing()
{
  alert("OK")
  alert(this.name)
}

function embedsound(source,doc,h,yesno)
{
  globalh = h
  h = 0
  nwcplay = "true"
  wavplay = "false"
  midplay = "false"
  if (yesno)
    {
      nwcplay = "false"
      wavplay = "true"
      midplay = "false"
    }
  if (1)
    {
      nwcplay = "false"
      wavplay = "false"
      midplay = "true"
  // I need some means by which I can determine whether or not plugins work!
    }
  if (yesno == 2)
    {
      nwcplay = "true"
      wavplay = "false"
      midplay = "false"
    }
  if (yesno == 4)
    {
      nwcplay = "false"
      wavplay = "false"
      midplay = "false"
    }

  var embedded = "<P align=center><EMBED name=nwcembed pluginspage=http://www.noteworthysoftware.com/composer/plugin.htm align=baseline src="
  embedded = embedded + "../music/" + source +".nwc width=100% height=" + h +" type=application/x-nwc autostart='" + nwcplay + "' vspace=5 hspace=5 border=2 id=NWC></P>"
  embedded = embedded + "<P align=center><EMBED name=wavembed align=baseline src="
  embedded = embedded + "../music/" + source +".wav height=0 autostart='" + wavplay + "' vspace=5 hspace=5 border=2 id=WV></P>"
  embedded = embedded + "<P align=center><EMBED name=midembed align=baseline src="
  embedded = embedded + "../music/" + source +".mid height=10 controls='small console' autostart=" + midplay + " vspace=5 hspace=5 border=2 id=MD></P>"
  //  autoplay='" + wavplay + "'
  if (alerts) alert(embedded);
  if (NavIsIE)
  {
    if (document.all.embed.innerHTML)
    {
      document.all.embed.innerHTML = embedded;
    }
  }
  else
  {
    if (document.getElementById("embed").innerHTML)
    {
      document.getElementById("embed").innerHTML = embedded;
    }
  }

// When working locally IE has started to complain that playing the mid file would change the root
// must sort this out sometime! 12/04
}

function _embedsound(source,doc,h,yesno)
{
  globalh = h
  h = 0
  var embedded = "<P align=center><EMBED pluginspage=http://www.noteworthysoftware.com/composer/plugin.htm align=baseline src="
  embedded = embedded + "../music/" + source +".nwc width=100% height=" + h +" type=application/x-nwc autostart='true' vspace=5 hspace=5 border=2 id=NWC></P>"
  embedded = embedded + "<P align=center><EMBED align=baseline src="
  embedded = embedded + "../music/" + source +".wav height=0 autostart='false' vspace=5 hspace=5 border=2 id=WV></P>"
  if (alerts) alert(embedded);
  document.all.embed.innerHTML = embedded
}

function old_embedsound(source,doc,h,yesno)
{
  globalh = h
  h = 0
  var embedded = "<P align=center><EMBED pluginspage=http://www.noteworthysoftware.com/composer/plugin.htm align=baseline src="
  embedded = embedded + source +".nwc width=100% height=" + h +" type=application/x-nwc autostart='false' vspace=5 hspace=5 border=2 id=NWC></P>"
  embedded = embedded + "<P align=center><EMBED align=baseline src="
  embedded = embedded + source +".wav height=0 autostart='false' vspace=5 hspace=5 border=2 id=WV></P>"
  embedded = embedded + "<P align=center><EMBED align=baseline src="
  embedded = embedded + "../music/" + source +".mid height=10 controls='small console' autostart='true' vspace=5 hspace=5 border=2 id=MD></P>"
  if (alerts) alert(embedded);
  with (doc)
  {
    document.write(embedded)
  }
}

function _revealembedded(_NWC,_WAV)
{
  if (alerts) alert(globalh);
  if(_NWC>1) _NWC = globalh;
  document.all.NWC.height = Math.max(_NWC,1);
  document.all.WV.height = Math.max(_WAV,1);
}

function old_revealembedded(_NWC,_WAV)
{
  document.all.NWC.height = Math.max(_NWC,1);
  document.all.WV.height = Math.max(_WAV,1);
}

function donothing() {testing();}

function musicarray_old(item,useArray)
{
// used in pclmusic.htm - try to combine with linksarray - but need extra part for icon
  if (alerts) alert(this+" "+useArray);
  j = item;
//  var thisArray = new Array()
//  var tempArray = thisArray.concat(useArray)
//    MusicC = '"'+tempArray[(j+2)]+'"'
  MusicC = '"'+MusicA[(j+2)]+'"'
//  MusicB = "<u class=llink><span onClick='_pclmus_new_old(document.all,"+item+")' onMouseOver='winstatus("+MusicC + ");return true' style='cursor:hand'><LI>" + MusicA[j+1] +"</span></u>";
  myclass = '"llink"'
  noclass = '""'
  MusicB = "<span class=pclinka onClick='_pclmus_new_old(document.all,"+item+")' onMouseOver='winstatus("+MusicC + ");return true' ><LI onMouseOver='this.className=" + myclass + "' onMouseOut='this.className=" + noclass + "'>" + MusicA[j+1] +"</span>";
  if (alerts) alert(MusicB + item);
  document.write(MusicB);
}

function older_musicarray(item,useArray)
{
// used in pclmusic.htm - try to combine with linksarray - but need extra part for icon
  if (alerts) alert(this+" "+useArray);
  j = item;
  jeven = (item - 1)/parts
  jeven = jeven - Math.floor(jeven/3)*3
  newcell = "<tr><td>"
  if (jeven) newcell = "<td>";
  if (alerts) alert (item + " "+jeven)
//  var thisArray = new Array()
//  var tempArray = thisArray.concat(useArray)
//    MusicC = '"'+tempArray[(j+2)]+'"'
  MusicC = '"'+MusicA[(j+2)]+'"'
//  MusicB = "<u class=llink><span onClick='_pclmus_new_old(document.all,"+item+")' onMouseOver='winstatus("+MusicC + ");return true' style='cursor:hand'><LI>" + MusicA[j+1] +"</span></u>";
  myclass = '"llink"'
  noclass = '""'
//  MusicB = "<span class=pclinka onClick='_pclmus_new_old(document.all,"+item+")' onMouseOver='winstatus("+MusicC + ");return true' ><LI onMouseOver='this.className=" + myclass + "' onMouseOut='this.className=" + noclass + "'>" + MusicA[j+1] +"</span>";
  MusicB = newcell + "<span class=pclinka onClick='_pclmus_new_old(document.all,"+item+")' onMouseOver='winstatus("+MusicC + ");return true' ><LI onMouseOver='this.className=" + myclass + "' onMouseOut='this.className=" + noclass + "'>" + MusicA[j+1] +"</span>";
//  MusicB = newcell + "<span class=pclinka onClick='change_window(\"" + LinksA[0] + "\"," + MusicL + ");' onMouseOver='this.className=" + myclass + "; winstatus(" + MusicC + ");return true' onMouseOut='this.className=" + lclass + "'><LI>" + MusicI + " " + LinksA[j+1] + "</span>";

  if (alerts) alert(MusicB + item);
  document.write(MusicB);
}

function linksarray(item,useArray)
{
// used in pclcontacts.htm - try to combine with musicarray
  if (alerts) alert(linksarray+" "+useArray);
  j = item;
  jeven = (item - 1)/lparts
  jeven = jeven - Math.floor(jeven/2)*2
  newcell = "<tr><td>"
  if (jeven) newcell = "<td>";
  if (alerts) alert (item + " "+jeven)
//  var thisArray = new Array()
//  var tempArray = thisArray.concat(useArray)
//    LinkC = '"'+tempArray[(j+2)]+'"'
  MusicC = '"'+LinksA[(j+2)]+'"'
  MusicI = LinksA[(j+3)];
  if (!MusicI) MusicI = "../images/pcicon.gif height=12";
  MusicI = "<IMG src=" + MusicI + " >";
  MusicL = LinksA[(j)]
  if (!MusicL) MusicL = "/";
  MusicL = '"' + MusicL + '"';
  lclass = '"pclinka"';
  myclass = '"llink"';
  noclass = '""';
//  MusicB = "<span class=pclinka onClick='_pclmus_new_old(document.all,"+item+")' onMouseOver='winstatus("+MusicC + ");return true' ><LI onMouseOver='this.className=" + myclass + "' onMouseOut='this.className=" + noclass + "'>" + LinksA[j+1] +"</span>";


  MusicB = newcell + "<span class=pclinka onClick='change_window(\"" + LinksA[0] + "\"," + MusicL + ");' onMouseOver='this.className=" + myclass + "; winstatus(" + MusicC + ");return true' onMouseOut='this.className=" + lclass + "'><LI>" + MusicI + " " + LinksA[j+1] + "</span>";

//  MusicB = "<span class=pclinka onClick='change_window(\"" + LinksA[0] + "\"," + MusicL + ");' onMouseOver='winstatus("+MusicC + ");return true' ><LI onMouseOver='this.className=" + myclass + "' onMouseOut='this.className=" + noclass + "'>" + MusicI + LinksA[j+1] +"</LI></span>";
  document.write(MusicB);
}


function musicarray_old(item)
{
  if (alerts) alert(musicarray);
  i = item;
  MusicB = "<a href=../music/pclmus.htm onClick='_pclmus("+item+")' onMouseOver='winstatus(MusicA["+(i+2)+"]);set_pcmitem(" + item + ");return true'><LI>" + MusicA[i+1] +"</a>";
  if (alerts) alert(MusicB + item);
  document.write(MusicB);
}

function set_pcmitem(musno)
{
    if (alerts) alert("Hi"+musno + MusicA[0]);
    MusicA[0] = musno;
  if (alerts) alert("Hi"+MusicA[0]);
}

function _pclmus_new_old(loc,pcitem)
{
  h = MusicA[pcitem+3]
  nwcfile = MusicA[pcitem]+".nwc"
  embedsound(MusicA[pcitem],loc,h,playwav)
  showText(loc.MusicA1,MusicA[pcitem+1])
  showText(loc.MusicA1b,"Index")
  showText(loc.MusicA2,MusicA[pcitem+2])
  displayText(loc.PCM_Item)
  undisplayText(loc.PCM_Index)
  if (MusicA[pcitem+4]) showText(loc.musWds," This piece has words. Click <a href=../words/"+MusicA[pcitem]+".htm onMouseOver='winstatus(MusicA["+(pcitem+2)+"]);return true' target=NewWindow>here</a> to read them.");
}

function play_nwcfile(nwcf)
{
  nwcp.href="../music/"+nwcf;
//  alert(nwcp.href)
}

function _pclmus_index(loc,pcitem)
{
//  h = MusicA[pcitem+3]
//  embedsound(MusicA[pcitem],loc,h,0)
  showText(loc.MusicA1,"Music Index")
  showText(loc.MusicA1b,"Index")
//  showText(loc.MusicA2,MusicA[pcitem+2])
  undisplayText(loc.PCM_Item)
  displayText(loc.PCM_Index)
  loc.musWds.innerText = ""
}

function _pclmus(pcitem)
{
  if (alerts) alert(pcitem);
}

function displayText(locn)
{
  if (alerts) alert(displayText + " " + locn.id);
  with(locn)
  {
  style.display = "block"
  }
}

function undisplayText(locn)
{
// be careful this cannot unhide itself
// alert(displayText + " " + locn.style.display)
  with(locn)
  {
  style.display = "none"
  }
// alert(locn.innerText)
}

function swapText(locd,loch)
{
  displayText(locd);
  undisplayText(loch);
}

function pclmus(thisloc,pcmitem)
{
  if (alerts) alert(pcmitem);
  i = pcmitem;
  MusicItem = "../music"+"/"+MusicA[i]
  if (alerts) alert(MusicItem);
  if (alerts) alert(thisloc.location);
}

function old_MusicArray()
{
  // 0 is name of file
  // 1 is display text
  // 2 is status text
  // 3 is size of embedded object
    for (i = 0;i < Math.min(items,imax); i++)
     {
       if (alerts) alert(i);
       MusicD[i]="abce"
     }
    if (document.all.tags("HEAD")[0].id != "PCM") MusicA[0] = 1;
    i = 1;
    MusicA[i] = "march21";
    MusicA[i+1] = "March 21";
    MusicA[i+2] = "A sound for 21 March 2002.";
    MusicA[i+3] = 500
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "april12";
    MusicA[i+1] = "April 12";
    MusicA[i+2] = "A song for 12 April 2002.";
    MusicA[i+3] = 600
    MusicA[i+4] = 1
    i = i + parts;
    MusicA[i] = "june15";
    MusicA[i+1] = "June 15";
    MusicA[i+2] = "A birthday song for 15 June 2002.";
    MusicA[i+3] = 300
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "july23";
    MusicA[i+1] = "July 23";
    MusicA[i+2] = "A Irish jig for 23 July 2002.";
    MusicA[i+3] = 400
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "august25";
    MusicA[i+1] = "August 25";
    MusicA[i+2] = "A languid piano piece";
    MusicA[i+3] = 300
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "august31";
    MusicA[i+1] = "August 31";
    MusicA[i+2] = "a string quartet movement";
    MusicA[i+3] = 400
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "september02";
    MusicA[i+1] = "September 2";
    MusicA[i+2] = "Japanese sounds in western ears";
    MusicA[i+3] = 600
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "september05";
    MusicA[i+1] = "September 5";
    MusicA[i+2] = "A march for piano";
    MusicA[i+3] = 300
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "september06";
    MusicA[i+1] = "September 6";
    MusicA[i+2] = "Japan in Vienna for piano";
    MusicA[i+3] = 400
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "october17";
    MusicA[i+1] = "October 17";
    MusicA[i+2] = "A slow trot";
    MusicA[i+3] = 300
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "october25";
    MusicA[i+1] = "October 25";
    MusicA[i+2] = "A fanfare for the day";
    MusicA[i+3] = 400
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "october31";
    MusicA[i+1] = "October 31";
    MusicA[i+2] = "A frolic";
    MusicA[i+3] = 300
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "november4";
    MusicA[i+1] = "November 4";
    MusicA[i+2] = "A light walk";
    MusicA[i+3] = 300
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "november23";
    MusicA[i+1] = "November 23";
    MusicA[i+2] = "Activity";
    MusicA[i+3] = 300
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "december28";
    MusicA[i+1] = "December 28";
    MusicA[i+2] = "Trotting";
    MusicA[i+3] = 300
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "estutmirleid";
    MusicA[i+1] = "<span class=pcvred>Es tut mir leid</span>";
    MusicA[i+2] = "A song that could have been sung by the villagers to the returning Naomi, but that it is in German!";
    MusicA[i+3] = 400
    MusicA[i+4] = 1
    i = i + parts;
    MusicA[i] = "ThreeHoops";
    MusicA[i+1] = "Three Hoops";
    MusicA[i+2] = "Three Hoops for two clarinets.";
    MusicA[i+3] = 300
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "wquintet";
    MusicA[i+1] = "Wind quintet";
    MusicA[i+2] = "Written for the teacher of my favourite oboeist.";
    MusicA[i+3] = 400
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "auf2";
    MusicA[i+1] = "Auf Wiedersehen";
    MusicA[i+2] = "One day we must all cross the one stranded river. Where then will you be?";
    MusicA[i+3] = 400
    MusicA[i+4] = 1
    i = i + parts;
    MusicA[i] = "thiswasnotheway";
    MusicA[i+1] = "This was not the way";
    MusicA[i+2] = "A setting of words by a contemporary writer.";
    MusicA[i+3] = 500
    MusicA[i+4] = 1
    i = i + parts;
    MusicA[i] = "goelovelyrose";
    MusicA[i+1] = "Goe lovely rose";
    MusicA[i+2] = "A setting of words by a Edmund Waller.";
    MusicA[i+3] = 500
    MusicA[i+4] = 1
    i = i + parts;
    MusicA[i] = "serialqt";
    MusicA[i+1] = "String quartet movement";
    MusicA[i+2] = "An exercise in 12-tones.";
    MusicA[i+3] = 500
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "3wquartetmarches";
    MusicA[i+1] = "Wind quartet movements";
    MusicA[i+2] = "3 marches for children.";
    MusicA[i+3] = 400
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "elegy_flute_strings";
    MusicA[i+1] = "Elegy";
    MusicA[i+2] = "For two flutes and strings";
    MusicA[i+3] = 500
    MusicA[i+4] = 0
    i = i + parts;
    MusicA[i] = "habakuk2_2r";
    MusicA[i+1] = "The vision is not yet";
    MusicA[i+2] = "A setting of Habakuk 2:2-4 for Babillage.";
    MusicA[i+3] = 500
    MusicA[i+4] = 1
    i = i + parts;
    MusicA[i] = "ineedthee";
    MusicA[i+1] = "O Lord, I need thee";
    MusicA[i+2] = "A setting of words by Stephen Henwood.";
    MusicA[i+3] = 300
    MusicA[i+4] = 1
    i = i + parts;
    MusicA[i] = "fanfareformay2";
    MusicA[i+1] = "Fanfare";
    MusicA[i+2] = "For brass ensemble";
    MusicA[i+3] = 300
    MusicA[i+4] = 0
    imax = 1 + (i - 1)/parts;
}

function _LinksArray()
{
  // 0 is URL
  // 1 is display text
  // 2 is status text
  // 3 is the icon
  if (NavIsIE)
  {
    if (document.all.tags("HEAD")[0].id != "PCM") LinksA[0] = 1;
  }
  else
  {
    if (document.getElementById("HEAD") != "PCM") LinksA[0] = 1;
  }
  LinksA[0] = "purechocolate/htm/pclerror.htm";
  i = 1;
//  LinksA[i] = "http://abacus.purechocolate.org.uk";
  LinksA[i] = "  http://thomsonreuters.com/products_services/taxacct/united_kingdom/abacus_enterprise/"
//    LinksA[i+1] = "<span style='position:absolute;'><span style='position:relative;left:-8px;'><font size=+4 color=#B0D020 style='position:relative;top:-19;'>&bull;</font></span></span>&nbsp;&nbsp;&nbsp;Deloitte";
//  LinksA[i+1] = "<span style='position:absolute;'><span style='position:relative;left:-8px;'><font size=+4 color=#9CD100 style='position:relative;top:-19;'>&bull;</font></span></span>&nbsp;&nbsp;&nbsp;Abacus";
  LinksA[i+1] = "<span style='position:absolute;'><span style='position:relative;left:-8px;'></span></span>Abacus";
  LinksA[i+2] = "abacus: the worlds most taxing spreadsheet";
//    LinksA[i+3] = "../images/firm_logo.gif style='position:absolute;left:+25px;clip:rect(64px,228px,75px,217px)' height=90"
//  LinksA[i+3] = "../images/whitepixel.gif"
  LinksA[i+3] = "../images/trdots.jpg height=12 width=12"
//    LinksA[i] = "http://andersenreunited.com";
//    LinksA[i+1] = "<span style='position:absolute;left:42px'>Andersen alumni</span>";
//    LinksA[i+2] = "Andersen Alumni web site";
//    LinksA[i+3] = "../images/andersen_logo.gif style='position:absolute;left:22px;clip:rect(3px,17px,17px,3px)' height=30"
  i = i + 4;
  LinksA[i] = "http://www.alumni.net";
  LinksA[i+1] = "Alumni Net";
  LinksA[i+2] = "Alumni.net web site";
  LinksA[i+3] = ""
  i = i + 4;
//    LinksA[i] = "http://www.andersen.com";
//    LinksA[i] = "http://www.awo.com";
//  Some networks block access to andersen.com and awo.com, therefore try using
//  There is also a de.purechocolate.org.uk which I should think about including somehow
  LinksA[i] = "../htm/index_aa.htm";
//  LinksA[i] = "http://aa.purechocolate.org.uk";
  LinksA[i+1] = "Andersen";
  LinksA[i+2] = "Arthur Andersen web site";
  LinksA[i+3] = "../images/solosphere.gif height=12"
  i = i + 4;
  LinksA[i] = "../htm/index_aa_de.htm";
//    LinksA[i] = "http://de.purechocolate.org.uk";
  LinksA[i+1] = "Andersen de";
  LinksA[i+2] = "Arthur Andersen Deutschland web site";
  LinksA[i+3] = "../images/solosphere.gif height=12"
// andersenreunited.com is now defunct //
//    i = i + 4;
//    LinksA[i] = "http://andersenreunited.com";
//    LinksA[i+1] = "Andersen alumni";
//    LinksA[i+2] = "Andersen Alumni web site";
//    LinksA[i+3] = "../images/solosphere.gif height=12"
  i = i + 4;
  LinksA[i] = "http://moffattfamily.org.uk/darkchocolate/index.htm";
  LinksA[i+1] = "Dark Chocolate";
  LinksA[i+2] = "Dark Chocolate - The Question";
  LinksA[i+3] = "../images/goldglobe.gif height=12"
  i = i + 4;
  LinksA[i] = "http://deloitte.purechocolate.org.uk";
// something on the deloitte site blocks it being windowed in this!
  LinksA[i] = "http://www.deloitte.com";
// Aha! If we use the IP address it works! //
  LinksA[i] = "http://deloitte2.purechocolate.org.uk";
//    LinksA[i+1] = "<span style='position:absolute;'><span style='position:relative;left:-8px;'><font size=+4 color=#B0D020 style='position:relative;top:-19;'>&bull;</font></span></span>&nbsp;&nbsp;&nbsp;Deloitte";
  LinksA[i+1] = "<span style='position:absolute;'><span style='position:relative;left:-8px;'><font size=+4 color=#9CD100 style='position:relative;top:-19;'>&bull;</font></span></span>&nbsp;&nbsp;&nbsp;Deloitte";
  LinksA[i+2] = "Deloitte Touche Tohmatsu a Swiss Verien web site";
//    LinksA[i+3] = "../images/firm_logo.gif style='position:absolute;left:+25px;clip:rect(64px,228px,75px,217px)' height=90"
  LinksA[i+3] = "../images/whitepixel.gif"
  i = i + 4;
  LinksA[i] = "http://www.hebrondowlais.org.uk";
  LinksA[i+1] = "Hebron";
  LinksA[i+2] = "Hebron Evangelical Church";
  LinksA[i+3] = "../images/goldglobe.gif height=12"
  i = i + 4;
  LinksA[i] = "http://www.ic.ac.uk";
  LinksA[i+1] = "Imperial College";
  LinksA[i+2] = "Imperial College (formerly of Science and Technology) of Science, Technology and Medicine";
  LinksA[i+3] = "../images/ic_text_05.gif height=14"
  i = i + 4;
  LinksA[i] = "http://www.farese.com/rbcd/rbcd.htm";
  LinksA[i+1] = "Johnny Farese";
  LinksA[i+2] = "Johnny Farese - reformed links";
  LinksA[i+3] = "../images/goldglobe.gif height=12"
  i = i + 4;
  LinksA[i] = "http://www.ntworthy.com";
  LinksA[i+1] = "Noteworthy composer";
  LinksA[i+2] = "Noteworthy composer web site";
  LinksA[i+3] = "../images/nwcicon.gif height=12"
//  i = i + 4;
//  LinksA[i] = "http://uk.purechocolate.org.uk";
//  LinksA[i] = "http://www.moffattfamily.org.uk/chocolate/gmx/blue_pc_new.htm"
//  LinksA[i+1] = "Blue page";
//  LinksA[i+2] = "Search and login ";
//  LinksA[i+3] = "../images/goldglobe.gif height=12"
}

function change_window(local_a,web_a)
{
  change_page(local_a,web_a)
}

// This is a script to allow pclcontacts to work
// And this must be pointing correctly for local use! Script will find the absolute address above this level
var htm_location = "Inputs/";

function change_page(local,web)
{
  extwin = window.open("","newwin");
  with(extwin)
  {
  location_href = web;
  if (nweb) local_href(local);
  location.href = location_href;
  defaultStatus = "Pure Chocolate Library";
  }
}

function local_href(local)
{
  location_href = htm_location + local;
  current_href = location.href;
  i = current_href.indexOf('Inputs');
  parent_href = current_href.substring(0,i);
  location_href = parent_href + location_href;
}

function old_change_window(local_a,web_a)
{
// this script only works if extwin is not already open - how do you know if it is open?
  newcontent = "<script language='JavaScript' src='../bin/cdscript.js'></script><SCRIPT language='JavaScript'>var local_address = \"" + local_a + "\";var web_address = " + web_a + ";change_page(local_address,web_address);</SCRIPT>";
  extwin = window.open("index_blank.htm","newwin");
  extwin.document.write("Hello")
  alert("hi")
  extwin.document.write("<script language='JavaScript' src='../bin/cdscript.js'></script>");
  extwin.document.write("<SCRIPT language='JavaScript'>");
  extwin.document.write("var local_address = \"" + local_a + "\";");
  extwin.document.write("var web_address = \"" + web_a + "\";");
  extwin.document.write("change_page(local_address,web_address)");
  extwin.document.write("</SCRIPT>");
//  extwin.document.close();
}

function freeparking (i)
{
i$ = ""
if (i == 2)
{
i$ = i$ + "<hr><table width=155 align=left border=0 cellpadding=0 cellspacing=0>"
i$ = i$ + "<tr>"
i$ = i$ + "  <td width=155 align=left>"
i$ = i$ + "   <font face=arial size=0 color=#0000FF>"
i$ = i$ + "    Is your domain name available?"
i$ = i$ + "     <form action='http://www.freeparking.co.uk/affiliates/checkdomain.asp' method='post' target='newwhoiswin'>"
i$ = i$ + "      <input type='text' name='domainname' size=9>"
i$ = i$ + "      <select name='tld'>"
i$ = i$ + "       <option value=1>.com"
i$ = i$ + "       <option value=2>.org"
i$ = i$ + "       <option value=3>.net"
i$ = i$ + "       <option value=4>.co.uk"
i$ = i$ + "       <option value=5>.org.uk"
i$ = i$ + "       <option value=6>.uk.com"
i$ = i$ + "       <option value=7>.uk.net"
i$ = i$ + "       <option value=8>.gb.com"
i$ = i$ + "       <option value=9>.gb.net"
i$ = i$ + "      </select>"
i$ = i$ + "      <input type='hidden' name='referrer' value='40403'>"
i$ = i$ + "      <input type='image' src='http://www.freeparking.co.uk/affiliates/images/fpaff.gif' width=95%>"
i$ = i$ + "     </form>"
i$ = i$ + "    </td>"
i$ = i$ + "   </tr>"
i$ = i$ + "  </table> "
}
if (i == 1)
{
i$ = i$ + "<table width=155 align=center border=0 cellpadding=0 cellspacing=0>"
i$ = i$ + " <tr>"
i$ = i$ + "  <td width=155 align=left>"
i$ = i$ + "   <font face=arial size=0>"
i$ = i$ + "    <form action='http://www.freeparking.co.uk/default.asp' method='post'>"
i$ = i$ + "     <input type='hidden' name='referrer' value='40403'>"
i$ = i$ + "     <input type='image' src='http://www.freeparking.co.uk/affiliates/images/fpaff.gif' width=95%>"
i$ = i$ + "    </form>"
i$ = i$ + "   </td>"
i$ = i$ + "  </tr>"
i$ = i$ + " </table><hr>"
}
else
{
  i$ = i$ + "<form action='http://www.freeparking.co.uk/default.asp' method='post'>"
  i$ = i$ + "<input type='hidden' name='referrer' value='40403'>"
  i$ = i$ + "Freeparking><input type='image' src='images/bullet1.gif' height=8px>"
  i$ = i$ + "</form>"

}
document.write(i$)
}


// Think about how to generalise this code!
// Used on pclmusic only so far.
var cookieName = "pclmusic";  // May be user-defined, or leave as-is.
var cookieValue = "NoValue";  // Leave as-is.
var cookieArray = new Array;
function bakeCookie()
{
  var exp = new Date()
  var exptime = exp.getTime() + (60 * 60 * 1000)
  exp.setTime(exptime)
  document.cookie = cookieName + "=" + escape(cookieValue) + "; expires=" + exp.toGMTString();
  document.cookie = ("ConType="+escape("Slow"));
  document.cookie = ("Other="+escape("NotUsed"));
}
function readCookie()
{
  temp$ = document.cookie
  var cookieArray = temp$.split(";")
//  alert(cookieArray[2])
  var search = cookieName + "=";
  if (document.cookie.length > 0)
  {
    cookiePosition = document.cookie.indexOf(search);
    if (cookiePosition != -1) return 1;
  }
}
function playpclmusic()
{
  if (NavIsIE)
  {
    if (navigator.cookieEnabled)
    {
      var isCookieHere = readCookie();
      playSound("","../music/nosound.au")
      displayText(PCM_onreturn)
      undisplayText(PCM_onopen)
      if (isCookieHere == null)
      {
        bakeCookie();
//        playSound("","../music/pclmusic.mid")
        playSound("",momentmusmid)
        undisplayText(PCM_onreturn)
        displayText(PCM_onopen)
//    document.write("<EMBED SRC='" + fileName + "' HIDDEN AUTOSTART=TRUE>");
      }
    }
  }
}

// The variable pclmusic seems to work, but there is nowhere to turn off the music the visitor turns it on after the cookie has been written!
