// JavaScript Document


// BUTTONS.JS
//
// This file implements object-oriented buttons.
// To use them, instantiate a new button for each
// button on your page, linking the &lt;img&gt; tag to the
// button object. You can then use the SetUp(), SetDown()
// and RollOver() methods to change the button states.

var btnStateUp = 1;
var btnStateDown = 2;

function BmBtnSetDown()
{
    if(null == this.sImgObject)
        return;
        
	var theObject = document.getElementById(this.sImgObject);
	if(null == theObject)
		return;
        
    this.nState = btnStateDown;
    theObject.src = this.sSrcDown;
}

function BmBtnSetUp()
{
    if(null == this.sImgObject)
        return;
        
	var theObject = document.getElementById(this.sImgObject);
	if(null == theObject)
		return;
        
    this.nState = btnStateUp;
    theObject.src = this.sSrcUp;
}

function BmBtnRollOver()
{
    if(null == this.sImgObject)
        return;
        
   	if(this.bEnabled == false)
    	return;
       
 	var theObject = document.getElementById(this.sImgObject);
	if(null == theObject)
		return;
    switch(this.nState)
    {
    case btnStateUp:
        if(this.sSrcUpOver != null)
        {
            theObject.src = this.sSrcUpOver;
        }
        break;            
        
    case btnStateDown:
        if(this.sSrcDownOver != null)
        {
            theObject.src = this.sSrcDownOver;
        }
        break;            
    }
    this.bHover = true;
}

function BmBtnIsDown()
{
    if(null == this.sImgObject)
        return;
        
    return (this.nState == btnStateDown);
}


function BmBtnIsUp()
{
    if(null == this.sImgObject)
        return;
        
    return (this.nState == btnStateUp);
}



function BmBtnRollOff()
{
    if(null == this.sImgObject)
        return;
		
	var theObject = document.getElementById(this.sImgObject);
	if(null == theObject)
		return;
        
    if(this.bEnabled == false)
        return;
        
    switch(this.nState)
    {
    case btnStateUp:
        theObject.src = this.sSrcUp;
        
        break;            
        
    case btnStateDown:
        theObject.src = this.sSrcDown;
        break;            
    }
    this.bHover = false;
}



function BmBtnInit(sImgObject, sSrcUp, sSrcDown, sSrcUpOver, sSrcDownOver)
{
    // set the button state graphics - the over graphics can be null.
    this.sSrcUp = sSrcUp;
    this.sSrcDown = sSrcDown;
    this.sSrcUpOver = sSrcUpOver;
    this.sSrcDownOver = sSrcDownOver;
    
    // set which object the button is tied to.
    this.sImgObject = sImgObject;
}


function BmBtnPreload()
{
	this.imgArray = new Array();
	for(i = 0; i < 3; i++)
		this.imgArray[i] = new Image();
	this.imgArray[0].src = this.sSrcDown;
	this.imgArray[1].src = this.sSrcUpOver;
	this.imgArray[2].src = this.sSrcDownOver;
}



function BtnEnable(bEnabled)
{
    this.bEnabled = bEnabled;
}


function BtnIsEnabled()
{
    return this.bEnabled;
}




function BmButton(sImgObject, sSrcUp, sSrcDown, sSrcUpOver, sSrcDownOver)
{
    // set the methods
    this.Init = BmBtnInit;
	this.Preload = BmBtnPreload;
    this.SetDown = BmBtnSetDown;
    this.SetUp = BmBtnSetUp;
    this.RollOver = BmBtnRollOver;
    this.RollOff = BmBtnRollOff;
    this.IsDown = BmBtnIsDown;
    this.IsUp = BmBtnIsUp;
    this.Enable = BtnEnable;
    this.IsEnabled = BtnIsEnabled;
    
    // set initial button states    
    this.nState = btnStateUp;
    this.bHover = false;
    this.sImgObject = null;
    this.Enable(true);

    if(BmButton.arguments.length == 5)
        this.Init(sImgObject, sSrcUp, sSrcDown, sSrcUpOver, sSrcDownOver);
}



var btnHome = new BmButton("imgHome", "images/home.gif", null, "images/home-over.gif", null);
var btnBio = new BmButton("imgBio", "images/bio.gif", null, "images/bio-over.gif", null);
var btnMusic = new BmButton("imgMusic", "images/music.gif", null, "images/music-over.gif", null);
var btnShows = new BmButton("imgShows", "images/shows.gif", null, "images/shows-over.gif", null);
var btnTeaching = new BmButton("imgTeaching", "images/teaching.gif", null, "images/teaching-over.gif", null);
var btnResume  = new BmButton("imgResume", "images/resume.gif", null, "images/resume-over.gif", null);
var btnContact = new BmButton("imgContact", "images/contact.gif", null, "images/contact-over.gif", null);
var btnLinks = new BmButton("imgLinks", "images/links.gif", null, "images/links-over.gif", null);

function PreloadButtons()
{
	btnHome.Preload();
	btnBio.Preload();
	btnMusic.Preload();
	btnShows.Preload();
	btnTeaching.Preload();
	btnResume.Preload();
	btnContact.Preload();
}

