function tideheight() {

	var i    = 0;
	var bst  = 0;
	var now  = new Date();
	var nowh = now.getUTCHours();
	var nowm = now.getUTCMinutes();
	var nows = now.getUTCSeconds();

	//re-base time and correct for BST
	var secs = nowh*3600+nowm*60+nows+86400+bst;

	//perform a reload at midnight plus two minutes
	//to get the new tidal information
	var reload = (86400*2)-secs+120;
	defaultStatus= "This page will refresh in "+reload+" seconds. Tidal heights cannot be guaranteed - please refer to HM Admiralty Charts";
	if (reload <0) {location.reload() };

	while (secs > tidet[i]) { i++ }

	var time_factor   = (secs - tidet[i-1])/(tidet[i]-tidet[i-1]);
	var phase_factor  = Math.cos(2*Math.PI*time_factor);
	var height_change = (tideh[i]-tideh[i-1])*time_factor;
	var tide_uncorr   = (tideh[i-1]-2.757)*phase_factor + height_change;
	var tide          = tide_uncorr + 2.757;

	//display computed tide in textbox, 2dp only
	var minitide = Math.round(tide*100)/100;
	var message = " "+minitide+"m";
	window.document.tideform.the_tide.value = message;
	//display the time in textbox
	if (bst) { nowh = (nowh+1)%24};
	if (nowh <10) {nowh = "0"+nowh};
	if (nowm <10) {nowm = "0"+nowm};
	var nowd = " "+nowh+":"+nowm;
	window.document.timeform.the_time.value = nowd;

	var to = setTimeout('tideheight();',1000);

}

var tidet = new Array(4);
tidet[0] = 49200;
tidet[1] = 94800;
tidet[2] = 140400;
tidet[3] = 184800;

var tideh = new Array(4)
tideh[0] = 3.73;
tideh[1] = 3.94;
tideh[2] = 3.91;
tideh[3] = 4.20;

tideheight();

