<!--
var buffer = 0;
var maxlevel = 0;
var increment = 4;
var interval = 1;
var moving_up = new Array(false, false, false, false, false);
var moving_down = new Array(false, false, false, false, false);
var diff = 5
var shadowdiff = diff-2;
var adj = 3;
var movement = false;
initpage = function() {
	// position the hidden menus
	if(getElementById('menu1')) {
		setTop(1, buffer - getElementById('menu1').offsetHeight-diff);
		setTop(2, buffer - getElementById('menu2').offsetHeight-diff);
		setTop(3, buffer - getElementById('menu3').offsetHeight-diff);
		setTop(4, buffer - getElementById('menu4').offsetHeight-diff);
	}
}
window.onload = initpage;

function setTop(n, t) {
	if(document.all) {
		getElementById('menu'+n).style.pixelTop = t;
	} else {
		getElementById('menu'+n).style.top = t + 'px';
	}
}
function getCurrentPosition(div) {
	return parseInt(getElementById(div).style.top);
}
function showmenu(n) {
	//alert(getCurrentPosition('menu'+n));
	getElementById('menucontainer').style.height = '280px';
	clearInterval(moving_up[n]);
	moving_down[n] = setInterval("moveMenuDown("+n+")", interval);
}
function hidemenu(n) {
	clearInterval(moving_down[n]);
	moving_up[n] = setInterval("moveMenuUp("+n+")", interval);
}
function moveMenuUp(n) {
	var div = 'menu' + n;
	if(getCurrentPosition(div) > (buffer - getElementById(div).offsetHeight - shadowdiff)) { 
		setTop(n, getCurrentPosition(div) - increment);
	} else {
		clearInterval(moving_up[n]);
		var menu_showing = false;
		for(var i=1; i<=4; ++i) {
			if(getCurrentPosition('menu'+i) > buffer - getElementById('menu'+i).offsetHeight - shadowdiff) menu_showing = true;
		}
		if(!menu_showing) getElementById('menucontainer').style.height = '1px';
	}
}
function moveMenuDown(n) {
	var div = 'menu' + n;
	var diff = (getElementById(div).offsetHeight) % increment;
	var pos = getCurrentPosition(div);
	if(pos < maxlevel - increment) {
		setTop(n, getCurrentPosition(div) + increment);
	} else if(pos >= (maxlevel - increment) && pos < maxlevel) { 
		setTop(n, maxlevel);
	} else {
		clearInterval(moving_down[n]);
		moving_down[n] = false;
	}
}

/*
function hideAll(n) {
	for(var i=1; i<=4; ++i) {
		if(i!=n) hidemenu(i);
	}
}
function clearAll(n, dir) {
	for(var i=1; i<=4; ++i) {
		if(i!=n) {
			if(dir == 'up') clearInterval(moving_up[i]);
			else clearInterval(moving_down[i]);
		}
	}
}
*/
/*
function dohide(n) {
	clearInterval(moving_down[n]);
	if(getCurrentPosition('menu'+n) > minlevel+1) {
		if(!moving_up[n]) {
			moving_up[n] = setInterval("moveMenuUp("+n+")", 1);
		} 
	} else {
		clearInterval(moving_up[n]);
		moving_up[n] = false;
	}
}

*/
/*
	var menux = parseInt(getElementById('menu'+n).style.top);
	var menuy = parseInt(getElementById('menu'+n).style.left);
	var menuw = getElementById('menu'+n).offsetWidth;
	var menuh = getElementById('menu'+n).offsetHeight;
	if(event.x < menux || event.x > menux + menuw || event.y < menuy || event.y > menuy + menuh) {
		//setTimeout("dohide("+n+")", 500);
		dohide(n);
	alert('x='+event.x + ' y='+event.y+' '+menux+' '+menuy+' '+menuw+ ' ' +menuh);
	}
*/


function highlightField(f) {
	if(getElementById(f)) {
		getElementById(f).className = 'text-high';
	}
}


// gets width of window
function getWindowWidth() {
  var myWidth = 0;
  if(typeof(window.innerWidth) == 'number') {
    //Non-IE
    myWidth = window.innerWidth;
  } else if(document.documentElement && (document.documentElement.clientWidth )) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if(document.body && (document.body.clientWidth)) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return(myWidth);
}

function getWindowHeight() {
  var myHeight = 0;
  if(typeof(window.innerHeight) == 'number') {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && (document.documentElement.clientHeight)) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if(document.body && (document.body.clientHeight)) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  return(myHeight);
}


function getElementById(id) {
	if (document.all) {
		return document.all[id];
	} else  {
		return document.getElementById(id);
	}
}

function getElementByName(name) {
	if (document.all) {
		return document.all[name];
	} else  {
		return document.getElementByName(name);
	}
}

function readCookie(name) {
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0) { 
    offset = document.cookie.indexOf(search);
    if (offset != -1) { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function deleteCookie(name) {
	var todayDate = new Date();
	todayDate.setDate(todayDate.getDate() - 1);
	document.cookie = name + "=delete; expires=" + todayDate.toGMTString() + ";path=/;";
}

function SetCookie(name, value, expdate) {
	document.cookie = name + "=" + escape(value) + "; expires=" + expdate.toGMTString() + ";path=/;";
}

//====================================================================
// following code (not used currently) can be used to preload images
function loadImages() {
	for (count=0; count <= (mouseOverImageArray.length - 1); count = count + 2) {
		eval(mouseOverImageArray[count] + "_off = new Image();");
		eval(mouseOverImageArray[count] + "_off.src = '" + mouseOverImagePath + mouseOverImageArray[count] + "_off." + mouseOverImageArray[count+1] + "';");
		eval(mouseOverImageArray[count] + "_on = new Image();");
		eval(mouseOverImageArray[count] + "_on.src = '" + mouseOverImagePath + mouseOverImageArray[count] + "_on." + mouseOverImageArray[count+1] + "';");
	}
}
// images must be stored in this directory and be named, for example
// citrix_on.gif, citrix_off.gif
var mouseOverImagePath = '/images/template/';
//mouseOverImageArray = new Array(
//"citrix", "gif", 
//"offices", "gif"
//);
mouseOverImageArray = new Array();
loadImages();
//====================================================================


function checkLength(elem, len) {
	/* 
	 To use this function the input (type=text) or textarea must have its id attribute set
	 There must be an empty div element with an id of the same name with '-msg' at the end to display the error message
	 Call using... onkeyup="checkLength(this, 50)" ...where 50 is the maximum length you want to allow
	 e.g. 
	 <textarea id="Comments" name="Comments" onkeyup="checkLength(this, 50)"></textarea>
	 <div id="Comments-msg"></div>
	*/
	if(elem.value.length >= len) {
		if(getElementById(elem.id + '-msg')) {
			getElementById(elem.id + '-msg').innerHTML = 'You have reached the maximum length';
		}
		elem.value = elem.value.substr(0, len);
	} else {
		if(getElementById(elem.id + '-msg')) {
			getElementById(elem.id + '-msg').innerHTML = '';
		}
	}
}

var mapWin = null;
function getDirections(start1, finish) {
	start2 = start1.replace(/\s+/g, "+");
	url = 'http://maps.google.co.uk/?ie=UTF8&hl=en&q='+start2+'+to+'+finish+'&f=q'
	mapWin = window.open(url);
	return false;
}

function schk(f) {
	f.action = '/contactus.htm';
}
function schk2(f) {
	f.action = '/stay-informed/signup.htm';
}
function schk3(f) {
	f.action = '/stay-informed/events/regform.htm';
}
function schk4(f) {
	f.action = '/claretsinjury/default.htm';
}
function schk5(f) {
	f.action = '/for-your-business/business-startup/process.php';
}
//-->
