var hmenuImage = "url('images/menu_arrow_trans.png')"; 
function startGrow(i, lockWhenDone)
{
	var th = this;
	if(!th.nodeName)
		th = document.getElementById(i);

	if(th.bLocked) return;
	clearInterval(th.shrinkInt);
	th.bShrinking = false;
	
	showA(th.firstChild.id);

	th.growInt = setInterval("grow('" + th.id + "', " + lockWhenDone + ")", 10);
	growShrinkList.push(th.shrinkInt);
	th.bGrowing = true;
}
var growShrinkList = [];
function startShrink(i)
{
	var th = this;
	if(!th.nodeName)
		th = document.getElementById(i);

	if(th.bLocked) return;
	clearInterval(th.growInt);
	th.bGrowing = false;
	
	hideA(th.firstChild.id);

	th.shrinkInt = setInterval("shrink('"+th.id+"')", 10);
	growShrinkList.push(th.shrinkInt);
	th.bShrinking = true;
}
function shrink(i)
{
   var t = document.getElementById(i);
   if(!t) { /*alert('nothing to shrink');*/for(var c = 0; c < growShrinkList.length; c++) clearInterval(growShrinkList[c]); return; }
   var pos = ('' + t.style.backgroundPosition).search(/ /);
   var bp = '';
   if(pos > -1)
      bp = parseInt(t.style.backgroundPosition.substr(0,pos));
   bp -= 5;
/*   if(isIE6())
   {
	   if(bp < -320)
	   {
		  bp = -320;
		  clearInterval(t.shrinkInt);
	   }
   }
   else
   {*/
	   if(bp < -230)
	   {
		  bp = -230;
		  clearInterval(t.shrinkInt);
	   }
  // }
   t.style.backgroundPosition = bp + 'px';
}
function grow(i, lockWhenDone)
{
   var t = document.getElementById(i);
   if(!t) { for(var c = 0; c < growShrinkList.length; c++) clearInterval(growShrinkList[c]); return; }
   var pos = ('' + t.style.backgroundPosition).search(/ /);
   var bp = '';
   if(pos > -1)
      bp = parseInt(t.style.backgroundPosition.substr(0,pos));
   bp += 5;
   if(isIE6())
   {
	   if(bp > -210)
	   {
		  bp = -210;
		  if(lockWhenDone)
			lock(i);
		  clearInterval(t.growInt);
	   }
   }
   else
   {
	   if(bp > -190)
	   {
		  bp = -190;
		  if(lockWhenDone)
			lock(i);
		  clearInterval(t.growInt);
	   }
   }
   t.style.backgroundPosition = bp + 'px';
}
function growToLock(i)
{
   startGrow(i, true);
}
function lock(t)
{
	var th = this;
	if(!th.nodeName)
		th = document.getElementById(t).firstChild;
		
	if(th.parentNode.bLocked) return;
	var lis = document.getElementById(th.parentNode.parentNode.parentNode.id).getElementsByTagName('li');
	for(var i = 0; i < lis.length; i++)
	{
		lis[i].onmouseout = startShrink;
		lis[i].bLocked = false;
		lis[i].firstChild.onmouseout = hideA;
		if(th.parentNode.id != lis[i].id)
		{
			startShrink(lis[i].id);
			hideA(lis[i].firstChild.id);
		}
	}
	th.parentNode.bLocked = true;
	th.parentNode.onmouseout = null;
	th.onmouseout = null;
}
function unlockAndShrink(targ)
{
	var t = document.getElementById(targ);
	t.bLocked = false;
	startShrink(targ);
}
function isIE6()
{
	if(navigator.appName.search(/Microsoft Internet Explorer/i) >= 0)
	{
		var iepos = -1;
		var num = 0;
		if((iepos = navigator.appVersion.search(/MSIE/i)) >= 0)
		{
			var semi = navigator.appVersion.indexOf(';', iepos);
			num = parseFloat(navigator.appVersion.substring(iepos+4, semi));
		}
		if(num < 7)
			return true;
	}
	return false;
}
function isIE7()
{
	if(navigator.appName.search(/Microsoft Internet Explorer/i) >= 0)
	{
		var iepos = -1;
		var num = 0;
		if((iepos = navigator.appVersion.search(/MSIE/i)) >= 0)
		{
			var semi = navigator.appVersion.indexOf(';', iepos);
			num = parseFloat(navigator.appVersion.substring(iepos+4, semi));
		}
		if(num >= 7)
			return true;
	}
	return false;
}
/* TIM: SETS UP MOVERS */
function makeMover(targ, startGrown)
{
	var t = document.getElementById(targ);
	var a = t.firstChild;
	if(t && a)
	{
		if(isIE6() || isIE7())
			hmenuImage = "url('images/menu_arrow_ie6.gif')";
	   t.style.backgroundImage = hmenuImage;
	   t.style.backgroundRepeat = 'no-repeat';
	   t.style.backgroundPosition = '-190px 0px';
	   if(isIE6())
	   	  t.style.backgroundPosition = '-210px 0px';
	   t.style.color = '#FFFFFF';

		t.bLocked = false;
		startShrink(targ);

		t.onmouseover = startGrow;
		t.onmouseout = startShrink;
		t.onclick = function() { window.top.location = a.href; a.onclick(); };
		a.onclick = lock;

		if(startGrown)
		{
			startGrow(targ);
			t.onmouseout = null;
		}
	}
}
function showA(targ)
{
	var t = this;
	if(!t.nodeName)
		t = document.getElementById(targ);
	t.style.width = '120px';
}
function hideA(targ)
{
	var t = this;
	if(!t.nodeName)
		t = document.getElementById(targ);
	t.style.width = '80px';
}