/* Javascript code document for Canvin Brown */
/* created by mercury1 @ www.mercury1.co.uk */

var msgWidth = 600, bannerWidth = 650;
var timerID;

function dostuff (name,id,total)
{
	highlight(name);
	display(id,total);
}

function highlight(id)
{
	if(document.getElementById(id).className.indexOf('highlight') == -1 )
	{
		document.getElementById(id).className = document.getElementById(id).className + 'highlight';
	}
	else
	{
		document.getElementById(id).className = document.getElementById(id).className = document.getElementById(id).className.substring(0,document.getElementById(id).className.indexOf('highlight'));
	}
}

function display(id,tot)
{
  do 
  {	  	
  	document.getElementById('project'+tot).style.display = 'none';
  	tot--;
  }
  while(tot>=0);
  
  document.getElementById('project1').style.display = 'inline';
  
}

function dropdown(menuname,command)
{
	if (command == 'on')
	{
		document.getElementById(menuname).style.display = 'inline';
	}
	else if (command == 'off') 
	{
		document.getElementById(menuname).style.display = 'none';
	}
}


/* Function to start and stop scrolling */
function scroll(type) {

   if (type == 'start') {   
     scrollIt(bannerWidth, 1, 10);
   } else 
     if (timerID != null) clearTimeout(timerID);
}

/* Function to reset the text layer for next scroll */
function clearText() {
  scroll('stop');
  var el = document.getElementById('thetext');
/* Reposition the scrolling text */
  el.style.left = bannerWidth + "px";
}

/* Function that does the actually scrolling */
function scrollIt(Left, dx, speed) {
  var text = document.getElementById('thetext');
  Left -= dx;
  text.style.left = Left + "px";
  if (Left > -msgWidth)  	
  {
    timerID = setTimeout("scrollIt(" + Left + ", " + dx + ", " + speed + ")", speed);
  }
  else
  {
  	clearText();
  	scroll('start');
  }
    
}
