function centre_in_window() {
  var width = (getDocumentWidth() - getWindowWidth()) / 2;
  var height = (getDocumentHeight() - getWindowHeight()) / 2;

  window.scrollTo(width, height);
}

function getWindowWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }

  return myWidth;
}

function getWindowHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }

  return myHeight;
}

function getDocumentWidth() {
var x;
var test1 = document.body.scrollHeight;
var test2 = document.body.offsetHeight
if (test1 > test2) // all but Explorer Mac
{
	x = document.body.scrollWidth;
}
else // Explorer Mac;
     //would also work in Explorer 6 Strict, Mozilla and Safari
{
	x = document.body.offsetWidth;
}

  return x ;
}

function getDocumentHeight() {
var y;
var test1 = document.body.scrollHeight;
var test2 = document.body.offsetHeight
if (test1 > test2) // all but Explorer Mac
{
	y = document.body.scrollHeight;
}
else // Explorer Mac;
     //would also work in Explorer 6 Strict, Mozilla and Safari
{
	y = document.body.offsetHeight;
}
return y;
}

function validEmail(strObj)
{
	var reg = new RegExp("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"); 
	return (reg.test(eval(strObj+".value")));
}

function validateCandNewUser(strEmail, strPass, strRePass)
{
	if(! validEmail(strEmail))
	{
		alert("Please enter a valid e-mail address");
		eval(strEmail+".focus()");
		return false;
	}
	
	if(eval(strPass+".value") != eval(strRePass+".value"))
	{
		alert("Passwords do not match, please check and try again.");
		eval(strPass+".focus()");
		return false;
	}
	if (eval(strPass+".value.length")<6)
	{
		alert("Password is not at least six characters long, please check and try again.");
		eval(strPass+".focus()");
		return false;
	}

}

function validateCandModifyUser(strEmail, strPass)
{
	if(! validEmail(strEmail))
	{
		alert("Please enter a valid e-mail address");
		eval(strEmail+".focus()");
		return false;
	}
	
	if (eval(strPass+".value.length")<6)
	{
		alert("Password is not at least six characters long, please check and try again.");
		eval(strPass+".focus()");
		return false;
	}
}

function ValidatePersonalDetails(formname)
{
	if (formname.FirstName.value.length<=0)
	{
		alert("Please enter your first name.");
		formname.FirstName.focus();
		return false;
	}
	if (formname.LastName.value.length<=0)
	{
		alert("Please enter your last name.");
		formname.LastName.focus();
		return false;
	}
/*
	if (formname.DOB.value.length<=0)
	{
		alert("Please enter your date of birth.");
		formname.DOB.focus();
		return false;
	}
*/
	if (formname.Address.value.length<=0)
	{
		alert("Please enter your addreses.");
		formname.Address.focus();
		return false;
	}
	if (formname.Town.value.length<=0)
	{
		alert("Please enter your town.");
		formname.Town.focus();
		return false;
	}
	if (formname.County.value.length<=0)
	{
		alert("Please enter your county.");
		formname.County.focus();
		return false;
	}
	if (formname.Postcode.value.length<=0)
	{
		alert("Please enter your postcode.");
		formname.Postcode.focus();
		return false;
	}
	if (formname.Tel.value.length<=0)
	{
		alert("Please enter your telephone number.");
		formname.Tel.focus();
		return false;
	}
	if (formname.Mobile.value.length<=0)
	{
		alert("Please enter your mobile number.");
		formname.Mobile.focus();
		return false;
	}
	if(! validEmail('FormCandidateLogin.Email'))
	{
		alert("Please enter a valid e-mail address");
		formname.Email.focus();
		return false;
	}
}

function ie5macpos()
{
	var appname = navigator.appName;
	var appversion = navigator.appVersion;
	var divwidth=0;
	var divheight=0;

	if(!(appversion.indexOf("Windows") != -1))
	{//if not windows
		if(appname.indexOf("Microsoft") != -1)
		{//but we are IE

			//get the width of the window
			if (document.compatMode && document.compatMode != "BackCompat")
			{
				theWidth = document.documentElement.clientWidth;
			}
			else
			{
				theWidth = document.body.clientWidth;
			}

			//width of the movie
			var moviewidth = 950;
			//find out how much we want to move the window by
			divwidth = (((theWidth-900)/2)>0)?((theWidth-moviewidth)/2):0;
			divheight = 200;
		}
	}
	window.document.getElementById("MacIE").style.width = divwidth+'px';
	window.document.getElementById("MacIE").style.height = divheight+'px';
	
	//show the page now
	window.document.getElementById("Container").style.display = 'block';
}