//last modified 1-31-06
//will highlight the button of the page that is currently visited.
// BEGIN: Rollovers
function GetFileNameWithExtension(str){return str.substring(str.lastIndexOf('/') + 1, str.length)}
function GetFileName(str){return str.substring(str.lastIndexOf('/') + 1, str.lastIndexOf('.'))}
function GetExtension(str){return str.substring(str.lastIndexOf('.') + 1, str.length)}

function GetEarl(par, whost)
{
	var whost = window.location.protocol + "//" + window.location.hostname;
	if(window.location.port) {whost += ":" + window.location.port}

	var phref =  par.href.replace(whost, "").split("/")[1];

	if(phref.indexOf(".") != -1)
		{ //if there's a dot, parse it out
		phref = phref.split(".")[0]; //explode into an array by period
		}
	return phref;

}

var images;

images = document.getElementsByTagName("img");
for(i = 0; i < images.length; i++)
{
	ProcessImage(images[i]);
}

images = document.getElementsByTagName("input");
for(i = 0; i < images.length; i++)
{
	if (images[i].type == "image")
		ProcessImage(images[i]);
}

function ProcessImage(img)
{
	var sFullName = GetFileNameWithExtension(img.src);
	var sFileName = GetFileName(img.src);
	var sExtension = GetExtension(img.src);	

	if (sFileName.length < 3)
		return;

	if (sFileName.substring(0, 3).toLowerCase() != "btn")
		return;

	if(img.id == null || img.id == "" || img.id == "null" || img.id == "undefined")
		img.id = sFileName + "_" + i;

	if (img.id.length <= 0)
		return;

	var imgOff = new Image();
	imgOff.src = "/img/" + sFullName; //added leading slash so it works in sub directories -jp			

	var imgOn = new Image();
	imgOn.src = "/img/" + sFileName + "_over." + sExtension; //added leading slash -jp	

	//check the parent href if it's an anchor tag
	if(img.nodeName == "IMG") 
	{
		var par = img.parentNode;
		while(par.nodeName != "A") { par = par.parentNode; }
		//some browsers might return a text node as the parent, keep going to find the <a> element
		var phref = GetEarl(par);  //get the parent link's href
		if(window.location.pathname.replace(/\//g, "") == "") 
			//special circumstance for default.aspx or index
			{
				if (phref == "default" || phref == "index" || phref == "")
					{
					img.src = imgOn.src;
					return
					}
			}
		if(phref.length>2 && window.location.pathname.substring(1, phref.length+1) == phref)//compare phref with the window location
			{
				img.src = imgOn.src;
			}
			else
			{
				img.imgOn = imgOn.src;
				img.imgOff = imgOff.src;
				img.onmouseover = function() { this.src = this.imgOn };
				img.onmouseout = function() { this.src = this.imgOff };
			}
		}
		else //it's a button
		{
			img.imgOn = imgOn.src;
			img.imgOff = imgOff.src;
			img.onmouseover = function() { this.src = this.imgOn };
			img.onmouseout = function() { this.src = this.imgOff };
		}

	} //end ProcessImage
// END: Rollovers