//
//	HOVER CLASS
//  Description : Apply hoverClassName to each control in containerElement when OnMouseOver event is fired, and back when OnMouseOut.

//  SECTION :: INCLUDES ( This includes have to be included in target html file
//	#INCLUDE ('System.js')
//		<script language='javascript' src="System.js"/>

//
// !!! IF DEBUG VARIABLE NOT SETTED AT PARENT HTML THEN SET IT AS DEFAULT VALUE = FALSE !!!
//

//CONFIG

function startup() {
if (document.all&&document.getElementById) 
{
	var tmpcontainer = document.getElementById('mainMenu');
	var hoverObj = new Hover( tmpcontainer, "IMG", "over" );
	hoverObj.init();

	}
}

// END

tmp_debug = null;
try{ tmp_debug = isNullValue( DEBUG, false );}catch( ex ){}
DEBUG = tmp_debug;

//HOVER CLASS
function Hover( containerElement, tagetTagName, hoverClassName )
{
	this.containerElement = containerElement;
	this.tagetTagName = tagetTagName;
	this.hoverClassName = hoverClassName;
	//alert( this.containerElement + "::" + hoverClassName );
}

Hover.containerElement = new Object;
Hover.tagetTagName = new String;
Hover.hoverClassName = new String;

Hover.prototype.init = function()
{
	var targets = this.containerElement.getElementsByTagName( this.tagetTagName );
	//alert( this.tagetTagName );
	for( var index = 0; index < targets.length; index++ )
	{
		var _element = targets[index];
		//alert(_element.tagName);
		_element.cuerrentHoverObject = this;
		//alert( _element.cuerrentHoverObject );
		_element.onmouseover = this.makeHover;
		_element.onmouseout = this.makeNotHover;
	}
}
Hover.prototype.getContainerElement = function()
{
	return this.containerElement;
}
Hover.prototype.getTagetTagName = function()
{
	return this.tagetTagName;
}
Hover.prototype.getHoverClassName = function()
{
	return this.hoverClassName;
}
Hover.prototype.makeHover = function() 
{
	if (this.id == 'current') return;
	this.className = isEmptyValue(this.className, (this.className + " " + this.cuerrentHoverObject.getHoverClassName()), this.cuerrentHoverObject.getHoverClassName() );
}
Hover.prototype.makeNotHover = function() 
{
	if( !isEmpty(this.className) )
	{
		if ( this.className.indexOf(" ") > -1 )
			this.className = this.className.replace(" " + this.cuerrentHoverObject.getHoverClassName(), "");
		else
			this.className = this.className.replace(this.cuerrentHoverObject.getHoverClassName(), "");
	}
}

// SYSTEM

function isNull( value )
{
	return (value == null || typeof(value) == "undefined");
}
// Returns nullValue if null otherwise value.
function isNullValue( value, nullValue )
{
	return (isNull(value)?nullValue:value);
}

function isEmpty( value )
{
	if( isNull(value) || value == "" ) return true;
	else return false;
}
function isEmptyValue( value, nonEmptyValue, emptyValue )
{
	if( isNull(value) || value == "" ) return emptyValue;
	else return nonEmptyValue;
}

window.onload=startup;