//-- load back and next buttons
this.btn_back_off = new Image();
this.btn_back_on = new Image();
this.btn_forward_off = new Image();
this.btn_forward_on = new Image();

this.btn_back_off.src = '/images/s_nav_back.gif';
this.btn_back_on.src = '/images/s_nav_back_on.gif';
this.btn_forward_off.src = '/images/s_nav_forward.gif';
this.btn_forward_on.src = '/images/s_nav_forward_on.gif';
//-- eof buttons
	
// extension defaults to HTML, but can be specified as 3rd argument
function nav_link(name, page)
{
	this.name = name;
	this.page = page;
	this.extension = (arguments[2]) ? ((arguments[2] == 'null') ? '' : '.' + arguments[2]) : '.html';
}

function select_nav()
{
	this.div_style = 'margin-top: 10px; margin-bottom: 20px;';
	this.arrow_action = '';
	this.var_name = 'selectNav';
	this.on_change = 'document.location = this.options[this.selectedIndex].value;';
	this.return_type = 'write'; // how to return output (document.write or string)
	
	this.action_text = function(txt)
	{
		return (this.arrow_action) ? 'javascript: ' + this.arrow_action + '(' + txt + ');' : txt;
	}
	this.parse_url = function()
		{
			var url = (document.location.href).split("/");
			var page = (url[url.length - 1]).split(".");
			return page[0];
		}
	this.cur_page = this.parse_url(); // get the current page name
	this.pages = new Array();
	this.prev_page = function(cur)
		{
			if((cur - 1) < 0)
			{
				return (this.pages.length - 1);
			} else {
				return (cur - 1);
			}
		}
	this.next_page = function(cur)
		{
			if((cur + 1) >= this.pages.length)
			{
				return 0;
			} else {
				return (cur + 1);
			}
		}
	this.output = function ()
		{
			var link1 = '';
			var link2 = '';
			var output = '<div id="navSelect" style="' + this.div_style + '">' +
						 '<a href="' + this.action_text('---link1---') + '">' +
						 '<img onMouseOut="this.src=\'' + btn_back_off.src + '\';" onMouseOver="this.src=\'' + btn_back_on.src + '\';" width="19" height="19" src="' + btn_back_off.src + '" align="absmiddle" border="0" alt="Previous"></a> ' +
						 '<select name="' + this.var_name + '" onchange="' + this.on_change + '">';
						 
			for(var i=0; i < this.pages.length; i++)
			{
				output += '<option value="' + this.pages[i].page + this.pages[i].extension + '"' + ((this.pages[i].page == this.cur_page) ? ' SELECTED' : '') + '>' + this.pages[i].name + '</option>'; 
				if(this.pages[i].page == this.cur_page)
				{
					link1 = this.pages[this.prev_page(i)].page + this.pages[this.prev_page(i)].extension;
					link2 = this.pages[this.next_page(i)].page + this.pages[this.next_page(i)].extension;
				}
			}
			output += '</select> <a href="' + this.action_text('---link2---') + '">' +
					  '<img width="19" height="19" onMouseOut="this.src=\'' + btn_forward_off.src + '\';" onMouseOver="this.src=\'' + btn_forward_on.src + '\';" src="/images/s_nav_forward.gif" align="absmiddle" border="0" alt="Next">' +
					  '</a></div>';
			output = (output.replace(/---link1---/i, link1)).replace(/---link2---/i, link2);
			if(this.return_type == 'write')
			{
				document.write(output);
			} else {
				return output;
			}
		}
	this.add = function (name, page)
		{
			this.pages.push(new nav_link(name, page, arguments[2]));
		}
}
