// -*- coding: utf-8 -*-

/**
 * this class manages mouseover and mouseout event for the menu entries
 */

function Menu()
{
	// private
	var strObject = "Menu" ;
	var strSuffix = "" ;

	// public
	this.setSuffix = function(strNewSuffix)
	{
		strSuffix = strNewSuffix ;
	}

	this.getSuffix = function()
	{
		return strSuffix ;
	}

	this.onMouseOver = function(objImage, strAlwaysMouseOver)
	{
		if (objImage.id != strAlwaysMouseOver)
		{
			objImage.src = this.onMouseOverImageSource(objImage.src) ;
		}
	}

	this.onMouseOut = function(objImage, strAlwaysMouseOver)
	{
		if (objImage.id != strAlwaysMouseOver)
		{
			objImage.src = this.onMouseOutImageSource(objImage.src) ;
		}
	}

	this.onMouseOverImageSource = function(strImageSource)
	{
		var strBaseName = this.getBaseName(strImageSource) ;
		var strExtensionName = this.getExtensionName(strImageSource) ;

		strBaseName = strBaseName.replace(this.getSuffix(), "") ;
		strBaseName = strBaseName.replace("_focus", "") ;
		return strBaseName + "_focus" + this.getSuffix() + "." + "jpg" ;
	}

	this.onMouseOutImageSource = function(strImageSource)
	{
		var strBaseName = this.getBaseName(strImageSource) ;
		var strExtensionName = this.getExtensionName(strImageSource) ;

		strBaseName = strBaseName.replace(this.getSuffix(), "") ;
		strBaseName = strBaseName.replace("_focus", "") ;
		return strBaseName + this.getSuffix() + "." + "jpg" ;
	}

	this.getBaseName = function(strString)
	{
		var intLastDotPosition = strString.lastIndexOf(".") ;
		return strString.substr(0, intLastDotPosition) ;
	}

	this.getExtensionName = function(strString)
	{
		var intLastDotPosition = strString.lastIndexOf(".") ;
		return strString.substr(intLastDotPosition + 1) ;
	}
}

var objMenu = new Menu() ;

