// JavaScript functions and variables used by Bromsgrove Concerts pages
//
// written by Andy Dix 29/12/02
//
// amended 04/04/03 - click on home page loads www.bromsgrove-concerts.org.uk (for searches)
// amended 17/4/03 - move newWindow function to here so it can be used generally
// amended 24-25/7/03 - add version 2 of writeEntry
// amended 7/12/03 - add emailLink function - modified 13/12/03
// amended Jul-Aug 2004 for site redesign
// amended 19-20/7/05 for changes to menus
// amended 18/2/06
// amended 21/7/07 to change my email address
// amended 5/6/09 for 2009-10 season

//__________________________________________________________________________________________

// variable displayed at the foot of each page showing date of last site update
sitelastupdated='27 February 2010'

//__________________________________________________________________________________________

// function to generate HTML for standard text at lower left of a page

function writeDatesUpdated(pagelastupdated)
// pagelastupdated = free format date or ''
{
  text = '<div class="dates" id="datesid">'

  if (pagelastupdated != '')
  {
    text+='<p>This page last amended:<br>' + pagelastupdated + '<br><br>'
  }
  
  var lastModDate=new Date(document.lastModified)
  var monthNames=new Array("January","February","March","April","May","June",
                           "July","August","September","October","November","December")
  
  text+='<p>This page last published:<br>' + 
        lastModDate.getDate() + ' ' +
        monthNames[lastModDate.getMonth()] + ' ' + 
        correctYear(lastModDate) + '<br><br>'

  text+='Site last updated:<br>' + sitelastupdated + '<br><br>'

  text+='Design and maintenance:<br>' + 
  '<a href="bccontacts.html#andy" target="_self"' + ' ' +
  'onMouseOver="window.status=&#039;Contact Andy Dix&#039;;return true"' + ' ' +
  'onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">' +
  'Andy Dix</a>'

  text+='</p></div>'
  document.write(text)
}
// end of function writeDatesUpdated

//__________________________________________________________________________________________

// function to give the correct browser-independent year
function correctYear(theDate) 
{ x = theDate.getYear(); 
  var y = x % 100; 
  y += (y < 38) ? 2000 : 1900; 
  return y; 
}
// end of function correctYear

//__________________________________________________________________________________________

// variables and function writeEntry used by fridaynnnn and mixingnnnn pages
// each call writes the entry for a single concert

datetime =''
artists=''
p = new Array("","","","","","","","","","","","","","","","","","","","")     /* allow up to 20 rows */
e = new Array("","","","","","","","","","")     /* allow up to 10 extra lines */

function writeEntry(seriesid,concertno,datetime,artists,rows,parray,extralines,earray)
// seriesid = fridaynnnn or mixingnnnn
// concertno = 1,2,3,...
// datetime = for display
// artists = for display
// rows = no of pieces in programme
// parray = array containing pieces in programme
// extralines = no of extra lines at bottom of entry
// earray = array containing extra lines at bottom of entry
{
  text='<A NAME="' + seriesid + concertno + '"></A>' 

  if (datetime != '')
    {text+= '<b>' + datetime + '</b><br><br>'}

  if (artists != '')
    {text+= artists + '<br><br>'}

  if (rows != 0)
  {
  tablehtml='<table border="0" width="100%" cellpadding="0" cellspacing="0" class="text">'
  trhtml='<tr valign="top" height="18">'
  tdhtml='<td width="25%">'
  text+=tablehtml
  for (i=0; i<rows;i++)
  {
    starposition = parray[i].indexOf('*')
    composer = parray[i].substring(0,starposition)
    work = parray[i].substring(starposition + 1,parray[i].length)
    if (i == 0) {indent=''} else {indent='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}
    text+=trhtml + tdhtml + indent + composer + '</td>' +
    '<td width="*">' + work + '</td></tr>'
  }
  text+='</table>'
  }

  for (i=0; i<extralines;i++)
  {
    text+='<br>' + earray[i] + '<br>'
  }
  text+='<br><HR width=100% align=left size=1 noshade color="#cccccc"><br>'
  document.write(text)
} 
/* end of function writeEntry */

//__________________________________________________________________________________________

// function writeEntry2 used by fridaynnnn and mixingnnnn pages
// each call writes the entry for a single concert

function writeEntry2(seriesid,concertno,datetime,artists,programme,extratext,horizontalline)

// Version 2: uses only delimiters (ie *'s) and not arrays

// seriesid = fridaynnnn or mixingnnnn
// concertno = 1,2,3,...
// datetime = for display - bold applied
// artists = for display
// programme = string containing pieces in programme in form composer*work*composer*work* etc
// extratext = string containing extra lines at bottom of entry in form line1*line2* etc
// horizontalline = "Y" for horizontal line after entry
{
  text='<a name="' + seriesid + concertno + '"></a>' 
  
  if (concertno ==1)
  {text+='<HR width=100% align=left size=1 noshade color="#cccccc"><br>'}

  if (datetime != '')
    {text+= '<b>' + datetime + '</b><br><br>'}
  
  if (artists != '')
    {text+= artists + '<br><br>'}
  
  text+='<table border="0" width="100%" cellpadding="0" cellspacing="0" class="text">'
  
  workprogramme = programme
  if (workprogramme != '')
  {
    done = false
    for (rowno=0; !done; rowno++)
    {
      starposition = workprogramme.indexOf('*')
      if (starposition == -1)
      {
        workprogramme = "composer error - no star**"
        starposition = workprogramme.indexOf('*')
      }
      
      composer = workprogramme.substring(0,starposition)
      rest = workprogramme.substring(starposition + 1,workprogramme.length)
      
      starposition = rest.indexOf('*')
      if (starposition == -1)
      {
        rest = "work error - no star*"
        starposition = rest.indexOf('*')
      }
        
      workprogramme = rest
        
      work = workprogramme.substring(0,starposition)
      rest = workprogramme.substring(starposition + 1,workprogramme.length)
          
      if (rowno == 0) {indent=''} else {indent='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'}
      text+='<tr valign="top" height="18">' + 
            '<td width="25%">' + indent + composer + '</td>' +
            '<td width="*">' + work + '</td>' +
            '</tr>'
      
      if (rest == '')
      {done = true}
      else
      {workprogramme = rest}
    }
  }

  worktext = extratext
  if (worktext != '')
  {
    done = false
    for (rowno=0; !done; rowno++)
    {
      starposition = worktext.indexOf('*')
      if (starposition == -1)
      {
        worktext = 'extratext error*'
        starposition = worktext.indexOf('*')
      }

      extraline = worktext.substring(0,starposition)
      rest = worktext.substring(starposition + 1, worktext.length)
      text+='<tr valign="top" height="18"><td colspan="2">' + extraline + '</td></tr>'

      if (rest == '')
      {done = true}
      else
      {worktext = rest}
    }
  }
  text+='</table>'
  if (horizontalline == 'Y')
  {
    text+='<br><HR width=100% align=left size=1 noshade color="#cccccc"><br>'
  }
  document.write(text)
} 
/* end of function writeEntry2 */

//__________________________________________________________________________________________


// function to open a new window - used in links page etc
// parameters are the URL of the web page to appear in the window + its size and position
// full = Y gives all of extra bits such as toolbar

function newWindow(url,inwidth,inheight,leftpos,toppos,full) 
{
  wk_leftpos = leftpos
  wk_toppos = toppos
  
  if (screen)
  {
    scrwdth = screen.width
    if (wk_leftpos + inwidth > scrwdth)
    {
      wk_leftpos = scrwdth - inwidth - 20
    } 
    if (wk_leftpos < 10)
    { wk_leftpos = 10 }
     
    scrht = screen.height
    if (wk_toppos + inheight > scrht)
    {
      wk_toppos = scrht - inheight - 20
    } 
    if (wk_toppos < 10)
    { wk_toppos = 10 }
  }
  
  params = "width=" + inwidth + 
           ",height=" + inheight + 
           ",left=" + wk_leftpos +
           ",top=" + wk_toppos
  if (full == "Y")
  { params+=",toolbar=yes,location=yes,scrollbars=yes,status=yes,menubar=yes,resizable=yes" }
  else
  { params+=",toolbar=no,location=no,scrollbars=no,status=no,menubar=no,resizable=yes" }
  
  linkWindow = window.open(url, 
               "urlWin",
               params)
  linkWindow.focus()
}
/* end of function newWindow */

//__________________________________________________________________________________________

// Create e-mail link to person firstName lastName
// (to hide email addresses from spammers)
function emailLink(firstName,lastName)
{
middleName=""
if (lastName == "Dix")
{middleName="M"}

if (lastName == "Evans")
{middleName="M"}

document.write('<a href="' + 
               '&#109;' + '&#097;' + '&#105;' + '&#108;' + '&#116;' + '&#111;' + '&#058;' + 
               firstName + middleName + lastName + 
               '&#064;' + 'bromsgrove-concerts' + '&#046;' + 'org' + '&#046;' + 'uk">' + firstName + ' ' + lastName + '</a>')
}

//__________________________________________________________________________________________

function gotoPage(newLoc)
{
  newPage = newLoc.options[newLoc.selectedIndex].value
  if (newPage != "")
  {window.location = newPage}
}

//__________________________________________________________________________________________

// make the pop-up menu passed as a parameter visible and hide all others

function showMenu(menuName)
{
  hideMenu()
  if (menuName != '')
  {document.getElementById(menuName).style.visibility = 'visible'}
}

//__________________________________________________________________________________________

// hide all pop-up menus

function hideMenu()
{
  document.getElementById("popup2").style.visibility = 'hidden'
  document.getElementById("popup3").style.visibility = 'hidden'
  document.getElementById("popup6").style.visibility = 'hidden'
  document.getElementById("popup7").style.visibility = 'hidden'
}

//__________________________________________________________________________________________

function msgOut(msgText)
{
  if (msgText == '')
    {statusMsg='Please select from the menu'}
  else
    {statusMsg=msgText}
  window.status=statusMsg;
  return true
}

//__________________________________________________________________________________________

// function to write buttons to left side of screen

function writeButtons()
{
text='<div class="button" id="button1" onMouseOver="showMenu(&#039;&#039;)" onMouseOut=""><p><a href="bchomepage.html" target="_self" onMouseOver="showMenu(&#039;&#039;);window.status=&#039;Bromsgrove Concerts Home Page&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Home Page</a></p></div>'

text+='<div class="button" id="button2" onMouseOver="showMenu(&#039;popup2&#039;)" onMouseOut=""><p><a href="concerts2009.html" target="_self" onMouseOver="showMenu(&#039;popup2&#039;);window.status=&#039;Chamber Music Concerts 2009-2010&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">2009-10 Season</a></p></div>'

text+='<div class="button" id="button3" onMouseOver="showMenu(&#039;popup3&#039;)" onMouseOut=""><p><a href="contemporary.html" target="_self" onMouseOver="showMenu(&#039;popup3&#039;);window.status=&#039;Contemporary Concerts&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Contemporary</a></p></div>'

text+='<div class="button" id="button4" onMouseOver="showMenu(&#039;&#039;)" onMouseOut=""><p><a href="artrix.html" target="_self" onMouseOver="showMenu(&#039;&#039;);window.status=&#039;How to get to Artrix&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Artrix</a></p></div>'

text+='<div class="button" id="button5" onMouseOver="showMenu(&#039;&#039;)" onMouseOut=""><p><a href="bchistory.html" target="_self" onMouseOver="showMenu(&#039;&#039;);window.status=&#039;History&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">History</a></p></div>'

text+='<div class="button" id="button6" onMouseOver="showMenu(&#039;popup6&#039;)" onMouseOut=""><p>Contact Us</p></div>'

text+='<div class="button" id="button7" onMouseOver="showMenu(&#039;popup7&#039;)" onMouseOut=""><p>Other Info</p></div>'

document.write(text)

}

//__________________________________________________________________________________________

// function to write popup menus

function writePopups()
{
// popup 1 - not used

// popup 2 - Concerts

text='<div id="popup2" class="menu" onMouseOver="showMenu(&#039;popup2&#039;)" onMouseOut="hideMenu()">'
text+='<p class="heading">2009-2010 Season</p>'

text+='<p><a href="concerts2009.html" target="_self" onMouseOver="window.status=&#039;Full Concert Details&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Full Concert Details</a></p>'

text+='<p><a href="bcdiary.html" target="_self" onMouseOver="window.status=&#039;Concert Diary&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Concert Diary</a></p>'

text+='<p><a href="prices2009.html" target="_self" onMouseOver="window.status=&#039;Ticket Prices&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Ticket Prices</a></p>'

text+='</div>'

// popup 3 - Contemporary

text+='<div id="popup3" class="menu" onMouseOver="showMenu(&#039;popup3&#039;)" onMouseOut="hideMenu()">'
text+='<p class="heading">Contemporary Music</p>'
text+='<p><a href="contemporary.html" target="_self" onMouseOver="window.status=&#039;Bromsgrove Contemporary Music&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Bromsgrove Contemporary Music</a></p>'

text+='<p><a href="bccomposerhosts.html" target="_self" onMouseOver="window.status=&#039;Mixing Music Featured Composers&#039;;return true" onMouseOut="msgOut(&#039;&#039;)">Featured Composers</a></p>'

text+='<p><a href="bccommissions.html" target="_self" onMouseOver="window.status=&#039;Commissions &amp; First Performances&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Commissions &amp; First Performances</a></p>'

text+='<p><a href="fourminutestarters.html" target="_self" onMouseOver="window.status=&#039;Four Minute Starters&#039;;return true" onMouseOut="msgOut(&#039;&#039;)">Four Minute Starters</a></p>'

text+='</div>'

// popup 4 - not used

// popup 5 - not used

// popup 6 - Contacts

text+='<div id="popup6" class="menu" onMouseOver="showMenu(&#039;popup6&#039;)" onMouseOut="hideMenu()">'

text+='<p class="heading">Contact Us</p>'

text+='<p><a href="bccontacts.html" target="_self" onMouseOver="window.status=&#039;Contacts and Booking Information&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Contacts and Booking Information</a></p>'

text+='<p><a href="bccontactform.html" target="_self" onMouseOver="window.status=&#039;Contact Form&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Contact Form</a></p>'

text+='<p><a href="bcwhoswho.html" target="_self" onMouseOver="window.status=&#039;Who Is Who at Bromsgrove Concerts&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Who&#039;s Who</a></p>'

text+='</div>'

// popup 7 - Other Information

text+='<div id="popup7" class="menu" onMouseOver="showMenu(&#039;popup7&#039;)" onMouseOut="hideMenu()">'
text+='<p class="heading">Other Information</p>'

text+='<p><a href="aboutthiswebsite.html" target="_self" onMouseOver="window.status=&#039;About This Web Site&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">About This Web Site</a></p>'

text+='<p><a href="bcacknowledgements.html" target="_self" onMouseOver="window.status=&#039;Acknowledgments&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Acknowledgments</a></p>'

text+='<p><a href="bccommissions.html" target="_self" onMouseOver="window.status=&#039;Commissions &amp; First Performances&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Commissions &amp; First Performances</a></p>'

text+='<p><a href="bcdiary.html" target="_self" onMouseOver="window.status=&#039;Concert and Event Diary&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Concert Diary</a></p>'

text+='<p><a href="bchistory.html" target="_self" onMouseOver="window.status=&#039;The History of Bromsgrove Concerts&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">History of Bromsgrove Concerts</a></p>'

text+='<p><a href="bclinks.html" target="_self" onMouseOver="window.status=&#039;Links To Other Web Sites&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Links to Other Web Sites</a></p>'

text+='<p><a href="bcmailinglist.html" target="_self" onMouseOver="window.status=&#039;Mailing Lists&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Mailing Lists</a></p>'

text+='<p><a href="bcnews.html" target="_self" onMouseOver="window.status=&#039;News&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">News</a></p>'

text+='<p><a href="bcreviews.html" target="_self" onMouseOver="window.status=&#039;Reviews&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Reviews</a></p>'

text+='<p><a href="prices2009.html" target="_self" onMouseOver="window.status=&#039;Ticket Prices&#039;;return true" onMouseOut="window.status=&#039;Please select from the menu&#039;;return true">Ticket Prices</a></p>'
text+='</div>'

document.write(text)

}

//__________________________________________________________________________________________

// function to place images on page and write the site title

function writeImagesTitle(imageNo)
{

text='<div id="leftimage"><img src="http://www.andydix.worldonline.co.uk/left_image_' + imageNo + '.gif" alt=""></div>' 
document.write(text)

text='<div id="rightimage"><img src="http://www.andydix.worldonline.co.uk/right_image_' + imageNo + '.gif" alt=""></div>'
document.write(text)

/*
text='<div id="topimage"><img src="http://www.andydix.worldonline.co.uk/top_image.gif" alt=""></div>'
document.write(text)
*/

document.write('<div id="sitetitle">Bromsgrove Concerts</div>')

}


