 // starts the warnings if you want to see them
alerts = 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 copynoticeshort = "Copyright Stuart Moffatt &copy; 1997-2002"
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 CloseButton = "<p align=left><input type=\"button\" value=\"Close\" name=\"Close\" onClick=\"window.close();\"></p>"
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_nwc2browser.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 items = 6
var parts = 4
     MusicA = new Array( items * parts + 1 )
     _MusicArray()
var litems = 6
var lparts = 4
     LinksA = new Array( litems * lparts + 1 )
     _LinksArray()
var globalh = 0
var NavApp = navigator.appName;
var NavIsIE =  (NavApp == "Microsoft Internet Explorer");

_pclmain()

function _pclmain()
{
  if (alerts) alert(pclmain);
  notfound = 1
//  if (top.document.all.tags("HEAD")[0].id == "PC") notfound = 0;
//  alert(notfound)
  if (NavIsIE && 0)
  {
    if (parent.document.all.tags("HEAD")[0].id == "PC") notfound = 0;
  }
  if (!NavIsIE && 0)
  {
    if (parent.document.getElementById("PC")) notfound = 0;
  }
  if (document.getElementById("PC")) notfound = 0;

// alert(notfound)
  if (alerts)
  {
    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)
  {
    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) 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) 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 (frames.length)
  {
    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);
  if (parent.frames.length) parent.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 //
   document.scrollForm.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=smallss><a href='javascript:addfavourites()' onMouseOver='javascript:winstatus(mssgfav); return true'>" + mssgfav + "</a></font>")

    }
    else
    {
        document.write('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)
{
  with(locn)
  {
    if (alerts) alert(bgmus.src+" "+sound);
    bgmus.loop = 0
    bgmus.src = sound
  }
}

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
  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 + 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='true' 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>"
  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(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(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(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 linksarray(item,useArray)
{
// used in pclcontacts.htm - try to combine with musicarray
  if (alerts) alert(linksarray+" "+useArray);
  j = item;
//  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(document.all,"+item+")' onMouseOver='winstatus("+MusicC + ");return true' ><LI onMouseOver='this.className=" + myclass + "' onMouseOut='this.className=" + noclass + "'>" + LinksA[j+1] +"</span>";


  MusicB = "<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(loc,pcitem)
{
  h = MusicA[pcitem+3]
  embedsound(MusicA[pcitem],loc,h,0)
  showText(loc.MusicA1,MusicA[pcitem+1])
  showText(loc.MusicA1b,"Index")
  showText(loc.MusicA2,MusicA[pcitem+2])
  displayText(loc.PCM_Item)
  undisplayText(loc.PCM_Index)
}

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)
}

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 pclmus(thisloc,pcmitem)
{
  if (alerts) alert(pcmitem);
  i = pcmitem;
  MusicItem = "../music"+"/"+MusicA[i]
  if (alerts) alert(MusicItem);
  if (alerts) alert(thisloc.location);
}

function _MusicArray()
{
  // 0 is name of file
  // 1 is display text
  // 2 is status text
  // 3 is size of embedded object
    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
    i = i + 4;
    MusicA[i] = "april12";
    MusicA[i+1] = "April 12";
    MusicA[i+2] = "A song for 12 April 2002.";
    MusicA[i+3] = 600
    i = i + 4;
    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
    i = i + 4;
    MusicA[i] = "ThreeHoops";
    MusicA[i+1] = "Three Hoops";
    MusicA[i+2] = "Three Hoops for two clarinets.";
    MusicA[i+3] = 300
    i = i + 4;
    MusicA[i] = "wquintet";
    MusicA[i+1] = "Wind quintet";
    MusicA[i+2] = "Written for the teacher of my favourite oboeist.";
    MusicA[i+3] = 400
}

function _LinksArray()
{
  // 0 is URL
  // 1 is display text
  // 2 is status text
  // 3 is the icon
    if (document.all.tags("HEAD")[0].id != "PCM") LinksA[0] = 1;
    LinksA[0] = "purechocolate/htm/pclerror.htm";
    i = 1;
    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.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://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.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] = "pclerror.htm";
    LinksA[i+1] = "Another";
    LinksA[i+2] = "Another web site";
    LinksA[i+3] = "../images/goldglobe.gif height=12"
}


function change_window(local_a,web_a)
{
  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("","newwin");
  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();
}
