var buttonPath = "/pics/buttons/";
var isInitialized = false;

/* Some browser feature detection */
var isW3C = (document.getElementById) ? true : false;
var isIE  = (document.all)            ? true : false;
var isNS4 = (document.layers)         ? true : false;


/* Return an element by ID on most any browser */
function getElement(id) {
    return (isW3C)  ? document.getElementById(id) : 
           ((isIE)  ? document.all[id] : 
           ((isNS4) ? document.layers[id] : null));
}



// Constructor for our "Button" object
function Button(name, desc) {
	/* Set misc info */
	this.name      = name;
	this.desc      = desc;                           /* status text */
	this.imageId   = name;                           /* Same as image name */
	this.image     = getElement(this.imageId);       /* Get button image object */
			
	/* Set methods */
	this.up        = buttonUp;
	this.over      = buttonOver;
	
	/* Define and pre-load button images, only if the image actually exists on the page */
	if (document.images && this.image) {
		this.image_up      = new Image;
		this.image_up.src  = buttonPath + name + "_up.gif";     /* normal    */
		this.image_over    = new Image;
		this.image_over.src= buttonPath + name + "_over.gif";   /* mouseover */
	}
}



//===================================
//  Button methods
//===================================

function buttonUp() {
	if (isInitialized && this.image) this.image.src = this.image_up.src;
	window.status = "";
	return true;
}


function buttonOver() {
	if (isInitialized && this.image) {
		this.image.src = this.image_over.src;
		window.status  = this.desc;
	}
	return true;
}



var buttons  = new Array;

function initialize_Buttons() {
	
	if (isInitialized) return false;
	
	// Define main menu pages
	buttons["books"]       = new Button("books",       "Books");
	buttons["videos"]      = new Button("videos",      "Videos");
	buttons["study"]       = new Button("study",       "Study Materials");
	buttons["music"]       = new Button("music",       "Music");
	buttons["specialties"] = new Button("specialties", "Notebook, Maps & Specialties");
	buttons["index"]       = new Button("index",       "Index of all products (when you already know what you want to order)");
	
	// Load data for the submenu, if it is present on the page
	buttons["prophecy"]    = new Button("prophecy", "Biblical Prophecy");
	buttons["feasts"]      = new Button("feasts",   "Feasts");
	buttons["messiah"]     = new Button("messiah",  "Messiah");
	buttons["history"]     = new Button("history",  "Biblical History");
	buttons["israel"]      = new Button("israel",   "Israel");
	buttons["musicals"]    = new Button("musicals", "Musicals/Music Videos");
	buttons["special"]     = new Button("special",  "Special Topics");
	
	isInitialized = true;
	window.status  = "";
	
	return true;
}

// Add our initializer function
addLoadHandler(initialize_Buttons);
