//-----------------------------------------------------
// Define objects, properties, constructor and methods
//-----------------------------------------------------
//-----------------------------------------------------
new MenuItem();					// prototype object

MenuItem.prototype.dir;
MenuItem.prototype.name;
MenuItem.prototype.url;
MenuItem.prototype.imageurl;
MenuItem.prototype.bannerurl;
MenuItem.prototype.bgcolor;

function MenuItem(dir, name, url, imageurl, bannerurl, bgcolor) {	// constructor
	this.dir = dir;
	this.name = name;
	this.url = url;
	this.imageurl = imageurl;
	this.bannerurl = bannerurl;
	this.bgcolor = bgcolor;
}

Menu.prototype.findItem =
function findItem(menuDir) {
	for (var i=0; i<this.menuItems.length; i++) {
    	if(this.menuItems[i].dir == menuDir) {
    		return(this.menuItems[i]);
    	}
    }
    alert('menuItem containing "' + menuDir + '" not found.');
    return(null);
}

MenuItem.prototype.write =
function write (homeDir,sectionDir,color) {
// Write section name in button bar
	var url = homeDir + this.dir + '/' + this.url;
	document.write(	'<td bgcolor=' + color + ' align="center"' +
					' onMouseOver="this.style.backgroundColor = \'' + this.bgcolor + '\'"' +
					' onMouseOut=\'this.style.backgroundColor = "'+ color +'\"\'>' +
					' <p class="sectionbutton"><A class="sectionbutton" HREF="' +   
					url + '">' + this.name + '</A></td>');

}

//-----------------------------------------------------

MenuItem.prototype.miniwrite =
function miniwrite (homeDir,sectionDir) {
	document.write('<a class="minibutton" href="' + homeDir + this.dir + '/' + this.url + '">' +
		this.name + '</a>');
}
									
//-----------------------------------------------------
new Menu();						// prototype object

Menu.prototype.menuItems;		// properties
Menu.prototype.homeDir;
Menu.prototype.sectionDir;

function Menu(menuItems) {		// constructor
	this.menuItems = menuItems;
}

Menu.prototype.write =
function write() {
	var menuitem = this.findItem(this.sectionDir);
	var color;

//	Display appropriate Basenji Companion graphic and banner
	document.write('<table CELLPADDING="5" CELLSPACING="0" BORDER="0" WIDTH="700">');
	document.write('<tr>'); 
	document.write('<td><img src="'+this.homeDir+'images/'+menuitem.imageurl+'" height="106" width="150"> </td>');
    document.write('<td><img src="'+this.homeDir+'images/'+menuitem.bannerurl+'" height="100" width="500" align="center">');
    document.write('</td></tr></table>');

//	Increase Spacing to button bar   
	document.write(	'<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="700">'+
					'<tr><td height="6">' +
					'<img src="'+this.homeDir+'images/blank.gif" height="6" width="500"' +
					'</td></tr></table>');
//	Draw line   
	document.write(	'<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="700">'+
					'<tr BGCOLOR="#000000"><td height="2">' +
					'<img src="'+this.homeDir+'images/blank.gif" height="2" width="500"' +
					'</td></tr></table>');
					
// Define button bar table and write entries: Join Now, Contacts
	document.write(	'<table BGCOLOR="#8B5C30" CELLPADDING="3" CELLSPACING="0" BORDER="0" WIDTH="700">' +
					'<tr BGCOLOR="#8B5C30">' +
					'<td BGCOLOR="#8B5C30" width="60" align="center"' +
					' onMouseOver="this.style.backgroundColor = \'black\'"' +
					' onMouseOut="this.style.backgroundColor = \'#8B5C30\'">' +
					' <p class="specialbutton"> <A class="specialbutton" HREF="' +   
					this.homeDir + 'membership.html' + '">Join Now!</A></td>');
										
	document.write( '<td BGCOLOR="#8B5C30" width="80" align="center"' +
					' onMouseOver="this.style.backgroundColor = \'black\'"'+
					' onMouseOver="alert(\'mouseover\')"'+
					' onMouseOut="this.style.backgroundColor = \'#8B5C30\'">'+
					' <p class="specialbutton"> <A class="specialbutton" HREF="' +  
					this.homeDir + 'board.html' + '">Contacts</A></td>');


//End button bar after writing Section Names
 	for (var i=0; i<this.menuItems.length; i++) {
 		if (menuitem==this.menuItems[i]) color=menuitem.bgcolor;
 		else color="#8B5C30";
    	this.menuItems[i].write(this.homeDir,this.sectionDir,color);
    }
    document.write('</tr></table>');
    
//Draw line   
	document.write(	'<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="700">'+
					'<tr BGCOLOR="#000000"><td height="2">' +
					'<img src="'+this.homeDir+'images/blank.gif" height="2" width="500"' +
					'</td></tr></table>');

}


Menu.prototype.miniwrite =
function miniwrite() {
	var menuitem = this.findItem(this.sectionDir);    	
//	Define table, write space row
	document.write('<br>');
	document.write('<table CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="700">');
	document.write('<tr><td width="150"></td>');

					
//	Write mini-menu row
	document.write(	'<td align="center"><p class="minibutton">');
		for (var i=0; i<this.menuItems.length; i++) {
 		if (i!=0) document.write(' | ');
    	this.menuItems[i].miniwrite(this.homeDir,this.sectionDir);
     }

 	document.write(	'<p class="minibutton"><a class="minibutton" href="' + this.homeDir + 'membership.html' + 
					'">Join Now!</a></p>');

// 	Write copyright

	document.write(	'<P class="smallcopyright">Copyright © 2003 by Basenji' + 
 					'Companions. All rights reserved.');
    document.write('</td></tr></table>'); 
	
}

//-----------------------------------------------------
new SectionItem();				// prototype object

SectionItem.prototype.name;			// properties
SectionItem.prototype.url;

function SectionItem (name, url) {	// constructor
	this.name = name;
	this.url = url;
}

SectionItem.prototype.write =
function write (homeDir,sectionDir,seccolor) {
	var url = homeDir + sectionDir + '/' + this.url;
	document.write( '<tr><td bgcolor="' + seccolor + '"' +
//					' onClick=\'location.href="' + url + '"\'' +
					' onMouseOver="this.style.backgroundColor = \'black\'"'+
					' onMouseOut="this.style.backgroundColor = \'' + seccolor + '\'">'+
					'<p class="itembutton"><A class="itembutton" HREF="' +   
					url + '">' + this.name + '</A></td>');
}

//-----------------------------------------------------
new Section();					// prototype object

Section.prototype.sectionItems;	// properties
Section.prototype.seccolor;

function Section (seccolor, sectionItems) {// constructor
	this.sectionItems = sectionItems;
	this.seccolor = seccolor;
}

Section.prototype.write =
function write(homeDir,sectionDir) {

// Define mini table for section items for alignement
	document.write('<table bgcolor="D6CBBA" CELLPADDING="2" CELLSPACING="7" BORDER="0" WIDTH="150">');
	for (var i=0; i<this.sectionItems.length; i++) {
     	this.sectionItems[i].write(homeDir,sectionDir,this.seccolor);
    }
	document.write('</table>'); 
}

function StartSectionTable (homeDir,sectionDir) {
	menu.homeDir = homeDir;
	menu.sectionDir = sectionDir;
	menu.write();
//	Define table that has Section Item table and Body table
	document.write('<table CELLPADDING="5" CELLSPACING="0" BORDER="0" WIDTH="700"><tr><td valign="top">');
//	Section Items are a mini table to ensure no alignment problems
	section.write(homeDir,sectionDir);
//	End row with section table; Start row for Body
	document.write('</td><td valign="top">');
	}

function EndSectionTable () {
//	End row for Body, write out mini menu at bottom, and copy right
	document.write('</td></tr></table>');
	menu.miniwrite();
}
			

//-----------------------------------------------------
// Print the header and Create the main menu of buttons
//-----------------------------------------------------

var menu = new Menu ( new Array (
	new MenuItem( '.', 'Home', 'index.html', 'basenji-logo.gif', 'banner-home.gif', '#E0A139'),
	new MenuItem( 'health', 'Health & Safety', 'index.html', 'basenji-health.gif', 'banner-health.gif', '#1680DA'),
	new MenuItem( 'tips', 'Obedience & Tips', 'index.html', 'basenji-tips.gif', 'banner-tips.gif', '#AC35D4'),
	new MenuItem( 'articles', 'Articles & Stories', 'index.html', 'basenji-articles.gif', 'banner-articles.gif', '#35844A'),
	new MenuItem( 'photo', 'Photos', 'index.html', 'basenji-asleep.gif', 'banner-photo.gif', '#6A07BC'),
	new MenuItem( 'resources', 'Resources', 'index.html', 'basenji-resources.gif', 'banner-resources.gif', '#0804AE')		
) );
