var id_list = new Array();
var on_drop_down = '';
var x_offset = 0;
var y_offset = 0;

function w(i) { document.writeln(i); }
function show(i) { document.getElementById(i).style.display = "block"; }
function hide(i) { document.getElementById(i).style.display = "none"; }
function url(i) { location.href = i; }

function ch_class(i, new_class)
{
	var oclass = i.className;
	i.className = new_class;
	i.onmouseout = function() { i.className = oclass; }
}

function ch_img(i, src)
{
	var oimg = i.src;
	i.src = src;
	i.onmouseout = function() { i.src = oimg; }
}

function set_on_dd(i, t)
{
	on_drop_down = t;
	if(i.className != "navbar_dd_table")
	{
		i.className = 'navbar_mm_active';
		i.onmouseout = function() { on_drop_down = ''; i.className = 'navbar_mm'; }
	}
	else
	{
		i.onmouseout = function() { on_drop_down = ''; }
	}
}

function pos(obj, dir)
{
	var i = 0;
	if(obj.offsetParent)
	{
		while(obj.offsetParent)
		{
			if(dir == "x") { i += obj.offsetLeft; }
			else if(dir == "y") { i += obj.offsetTop; }
			obj = obj.offsetParent;
		}
	}
	else if(dir == "x") { if(obj.x) { i += obj.x; } }
	else if(dir == "y") { if(obj.y) { i += obj.y; } }
	return i;
}

function drop_down(pd, id, i)
{
	var x = document.getElementById(id);
	
	if(pd == 1)
	{
		show(id);
		
		x.style.top = pos(i, 'y') + y_offset;
		x.style.left = pos(i, 'x') + x_offset;
		setTimeout("drop_down(0,'" + id + "')", 250);
		for(var z = 0; z < id_list.length; z++) { var t = 'nav' + z; if(t != id) { hide(t); } }
	}
	else
	{
		if(on_drop_down == "")
		{
			hide(id);
		}
		else { setTimeout("drop_down(0,'" + on_drop_down + "')", 250); }
	}
}

function build_dd()
{
	w('<table border="0" cellpadding="0" cellspacing="0" class="navbar_mm_table"><tr>');
	
	for(var z = 0; z < id_list.length; z++)
	{
		var x = id_list[z].split(/\|/);
		var sublist = ((x.length - 1) / 2)-1;

		w('<td style="padding: 5px 10px 5px 10px;">');

		if(x[2] == "_")
		{
			w('<span onmouseover="drop_down(1,\'nav'+z+'\',this); set_on_dd(this,\'nav'+z+'\');" class="navbar_mm">');
		}
		else
		{
			filename = x[2].replace(base_url, '');
			if(location.href.indexOf(filename) > -1)
			{
				//w('<span onclick="url(\''+x[2]+'\');" class="navbar_mm_active">');
				w('<img src="images/' + x[1] + '_on.gif" onmouseover="ch_img(this, \'images/' + x[1] + '_on.gif\')" onclick="url(\''+x[2]+'\');" class="pointer" />');
			}
			else
			{
				//w('<span onclick="url(\''+x[2]+'\');" onmouseover="ch_class(this, \'navbar_mm_active\')" class="navbar_mm">');
				w('<img src="images/' + x[1] + '.gif" onmouseover="ch_img(this, \'images/' + x[1] + '_on.gif\')" onclick="url(\''+x[2]+'\');" class="pointer" />');
			}
		}

		//w(x[1]);
		//w('<img src="images/' + x[1] + '.gif" onmouseover="ch_img(this, \'images/' + x[1] + '_on.gif\')" />');
		//w('</span>');
		w('<div id="nav'+z+'" style="display:none;position:absolute; z-index: 999;">');
		w('<table onmouseover="set_on_dd(this,\'nav'+z+'\');" width="' + x[0] + '" class="navbar_dd_table">');
		
		for(var p = 0; p < sublist; p++)
		{
			w('<tr>');
			
			if(x[(p*2) + 4] != "_")
			{
				if(x[(p*2)+4].indexOf(";") < 0)
				{
					w('<td class="navbar_dd" onmouseover="ch_class(this,\'navbar_dd_active\');" onclick="url(\''+x[(p*2)+4]+'\');">');
				}
				else
				{
					w('<td class="navbar_dd" onmouseover="ch_class(this,\'navbar_dd_active\');" onclick="' + x[(p*2)+4] + '">');
				}
																																				
				w(x[(p*2)+3]);
				w('</td>');
			}
			else { w('<td align="center" class="navbar_dd_no_link">' + x[(p*2) + 3] + '</td>'); }
			
			w('</tr>');
		}

		w('</table></div></td>');
	
		if(z < id_list.length - 1) { w('<td class="navbar_main_menu" style="font-size: 10px;">|</td>'); }
	}
	
	w('</tr></table>');
}

x_offset = 0;
y_offset = 17;
base_url = "/";
navcount = 0;

id_list[navcount] = "200|portfolio|" + base_url + "portfolio.htm";

navcount++;

id_list[navcount] = "200|philosophy|" + base_url + "philosophy.htm";

navcount++;

id_list[navcount] = "200|clients|" + base_url + "clients.htm";

navcount++;

id_list[navcount] = "200|contact|" + base_url + "contact.htm";

document.writeln('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
document.writeln('<tr valign="baseline">');
document.writeln('<td><a href="index.htm" target="_top"><img src="/images/logo.jpg" border="0" alt=""></a></td>');
document.writeln('<td align="right" style="padding-right: 20px;">All images &copy; Tim Rue</td>');
document.writeln('</tr>');
document.writeln('<tr>');
document.writeln('<td colspan="2" bgcolor="#9F8762" height="18">');
build_dd();
document.writeln('</td>');
document.writeln('</tr>');
document.writeln('</table>');