<!-- 
//master function that will get the next contact and call the function to do the changing
// --- if you want to add more contact addressess just change the maximum that CON can be before it returns to 1, and add an extra case in the switch in getContact ---

var mainTimer;
var decomposeTimer;
var buildTimer;

// FUNCTION BLOCK //

function rotate(con) {
 con++;
 if (con >= 4) { con = 1; }
 mainTimer = setTimeout("changeContact("+con+")",5000);  
}

//the function that does the changing of the contact and then goes back to rotate with the number, so it can be incremented and called over.
function changeContact(con) {

  //decompose the current texts from the element ids given.
  decompose("office",10,con);
  
  clearTimeout(mainTimer);
 }

//function to slowly decompose a string letter by letter

function decompose(element,speed,con) {
  len = document.getElementById(element).innerHTML.length;
  clearTimeout(decomposeTimer);
  
  if (len > 0) {
    cur = document.getElementById(element).innerHTML;
    sub = cur.substring(0,cur.length - 1);
	document.getElementById(element).innerHTML = sub;
    decomposeTimer = setTimeout("decompose('"+element+"',"+speed+","+con+")",speed);
  } else {
    var dets = getContact(con);
	var bits = dets.split(":");
	
	document.getElementById("tel_no").innerHTML = bits[1];
	document.getElementById("fax_no").innerHTML = bits[2];
	
    buildString("office",bits[0],10,con);	
  }
}

//function to build a string up letter by letter - almost the reverse of decompose
function buildString(element,string,speed,con) {
  len = document.getElementById(element).innerHTML.length;
  clearTimeout(buildTimer);
  
  if (len < string.length) {
    sub = string.substring(0,len+1);
	document.getElementById(element).innerHTML = sub;
    buildTimer = setTimeout("buildString('"+element+"','"+string+"',"+speed+","+con+")",speed);
  } else {
	rotate(con);  
  }  
}

//handy place to keep the different office details.
function getContact(d) {
	switch (d) {
	  case 1:
	   var off = "Scarborough Office";
	   var tel = "01723 360001";
	   var fax = "01723 353973";
	   break;
	  
	  case 2:
	   var off = "Helmsley Office";
	   var tel = "01439 770207";
	   var fax = "01439 771650";
	   break;
	  
	  case 3:
	   var off = "Whitby Office";
	   var tel = "01947 602131";
	   var fax = "01947 606165";
	   break;
	}
	
	var ret = off + ":" + tel + ":" + fax + ":";
	return ret;
}
-->