/**********************************************************************
submenu.js contains declarations for the menu object and
declares an instance of the menu object.
***********************************************************************/ 

//alert ('menu')
    

// create a new menu entry
function entry (theID,theCategory,theTitle,theAlt,thelink) {
    this.ID	= theID
    this.category = theCategory;
    this.title = theTitle;
    this.alt = theAlt;
    this.link = thelink
}


// ******************************************
// * menu constructor creates a new menu
// ******************************************
function menu () {
    this.numberEntries = 0;         
    this.entries = new Array();     
    this.addEntry = menu_addEntry;  
    this.header = menu_header;  
    this.header1 = menu_header1;
    this.header2 = menu_header2;
    this.footer = menu_footer;  
    this.title = menu_title;	
    this.smalltitle = menu_smalltitle;
    this.display = menu_display;  	
	this.sitemap = menu_sitemap;  	
	this.pagetop = menu_pagetop;
}


// ******************************************
// menu_addEntry adds an item to the gallery
// ******************************************
function menu_addEntry (entryID, entryCategory,entryTitle, entryAlt, entryLink) {
    this.numberEntries += 1;
    this.entries[this.numberEntries-1] = new entry(entryID, entryCategory, entryTitle, entryAlt, entryLink);    

}

// *********************************************
// * menu_smalltitle
// *********************************************
function menu_smalltitle (theTitleText) {

	document.write('<TR><TD><IMG SRC="images/spacer.gif" HEIGHT="10"></TD></TR>' );
	document.write('<TR><TD><div class="smalltitletext">' + theTitleText + '</div></TD></TR>' );
	document.write('<TR><TD><img src="images/purpledot.gif" height=1 width="100%"></td></tr>' );
	document.write('<TR><TD><IMG SRC="images/spacer.gif" HEIGHT="10"></TD></TR>' );

}

// *********************************************
// * menu_title
// *********************************************
function menu_title (theTitleText) {

//<TR><TD><IMG SRC="images/spacer.gif" HEIGHT="10"></TD></TR>
//<TR><TD><div class="titletext">Welcome</div></TD></TR>
//<tr><td><img src="images/purpledot.gif" height=1 width="100%"></td></tr>
//<TR><TD><IMG SRC="images/spacer.gif" HEIGHT="10"></TD></TR>
//
	document.write('<TR><TD><IMG SRC="images/spacer.gif" HEIGHT="10"></TD></TR>' );
	document.write('<TR align=left><TD><div class="titletext">' + theTitleText + '</div></TD></TR>' );
	document.write('<tr><td><img src="images/purpledot.gif" height=1 width="100%"></td></tr>' );
	document.write('<TR><TD><IMG SRC="images/spacer.gif" HEIGHT="10"></TD></TR>' );

}
	
// *********************************************
// * menu_display outputs menu entries
// * display the left hand side sub menu
// * built from the contents of menuitems.js
// *********************************************
function menu_display (theCategory) {
	
	var asText=0;
	var maxposter = 20;
	
   // Table Header Row Details
    document.write( '<table Class="menufont" cellspacing="0" cellpadding="3">' ); 
	document.write( '<TR>' ); 
	document.write( '<TD width="20" height="1"><IMG SRC="images/spacer.gif" HEIGHT="1"></TD>' );
	document.write( '<TD width="100"></TD>' );
	document.write( '</TR>' );
    document.write( '<TR><TD colspan="2" width="91">' );
    document.write( '<IMG width="96" SRC="images/menus/mnu'+ theCategory + '_up.jpg">' );
    document.write( '</td></tr>');

//***************************************
//  Process each entry in the gallery,
// ***************************************
     for (var i = 0; i <= this.numberEntries -1; i++) {
          var my = this.entries[i]; 
        if (my.category.toLowerCase() == theCategory.toLowerCase()) {
                document.write( '<TR>' );
                document.write( '<TD align="right"><IMG SRC="images/bullet_up.jpg"></TD>' );
	            document.write( '<TD>');        
	            document.write( '<a href="' + my.link + '" target="_self">');
	            document.write(my.title);
	            document.write( '</a>');
	    		document.write( '</TD></TR>');
		    } // End If

         }  // End for

//***************************************
//  Space before Poster
// ***************************************
	document.write( '<TR>' ); 
	document.write( '<TD width="20" height="1"><IMG SRC="images/spacer.gif" HEIGHT="10"></TD>' );
	document.write( '<TD width="100"></TD>' );
	document.write( '</TR>' );

//***************************************
//  Display a Random Poster
// ***************************************
     document.write( '<TR align=center><TD colspan="2">' );
     document.write( '<A Href="linhistory.htm">' );
     document.write( '<IMG SRC="images/posters/magicposter' );
     document.write( generatenumber(1,maxposter) + '.jpg" border="0">' );
     document.write( '</a>' );
     document.write( '</td></TR>' );

//***************************************
//  End the Table
// ***************************************
     document.write ( '</TABLE>' );
                 
} // End Function

// *******************************************
// * menu_header: Display the Header/Navigation
// *******************************************
function menu_footer() {

	// ************************* -->
	// * Footer Spacing			 -->
	// ************************* -->
	document.write ('<TABLE WIDTH="625" BORDER="0" CELLPADDING="0" CELLSPACING="0">' );
	document.write ('<TR>' );
	document.write ('<TD width="170" height="20"></TD>' );
	document.write ('<TD><IMG SRC="images/purpledot.gif" WIDTH="100%" HEIGHT="1"></TD>' );
	document.write ('</TR>' );
	document.write ('<TR>' );
	document.write ('<TD width="170" height="20"></TD>' );
	document.write ('<TD><IMG SRC="images/spacer.gif" HEIGHT="1"></TD>' );
	document.write ('</TR>' );
	document.write ('</Table>' );

	// ************************* -->
	// * Footer			 -->
	// ************************* -->
	document.write ('<TABLE WIDTH="647" BORDER="0" CELLPADDING="0" CELLSPACING="0">' );
	document.write ('<TR>' );
	document.write ('<TD><IMG SRC="images/menus/footer/footer_01.jpg" WIDTH="28" HEIGHT="13" ALT=""></TD>' );
	document.write ('<TD><IMG SRC="images/menus/footer/footer_02.jpg" WIDTH="100" HEIGHT="13" ALT=""></TD>' );
	document.write ('<TD><IMG SRC="images/menus/footer/footer_03.jpg" WIDTH="58" HEIGHT="13" ALT=""></TD>' );

	document.write ('<TD  rowspan="2">' );
	
	// ************************* -->
	// * Legalities				 -->
	// ************************* -->
   	document.write ('<div class="footer"><a href="abocontact.htm" target=_self>Contact Us</a> ' );
   	document.write ('| <a href="abolegal.htm" target=_self>Legal</a> ' );
   	document.write ('| <a href="abositemap.htm" target=_self>Sitemap</a><br>' );
   	document.write ('Copyright © 2004 Ipswich Magical Society | Designed by Bananafish' );
	document.write ('</div>' );
	document.write ('</TD>' );
	document.write ('<TD></TD>' );

	document.write ('</TR>' );
	document.write ('<TR>' );
	document.write ('<TD><IMG SRC="images/menus/footer/footer_06.jpg" WIDTH="28" HEIGHT="30" ALT=""></TD>' );
	document.write ('<TD bgcolor="purple">' );
	
	// ************************* -->
	// * Easyspace Logo			 -->
	// ************************* -->
	//document.write ('<A href="http://www.easyspace.com/cgi-bin/redirect.cgi?type=BNR-100_easyspace_1.gif&amp;url=http://www.easynic.com"' );
	//document.write (' target=_blank>' );
	document.write (' <IMG height=30 alt="" ');
	document.write (' src="images/menus/footer/footer_07.jpg" width=100 border=0>');
	//document.write (' src="images/menus/footer/footer_07.jpg" width=100 border=0></A>');
	// Note this should be a comment, but I dont think that will work as java script
	//document.write ('<!--#easybanner4-->');

	document.write ('</TD>' );
	document.write ('<TD><IMG SRC="images/menus/footer/footer_08.jpg" WIDTH="58" HEIGHT="30" ALT=""></TD>' );
	document.write ('<TD rowspan="2"></TD>' );
	
	document.write ('</TR>' );
	document.write ('<TR>' );
	document.write ('<TD><IMG SRC="images/menus/footer/footer_11.jpg" WIDTH="28" HEIGHT="38" ALT=""></TD>' );
	document.write ('<TD><IMG SRC="images/menus/footer/footer_12.jpg" WIDTH="100" HEIGHT="38" ALT=""></TD>' );
	document.write ('<TD><IMG SRC="images/menus/footer/footer_13.jpg" WIDTH="58" HEIGHT="38" ALT=""></TD>' );
	document.write ('<TD><IMG SRC="images/menus/footer/footer_14.jpg" WIDTH="432" HEIGHT="38" ALT=""></TD>' );
	document.write ('<TD><IMG SRC="images/menus/footer/footer_15.jpg" WIDTH="29" HEIGHT="38" ALT=""></TD>' );
	document.write ('</TR>' );
	document.write ('</TABLE>' );
	

}

// *******************************************
// * menu_header: Display the Header/Navigation
// *******************************************
function menu_header() {

  document.write( '<TABLE WIDTH="654" BORDER="0" CELLPADDING="0" CELLSPACING="0">' );
  document.write( '<TR >' );
  document.write( '<TD><IMG SRC="images/menus/header2008/header2008_01.jpg" WIDTH="199" HEIGHT="60" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header2008/header2008_02.jpg" WIDTH="400" HEIGHT="60" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header2008/header2008_03.jpg" WIDTH="55" HEIGHT="60" ALT=""></TD>' );
  document.write( '</TR>' );
  document.write( '<TR>' );
  document.write( '<TD><IMG SRC="images/menus/header2008/header2008_04.jpg" WIDTH="199" HEIGHT="55" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header2008/header2008_05.jpg" WIDTH="400" HEIGHT="55" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header2008/header2008_06.jpg" WIDTH="55" HEIGHT="55" ALT=""></TD>' );
  document.write( '</TR>' );
  document.write( '<TR>' );
  document.write( '<TD valign="top" height="33"><IMG SRC="images/menus/header2008/header2008_07.jpg" WIDTH="199" HEIGHT="33" ALT=""></TD>' );
  document.write( '<TD height="33">' );
  document.write( '<table border="0" cellpadding="0" cellspacing="0" width="400" height="33">' );
  document.write( '<tr>' );
  document.write( '<TD><a href="index.htm" onMouseOut="ImgUp(mnuabout);" onMouseOver="ImgDown(mnuabout);">' );
  document.write( '   <IMG id="mnuabout" name="mnuabout" SRC="images/menus/header/mnuabout_up.jpg" ');
  document.write( '   WIDTH="80" HEIGHT="33" ALT="About Us" border="0"></a></TD>' );
  document.write( '<TD><a href="evecurrent.htm" onMouseOut="ImgUp(mnuevents);" onMouseOver="ImgDown(mnuevents);">' );
  document.write( '   <IMG id="mnuevents" name="mnuevents" SRC="images/menus/header/mnuevents_up.jpg" ');
  document.write( '   border="0" WIDTH="80" HEIGHT="33" ALT="Events"></a></TD>' );
  document.write( '<TD><a href="boogeneral.htm" onMouseOut="ImgUp(mnubooking);" onMouseOver="ImgDown(mnubooking);">' );
  document.write( '   <IMG id="mnubooking" name="mnubooking" SRC="images/menus/header/mnubooking_up.jpg" ');
  document.write( '   border="0" WIDTH="80" HEIGHT="33" ALT="Booking a Magician"></a></TD>' );
  document.write( '<TD><a href="memnews.htm" onMouseOut="ImgUp(mnumembers);" onMouseOver="ImgDown(mnumembers);">' );
  document.write( '   <IMG id="mnumembers" name="mnumembers" SRC="images/menus/header/mnumembers_up.jpg" ');
  document.write( '   border="0" WIDTH="80" HEIGHT="33" ALT="Booking a Magician"></a></TD>' );
  document.write( '<TD><a href="lincontents.htm" onMouseOut="ImgUp(mnulinks);" onMouseOver="ImgDown(mnulinks);">' );
  document.write( '   <IMG id="mnulinks" name="mnulinks" SRC="images/menus/header/mnulinks_up.jpg" ');
  document.write( '   WIDTH="80" HEIGHT="33" border="0" ALT="Links"></a></TD>' );
  document.write( '</tr>' );
  document.write( '</table>' );
  document.write( '</TD>' );
  document.write( '<TD valign="top" height="33"><IMG SRC="images/menus/header2008/header2008_13.jpg" WIDTH="55" HEIGHT="33" ALT=""></TD>' );
  document.write( '</TR>' );
  document.write( '<TR>' );
  document.write( '<TD><IMG SRC="images/menus/header2008/header2008_14.jpg" WIDTH="199" HEIGHT="33" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header2008/header2008_15.jpg" WIDTH="400" HEIGHT="33" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header2008/header2008_16.jpg" WIDTH="55" HEIGHT="33" ALT=""></TD>' );
  document.write( '</TR>' );
  document.write( '</TABLE>' );

}

// *******************************************
// * menu_header: Display the Header/Navigation
// *******************************************
function menu_header2() {

  document.write( '<TABLE WIDTH="654" BORDER="0" CELLPADDING="0" CELLSPACING="0">' );
  document.write( '<TR >' );
  document.write( '<TD><IMG SRC="images/menus/header/header_01.jpg" WIDTH="184" HEIGHT="60" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header/header_02.jpg" WIDTH="412" HEIGHT="60" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header/header_03.jpg" WIDTH="17" HEIGHT="60" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header/header_04.jpg" WIDTH="41" HEIGHT="60" ALT=""></TD>' );
  document.write( '</TR>' );
  document.write( '<TR>' );
  document.write( '<TD><IMG SRC="images/menus/header/header_05.jpg" WIDTH="184" HEIGHT="71" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header/header_06.jpg" WIDTH="412" HEIGHT="71" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header/header_07.jpg" WIDTH="17" HEIGHT="71" ALT=""></TD>' );
  document.write( '<TD><IMG SRC="images/menus/header/header_08.jpg" WIDTH="41" HEIGHT="71" ALT=""></TD>' );
  document.write( '</TR>' );
  document.write( '<TR>' );
  document.write( '<TD valign="top" height="50"><IMG SRC="images/menus/header/header_09.jpg" WIDTH="184" HEIGHT="50" ALT=""></TD>' );
  document.write( '<TD height="50">' );
  document.write( '<table border="0" cellpadding="0" cellspacing="0" width="412" height="50">' );
  document.write( '<tr>' );
  document.write( '<TD><a href="index.htm" onMouseOut="ImgUp(mnuabout);" onMouseOver="ImgDown(mnuabout);">' );
  document.write( '   <IMG id="mnuabout" name="mnuabout" SRC="images/menus/header/mnuabout_up.jpg" ');
  document.write( '   WIDTH="80" HEIGHT="50" ALT="About Us" border="0"></a></TD>' );
  document.write( '<TD><a href="evecurrent.htm" onMouseOut="ImgUp(mnuevents);" onMouseOver="ImgDown(mnuevents);">' );
  document.write( '   <IMG id="mnuevents" name="mnuevents" SRC="images/menus/header/mnuevents_up.jpg" ');
  document.write( '   border="0" WIDTH="80" HEIGHT="50" ALT="Events"></a></TD>' );
  document.write( '<TD><a href="boogeneral.htm" onMouseOut="ImgUp(mnubooking);" onMouseOver="ImgDown(mnubooking);">' );
  document.write( '   <IMG id="mnubooking" name="mnubooking" SRC="images/menus/header/mnubooking_up.jpg" ');
  document.write( '   border="0" WIDTH="80" HEIGHT="50" ALT="Booking a Magician"></a></TD>' );
  document.write( '<TD><a href="memnews.htm" onMouseOut="ImgUp(mnumembers);" onMouseOver="ImgDown(mnumembers);">' );
  document.write( '   <IMG id="mnumembers" name="mnumembers" SRC="images/menus/header/mnumembers_up.jpg" ');
  document.write( '   border="0" WIDTH="80" HEIGHT="50" ALT="Booking a Magician"></a></TD>' );
  document.write( '<TD><a href="lincontents.htm" onMouseOut="ImgUp(mnulinks);" onMouseOver="ImgDown(mnulinks);">' );
  document.write( '   <IMG id="mnulinks" name="mnulinks" SRC="images/menus/header/mnulinks_up.jpg" ');
  document.write( '   WIDTH="80" HEIGHT="50" border="0" ALT="Links"></a></TD>' );
  document.write( '<TD WIDTH="12"><IMG SRC="images/menus/header/mnufiller.jpg" height="50" width="12"></TD>' );
  document.write( '</tr>' );
  document.write( '</table>' );
  document.write( '</TD>' );
  document.write( '<TD valign="top" height="50"><IMG SRC="images/menus/header/mnufiller.jpg" WIDTH="17" HEIGHT="50" ALT=""></TD>' );
  document.write( '<TD valign="top" height="50"><IMG SRC="images/menus/header/header_12.jpg" WIDTH="41" HEIGHT="50" ALT=""></TD>' );
  document.write( '</TR>' );
  document.write( '</TABLE>' );

}

// *******************************************
// * menu_header1: Display the Header/Navigation
// *******************************************
function menu_header1() {

	document.write( '<TABLE WIDTH="623" BORDER="0" CELLPADDING="0" CELLSPACING="0">');
	document.write( '<tr>');
	document.write( '<td>');
	document.write( '<table>');
	document.write( '<tr>');
	document.write( '<TD><IMG SRC="images/white.gif" WIDTH="10" HEIGHT="105" ALT=""></TD>');
	document.write( '<td><IMG SRC="images/menus/header/header5_01.jpg" WIDTH="105" HEIGHT="105" ALT=""></td>');
	document.write( '<TD><IMG SRC="images/white.gif" WIDTH="20" HEIGHT="105" ALT=""></TD>');
	document.write( '<td>');
	document.write( '<table ID="TableH1">');
	document.write( '<tr>');
	document.write( '<TD><IMG SRC="images/white.gif" WIDTH="486" HEIGHT="13" ALT=""></TD>');
	document.write( '</tr>');

	document.write( '<TR>');
	document.write( '<TD><IMG SRC="images/menus/header/header5_05.jpg" WIDTH="486" HEIGHT="47" ALT=""></TD>');
	document.write( '</TR>');
	document.write( '<tr>');
	document.write( '<TD>');
	document.write( '<table class="header" cellpadding="0" cellspacing="0" border="0">');
	document.write( '<tr valign=middle >');
	document.write( '<TD><IMG SRC="images/white.gif" WIDTH="5"" ALT=""></TD>');
	document.write( '<td align="center" width="90"><a href="index.htm">About us</a></td>');
	document.write( '<td align="center" width="90"><a href="evecurrent.htm">Events</a></td>');
	document.write( '<td align="center" width="90"><a href="boogeneral.htm">Booking</a></td>');
	document.write( '<td align="center" width="90"><a href="memnews.htm">Members</a></td>');
	document.write( '<td align="center" width="90"><a href="lincontents.htm">Links</a></td>');
	document.write( '</tr>');
	document.write( '</table>');
	document.write( '</TD>');
	document.write( '</tr>');
	
	
	document.write( '</table>');
	document.write( '</td>');
	document.write( '</tr>');
	document.write( '</table>');
	document.write( '</td>');
	document.write( '</tr>');
	document.write( '</TABLE>');

}


// ******************************************
// * Generate a sitemap Menu
// ******************************************
function menu_sitemap(theCategory, theText) {

	document.write ( '<table cellpadding="0" cellspacing="0" border="0">' );
	document.write ( '	<tr class="smalltitletext">' );
	document.write ( '		<td align="right" width="30"></td>' );
	document.write ( '		<td width="150"></td>' );
	document.write ( '	</tr>');
	document.write ( '	<tr class="smalltitletext">' );
	document.write ( '		<td colspan="2">' + theText + '</td>' );
	document.write ( '	</tr>');
	document.write ( '	<tr class="smalltitletext">');
	document.write ( '		<td colspan="2">&nbsp;</td>' );
	document.write ( '	</tr>');

//***************************************
//  Process each entry in the gallery,
// ***************************************
     for (var i = 0; i <= this.numberEntries -1; i++) {
        var my = this.entries[i]; 
		if (my.category.toLowerCase() == theCategory.toLowerCase()) {

			document.write ( '	<tr>' );
			document.write ( '	<td align="right" width="30">' );
			document.write ( '		<a href="' + my.link + '"' );
			document.write ( '      alt="' + my.alt + '">' );
			document.write ( '		<img src="images/smallbullet.jpg" border="0"></a>' );
			document.write ( '	</td>' );
			document.write ( '	<td width="120">' );
			document.write ( '		<a href="http://www.ipswichmagicalsociety.co.uk/' + my.link + '" ' );
			document.write ( '   alt="' + my.alt + '">' + my.title + '</a>' );
			document.write ( '	</td>' );
			document.write ( '	</tr>' );

		} // End if
	}	// End For

	document.write ( '	<tr class="smalltitletext">');
	document.write ( '		<td colspan="2">&nbsp;</td>' );
	document.write ( '	</tr>');
	document.write ( '	<tr class="smalltitletext">');
	document.write ( '		<td colspan="2">&nbsp;</td>' );
	document.write ( '	</tr>');
	document.write ( '</table>' );
	
}

// ******************************************
// * Jump to Page Top
// ******************************************
function menu_pagetop() {
	document.write( '<TR>' ); 
	document.write( '<TD class="navigation" align=left>' ); 
	document.write ( '<A href="#pagetop">' );
	//document.write ( '<A href="' + thePage + '.htm#pagetop">' );
	document.write ( '<img src="images/navtop.gif" border="0" alt="Return to Top of Page">' );
	document.write( '			 <br>Top');
	document.write( '</a>' );
	document.write( '</TD>' ); 
	document.write( '</TR>' ); 

}

// ******************************************
// * Generate a random number between x and y
// ******************************************
function generatenumber(x, y) {
  var irange = y - x + 1;
  var ireturn = Math.floor(Math.random() * irange) + x;
 // if ireturn > y {
 //   ireturn = y;
 // }
  return ireturn;
}

/*
}	
*/
// *****************************************
// * Create an instance of the Menu object
// *****************************************
var Menu = new menu();

