//
// Code to add page menu and menu side bar
//

var undefined;

function Menu(banner)
{
 this.banner = banner;
 this.menu = new Array();
 this.cnt = 0;
 this.content = undefined;
 this.addMenuEntry = Menu_addMenuEntry;
 this.display = Menu_display;
 this.addContent = Menu_addContent;
 this.addNotice = Menu_addNotice;
 this.displayNotices = Menu_displayNotices;
 this.displayLink = Menu_displayLink;
 this.notices = new Array();

}

function Menu_addMenuEntry(text, url)
{
  this.menu[this.cnt] = [ text, url ];
  this.cnt++;
}

function Menu_addNotice(title,text, url)
{
 this.notices[ this.notices.length ] = [ title, text, url ];
}

function Menu_addContent( contentElement )
{
 this.content = contentElement;
}

function Menu_displayNotices()
{
 document.write('<center class="COMPETITION_TITLE">');
 document.write('<div class="MAINPAGE_TITLE">' + this.noticeTitle + "</div></center>");
 for(var i=0; i < this.notices.length;i++)
 {
   document.write('<p><div class="NOTICE_TITLE"><b>');
   document.write( this.notices[i][0] );
   document.write('</b></div><div class="NOTICE_BODY">');
   document.write( this.notices[i][1] );
   document.write('</div><a class="NOTICE_LINK" href="' + this.notices[i][2] +'">More..</a></p>');
 }
}

function Menu_display()
{

 document.write('<table width=700 bgcolor=#1368b1 cellspacing="1" cellpadding="5">');
 
 document.write('<tr  valign="middle">');
 //document.write('<td class="TOP_CORNER" width=150><i>&nbsp;<p/>&nbsp;<p/><p/>&nbsp;</i></td>');
 document.write('<td colspan="2" class="BANNER_BODY"><center><p/>' + this.banner + '<p/></center></td></tr>');
 document.write('<tr>');
 document.write('<td valign="top" class="MENU_BODY">');
 
 
 document.write('<table class="MENU_BODY" cellpadding="2" cellspacing="5" width="150"><tbody>');
 for(var i=0; i < this.menu.length;i++)
 {
  document.write('<tr><td align="left"><a class="MENU" href="' + this.menu[i][0] + '">' + this.menu[i][1] + "</a></td></tr>");
 }
 
 document.write('<tr><td align=left><a class="MENU" href=mailto:mark.wassell@ps.ge.com>Contributions and Feedback</a></td></tr>');
  
 // Pad out the bottom of the menu bar so short content pages don't get 
 // the stunted look
 for(var i=0; i < 20 - this.menu.length;i++)
 {
  document.write('<tr><td>&nbsp;</td></tr>');
 }

 document.write("</tbody></table>");
 
 document.write("</td>");
 document.write('<td bgcolor=white valign="top">');
 
 if(this.notices.length > 0)
 {
  this.displayNotices();
 }
 else
  if(this.content != undefined && this.content.innerHTML != undefined) document.write(this.content.innerHTML);
 document.write("</td></tr>");

 document.write("</table>");
 
}

function Menu_display2()
{

 document.write('<table bgcolor=#aaaaff cellspacing="1" cellpadding="0">');
 
 document.write('<tr valign="middle">');
 openBox();
 document.write('<td class="TOP_CORNER" width=150><i>&nbsp;<p/>&nbsp;<p/><p/>&nbsp;</i></td>');
 closeBox();
 openBox();
 document.write('<td class="BANNER_BODY">&nbsp;' + this.banner + '</td></tr>');
 closeBox();
 document.write('<tr>');
 openBox();
 document.write('<td valign="top" class="MENU_BODY"><table class="MENU_BODY" cellpadding="2" cellpadding=5 width="150"><tbody>');
 for(var i=0; i < this.menu.length;i++)
 {
  document.write('<tr><td align="left"><a class="MENU" href="' + this.menu[i][0] + '">' + this.menu[i][1] + "</a></td></tr>");
 }
 // Pad out the bottom of the menu bar so short content pages don't get 
 // the stunted look
 for(var i=0; i < 20 - this.menu.length;i++)
 {
  document.write('<tr><td>&nbsp;</td></tr>');
 }
 document.write("</tbody></table></td>");
 closeBox();
 openBox();
 document.write('<td bgcolor=white valign="top">');
 
 if(this.notices.length > 0)
 {
  this.displayNotices();
 }
 else
  if(this.content != undefined && this.content.innerHTML != undefined) document.write(this.content.innerHTML);
 closeBox(); 
 document.write("</td></tr></table>");
 
}

function openBox()
{
 document.write('<td valign=top><table cellpadding=0 cellspacing=0>');
 document.write('<tr>');
 //document.write('<td valign=top><table cellpadding=10 cellspacing=0><tr>');
}

function closeBox()
{
 document.write('</tr></table></td>');
 //document.write('</tr></table></td>');
}

function KorfballVictoriaMenus(relative)
{
 if(relative == undefined) relative = "./";
 var m = new Menu("Korfball Victoria");
 m.addMenuEntry(relative + "index.html", "Home");
 m.addMenuEntry(relative + "aboutus.html", "About Us");
// m.addMenuEntry(relative + "diary.html","Diary");
 m.addMenuEntry(relative + "contacts.html","Contact Us");
 m.addMenuEntry(relative + "links.html", "Links");
 m.addMenuEntry(relative + "bmmka/index.html","BMMKA");

 return m;
}

function Menu_displayLink(title, url, comment)
{
 document.write("<tr><td><a href='" + url + "'>" + title + "</a></td></tr>");
}
 
function BMMKAMenus(relative)
{
 if(relative == undefined) relative = "./";
 var m = new Menu("Bacchus Marsh and Melton Korfball Association");
 m.addMenuEntry(relative + "index.html", "Home");
 m.addMenuEntry(relative + "../index.html", "Korfball Victoria");
 m.addMenuEntry(relative + "competition/SpringComp2004.html", "Spring Competition 2004");
// m.addMenuEntry(relative + "nationals2003/index.html", "Nationals 2003");
// m.addMenuEntry(relative + "competition/SpringComp2003.html", "Spring Competition 2003");
 /*
 //m.addMenuEntry(relative + "competition/resultsAutumn2003.html", "Autumn Competition 2003");
 m.addMenuEntry(relative + "minutes/index.html","Minutes");
 m.addMenuEntry(relative + "gallery/index.html","Picture Gallery");
 m.addMenuEntry(relative + "juniors/JuniorKorfballMarch2003.htm", "Junior Korfball");
 m.addMenuEntry("http://directory.google.com/Top/Sports/Korfball/", "Links");
 */
 return m;
}

function addImage(file,caption)
{

 document.write("<table border='2'><tr><td><img src='" + file + "'></td></tr>");
 document.write("<tr><td align='center'>" + caption + "</td></tr></table>"); 
}
