
var menuWidth   = 0
var menuButtons = new Array()
var menuPages   = new Array()


include('inc/hits.js')

function include(script_filename) {
    document.write('<' + 'script');
    document.write(' language="javascript"');
    document.write(' type="text/javascript"');
    document.write(' src="' + script_filename + '">');
    document.write('</' + 'script' + '>');
}


// banner picture
document.write('<table cellspacing=0 cellpadding=0 align="center" width=920>')
document.write('<tr><td colspan=2 background="Pics\\Tracky.jpg" height=100 width=920>')
document.write('</td></tr>')
	
document.write('<tr><td colspan=2>')
	document.write('<table cellspacing=0 cellpadding=0>')
	document.write('<tr>')
	document.write('<td>')
	MenuHeader()
	MenuButton('buttonHome'    ,'Home'    ,'indexWM.html'   	)
	MenuButton('buttonTrackMe' ,'TrackMe' ,'TrackMe2.html'	)
	MenuButton('buttonManual'  ,'Manual'  ,'Manual.htm'	)
	MenuButton('buttonDownload','Free<br>download','Download.htm'	)
	MenuButton('buttonBuy'     ,'Buy<br><b><font color=yellow><blink>33% off!</blink></font></b>'     ,'Buy2.htm'	)
	MenuButton('buttonQandA'   ,'Q&A'     ,'QandA.htm'	)
	MenuButton('buttonAndroid' ,'<b><font color=yellow><blink>Tracky for Android!</blink></font></b>','indexAndroid.html'	)
	MenuFooter(920)
	document.write('</td>')
	document.write('</tr>')
	document.write('</table>')
document.write('</td></tr>')
document.write('<tr><td colspan=2 height=7></td></tr>')

document.write('<tr><td width=800px>')


function MenuOnMouseOver(button)
{
	var src
	if (button == MenuButtonSelectedGet())
	{
		src = btn_sel.src
	}
	else
	{
		src = btn_over.src
	}
	document.getElementById(button).style.background = 'url(\'' + src + '\')'
}

function MenuOnMouseOut(button)
{
	var src
	if (button == MenuButtonSelectedGet())
	{
		src = btn_sel.src
	}
	else
	{
		src = btn_up.src
	}
	document.getElementById(button).style.background = 'url(\'' + src + '\')'
}

function MenuOnSelect(button)
{
	var src
	if (button == MenuButtonSelectedGet())
	{
		src = btn_sel.src
	}
	var buttonObj
	buttonObj = document.getElementById(button)
	if (buttonObj)
	{
		buttonObj.style.background = 'url(\'' + src + '\')'
	}
}

function MenuButtonSelectedGet()
{
	// search for menu page which matches current url
	var url = self.location.href.toUpperCase()
	
	var lastChar = url.charAt(url.length-1) 
	if ('/' == lastChar)
	{
		button = menuButtons[0]
	}
	else
	{
		var i	= menuPages.length - 1
		while (0 <= i)
		{
			if (0 <= url.indexOf(menuPages[i]))
			{
				// found!
				break;
			}
			else
			{
				i--
			}		
		}
		if (i < 0)
		{
			button = 0
		}
		else
		{
			button = menuButtons[i]
		}
	}
	
	return button
}

function MenuHeader()
{
	// PRELOADING IMAGES
	if (document.images)
	{
		btn_up	 = new Image(); btn_up.src   ="pics/menuUp.png" 
		btn_over = new Image(); btn_over.src ="pics/menuOver.png" 
		btn_sel	 = new Image(); btn_sel.src  ="pics/menuSel.png"
	}

	menuWidth = 35
	document.write('<table cellspacing=0 cellpadding=0>')
	document.write('<tr height=38>')
	document.write('<td width=35 background="pics\\menuLeft.png"></td>')
}

function MenuButton(id,title,url)
{
	menuButtons.push(id)
	menuPages.push(url.toUpperCase())
	
	menuWidth += 100
	document.write('<td width=100 style="vertical-align:middle;" ')
	document.write('background="' + btn_up.src + '" ')
	document.write('id=' + id + ' ')
	document.write('align=center ')
	document.write('onmouseover=\'MenuOnMouseOver("' + id + '")\' ')
	document.write('onmouseout=\'MenuOnMouseOut("' + id + '")\' ')
	document.write('onclick=\'self.location.href="' + url + '"\' ')
	document.write('>')
	document.write('<font color=white><b><a href="#" style="color: white; text-decoration:none;">' + title + '</a></b></font>')
	document.write('</td>')	    
}

function MenuFooter(width)
{
	var fillWidth
	fillWidth =  Math.max(0,width-menuWidth-45)
	document.write('<td width=2  background="pics\\menuRightPrefix.png"></td>')
	document.write('<td width=' + fillWidth + ' background="pics\\menuFill.png"></td>')
	document.write('<td width=43 background="pics\\menuRight.png"></td>')
	document.write('</tr>')
	document.write('</table>')

	// select button
	var button = MenuButtonSelectedGet()
	if (button)
	{
		MenuOnSelect(button)
	}
}


