/*
----------------------------------------------------------------------------------------------
Image change [v1.0]
Author:   Tribal DDB HK (Garfield Chan)
Created:  27 November 2007

History:
[2007/11/27]	- v1.0 completed

---------------------------------------------------------------------------------------------- */

function NavClass() {
	// private members
	var that = this;

	/* class definition
	---------------------------------------- */
	this.GetImage = GetImage;
	this.oImgs = [];

	/* instance handler
	---------------------------------------- */
	if (arguments.length) {
		this.oName = arguments[0];
		this.element = $(this.oName);
		this.GetImage();
	}
	return this;

	/* class methods definition
	---------------------------------------- */
	// create the instance of the image object - JS
	function GetImage() {
		var a = $$(this.element,"img");
		for (var i=0; i<a.length; i++) {this.oImgs[i] = new ImgClass(a[i]);}
	}
}

function ImgClass() {
	// private members
	var that = this;
	var isOn = false;

	/* class definition
	---------------------------------------- */
	this.MouseOver = MouseOver;
	this.MouseOut = MouseOut;

	// privileged methods
	this.IsOn = IsOn;

	/* instance handler
	---------------------------------------- */
	if (arguments.length) {
		this.element = arguments[0];
		this.element.onmouseover = this.MouseOver;
		this.element.onmouseout = this.MouseOut;
	}
	return this;

	/* class methods definition
	---------------------------------------- */
	// mouse over handler - JS
	function MouseOver() {
		if (that.element.parentNode.tagName.toUpperCase() == "A")
			that.element.src = that.element.src.replace(".gif","_on.gif");
		else
			that.IsOn(true);
	}

	// mouse out handler - JS
	function MouseOut() {
		if (that.IsOn() == false)
			that.element.src = that.element.src.replace("_on.gif",".gif");
	}

	/* privileged methods
	---------------------------------------- */
	// setter and getter of current on status - JS
	function IsOn() {
		if (arguments.length) {isOn = arguments[0];}
		return isOn;
	}
}

function init() {
	oNav = new NavClass("navList");
}
addLoadEvent(init);