// ========================================
// images.js
// ========================================


/**
* Preloads images needed for rollovers.
*/
if (document.images)
{
	// Main navigation images
	HomeBtn = new Image;
	HomeBtn.src = '/images/nav/btn_home.png';
	HomeBtn_o = new Image;
	HomeBtn_o.src = '/images/nav/btn_home_o.png';
	AboutBtn = new Image;
	AboutBtn.src = '/images/nav/btn_about.png';
	AboutBtn_o = new Image;
	AboutBtn_o.src = '/images/nav/btn_about_o.png';
	FirstBtn = new Image;
	FirstBtn.src = '/images/nav/btn_first.png';
	FirstBtn_o = new Image;
	FirstBtn_o.src = '/images/nav/btn_first_o.png';
	PreviousBtn = new Image;
	PreviousBtn.src = '/images/nav/btn_previous.png';
	PreviousBtn_o = new Image;
	PreviousBtn_o.src = '/images/nav/btn_previous_o.png';
	NextBtn = new Image;
	NextBtn.src = '/images/nav/btn_next.png';
	NextBtn_o = new Image;
	NextBtn_o.src = '/images/nav/btn_next_o.png';
	CurrentBtn = new Image;
	CurrentBtn.src = '/images/nav/btn_current.png';
	CurrentBtn_o = new Image;
	CurrentBtn_o.src = '/images/nav/btn_current_o.png';
}

// Create "onload" event queue.
ev_addLoadEvent(prepareMainNav);


// ----------------------------------------
// Public
// ----------------------------------------

/**
* Prepares navigation functionality.
*/
function prepareMainNav() { prepareNav('MainNav'); }


// ----------------------------------------
// Private
// ----------------------------------------

/**
* Adds rollover/rollout functionality to navigation.
*/
function prepareNav(id)
{
	// Check if user agent understands.
	if (document.getElementById && document.getElementsByTagName && document.images)
	{
		// Check if the id exists.
		if (document.getElementById(id))
		{
			var nav = document.getElementById(id);
			var li_collection = nav.getElementsByTagName('li');
			var a_collection = nav.getElementsByTagName('a');
			var num_a = a_collection.length;
			// Loop through links and add rollovers.
			for (var i = 0; i < num_a; i++)
			{
				// "selected" links do not have rollovers
				if (li_collection[i].className.indexOf('selected') == -1)
				{
					// 'onmouseover' event
					a_collection[i].onmouseover = function()
					{
						var imgs = this.getElementsByTagName('img');
						var img_name = imgs[0].name;
						var img_src_name = img_name + '_o';
						document[img_name].src = eval(img_src_name + '.src');
					}
					// 'onmouseout' event
					a_collection[i].onmouseout = function()
					{
						var imgs = this.getElementsByTagName('img');
						var img_name = imgs[0].name;
						var img_src_name = img_name;
						document[img_name].src = eval(img_src_name + '.src');
					}
				}
			}
		}
	}
}

// EOF