/*
--------------------------------------------------------------------------------------------------------
The source code contained herein is the property of 
Joseph A. Gonzalez
The source code may not be used without the express
written permission of Joseph A. Gonzalez

Usage - on page where image is placed use:
	<script>new oButton('NAME_OF_BUTTON','HREF_OF_BUTTON','ALT_TEXT_FOR_BUTTON');</script>

Tested in IE 6+ and Mozilla FireFox 0.9.1
--------------------------------------------------------------------------------------------------------
*/
var section
var offDir = "images/subnav/";   	
var onDir = "images/subnav/";		
var offExt = "_off.gif";		// What is the OFF image extention (ie what gets appended to the button name)
var onExt = "_on.gif";			// What is the ON image extention

// BUTTON OBJECT
function oButton(btnName,link, alt)
{	
	this.btnImg = new Image();
	this.btnImg.src = offDir + btnName + offExt;
	
	if (link.indexOf("http") >= 0)  // write the anchor open
	{	document.write("<a name='a_"+btnName+"' id='a_" + btnName + "' href='"+link+"' target='blank' />");   }
	else
	{	document.write("<a name='a_"+btnName+"' id='a_" + btnName + "' href='"+link+"' />");  }
		
	document.write("<img name='"+btnName+"' id='" + btnName + "' border='0' alt='"+alt+"' />"); // write the image
	document.write("</a>");  // write the anchor close
	
	//this = new anch();
	this.docAnc = document.getElementById("a_"+btnName);            // the document anchor	
	this.docBtn = document.getElementById(btnName);					// the document button
	
	// don't mouse over current section
	// NOTE the section variable must be set in the page
	if (section != btnName)
	{	
		this.docBtn.src =  this.btnImg.src;	
		this.docBtn.onmouseover = mOver;
		this.docBtn.onmouseout = mOut;		
		this.docBtn.onSrc = new Image();
		this.docBtn.onSrc.src = onDir + this.docBtn.name + onExt;
		this.docBtn.offSrc = new Image();
		this.docBtn.offSrc.src = this.btnImg.src;
	}
	else
	{
		this.docBtn.src =  this.btnImg.src;
	}

	this.docAnc.alt = alt;
}
 
// MOUSEOVER FUNCTION
function mOver()
{
	this.src = this.onSrc.src;
	// window.status = this.alt; // Uncomment to change window status to alt text - IE only
	return true;
}

// MOUSEOUT FUNCTION
function mOut()
{
	this.src = this.offSrc.src;
	return true;
}
// --------------------------------------------------------------------------------------------------------
