var menu_first_none	= 'top_menu_first_none.gif';
var menu_first_hover = 'top_menu_first_hover.gif';

var menu_last_none = 'top_menu_last_none.gif';
var menu_last_hover = 'top_menu_last_hover.gif';

var menu_other_bg = 'top_menu_other_bg.gif';
var menu_other_both = 'top_menu_other_both.gif';

var menu_hover_left = 'top_menu_hover_left.gif';
var menu_hover_right = 'top_menu_hover_right.gif';
var menu_hover_bg = 'top_menu_hover_bg.gif';

var menu_hover_all_left = 'top_menu_hover_all_left.gif';
var menu_hover_all_right = 'top_menu_hover_all_right.gif';

function topMenu()
{
	var tds = document.getElementById('top_menu').getElementsByTagName('td');

	for(var i = 0; i < tds.length; i++)
	{
		if(tds[i].id == '')
		{
			tds[i].style.backgroundRepeat = 'no-repeat';

			if(tds[i].id != 'linx_first' && tds[i].id != 'linx_last')
			{
				tds[i].style.backgroundImage = 'url(/images/' + menu_other_both + ')';
			}
		}
		else
		{
			tds[i].style.backgroundImage = 'url(/images/' + menu_other_bg + ')';
			tds[i].style.backgroundRepeat = 'repeat-x';

			if(tds[i].id == 'linx_first')
			{
				tds[i].style.backgroundImage = 'url(/images/' + menu_first_none + ')';
			}

			if(tds[i].id == 'linx_last')
			{
				tds[i].style.backgroundImage = 'url(/images/' + menu_last_none + ')';
			}
		}
	}
}

function initMenu()
{
	topMenu();

	var linx = document.getElementById('top_menu').getElementsByTagName('A');
	for(var i = 0; i < linx.length; i++)
	{
		var loc = window.location.href.split(/\?/)[0].replace("www.", "");
		if(loc == linx[i].href.replace("www.", ""))
		{
			menuBookmarkOver(linx[i].parentNode);
		}
/*		else
		{
			linx[i].parentNode.onmouseover = menuBookmarkOver;
			linx[i].parentNode.onmouseout  = menuBookmarkOut;
		}*/
	}
}

function menuBookmarkOver(obj)
{
	var tds = obj? obj: this;
	if(tds.id != '' && tds.id != undefined)
	{
		tds.style.backgroundImage = 'url(/images/' + menu_hover_bg + ')';
		tds.style.backgroundRepeat = 'repeat-x';

		if(tds.previousSibling.style.backgroundImage == "url(/images/" + menu_hover_right + ")")
		{
			tds.previousSibling.style.backgroundImage = 'url(/images/' + (tds.previousSibling.id == 'linx_first' ? menu_first_hover : menu_hover_all_left) + ')';
		}
		else
		{
			tds.previousSibling.style.backgroundImage = 'url(/images/' + (tds.previousSibling.id == 'linx_first' ? menu_first_hover : menu_hover_left) + ')';
		}
		tds.previousSibling.style.backgroundRepeat = 'no-repeat';


		if(tds.nextSibling.style.backgroundImage == "url(/images/" + menu_hover_left + ")")
		{
			tds.nextSibling.style.backgroundImage = 'url(/images/' + (tds.nextSibling.id == 'linx_last' ? menu_last_hover : menu_hover_all_right) + ')';
		}
		else
		{
			tds.nextSibling.style.backgroundImage = 'url(/images/' + (tds.nextSibling.id == 'linx_last' ? menu_last_hover : menu_hover_right) + ')';
		}
		tds.nextSibling.style.backgroundRepeat = 'no-repeat';
	}
}

function menuBookmarkOut(obj)
{
	var tds = obj? obj: this;
	if(tds.id != '' && tds.id != undefined)
	{
		tds.style.backgroundImage = 'url(/images/' + menu_other_bg + ')';
		tds.style.backgroundRepeat = 'repeat-x';

		if(tds.previousSibling.style.backgroundImage == "url(/images/" + menu_hover_all_left + ")")
		{
			tds.previousSibling.style.backgroundImage = 'url(/images/' + (tds.previousSibling.id == 'linx_first' ? menu_first_hover : menu_hover_right) + ')';
		}
		else
		{
			tds.previousSibling.style.backgroundImage = 'url(/images/' + (tds.previousSibling.id == 'linx_first' ? menu_first_none : menu_other_both) + ')';
		}
		tds.previousSibling.style.backgroundRepeat = 'no-repeat';

		if(tds.nextSibling.style.backgroundImage == "url(/images/" + menu_hover_all_right + ")")
		{
			tds.nextSibling.style.backgroundImage = 'url(/images/' + (tds.nextSibling.id == 'linx_last' ? menu_last_hover : menu_hover_left) + ')';
		}
		else
		{
			tds.nextSibling.style.backgroundImage = 'url(/images/' + (tds.nextSibling.id == 'linx_last' ? menu_last_none : menu_other_both) + ')';
		}

		tds.nextSibling.style.backgroundRepeat = 'no-repeat';
	}
}

function verify_form(this_id)
{
	if(event.keyCode == 13)
		document.getElementById(this_id).submit();
}
