﻿
var j = jQuery.noConflict();

function MainNavItem(anchor, onImage, offImage, reactToPath)
{
	this.onImage = onImage;
	this.offImage = offImage;
	this.headerImage = j(anchor.children("img")[0]);
	this.reactToPath = reactToPath;

	if (this.checkPathHighlight())
		this.highlight(null, this);

	this.headerImage.mouseover(function()
	{
		this.src = onImage;
	});
}

MainNavItem.prototype = {

	highlight: function(menu, owner)
	{
		owner.headerImage.attr("src", owner.onImage);
	},

	removeHighlight: function(menu, owner)
	{
		if(!owner.checkPathHighlight())
			owner.headerImage.attr("src", owner.offImage);
	},

	checkPathHighlight: function()
	{
		if (this.reactToPath)
		{
			return this.reactToPath.test(window.location.pathname);
		}
		return false;
	}
};
