function smoothmove(obj_id, distance, time, power, bool_updown_leftright) {
	this.complete = false;
	
	if (!smoothmove.Instances) {
		smoothmove.Instances = new Array();
	}
	this.id = smoothmove.Instances.length;
	smoothmove.Instances[this.id] = this;
	
	this.timeoutamount = 20;
	this.t = document.getElementById(obj_id);
	this.bool_updown_leftright = bool_updown_leftright;
	
	this.power = power;
	this.root = Math.pow(Math.abs(distance), 1/power);
	this.currprogress = this.root;
	this.rootchange = this.root * (this.timeoutamount/(time*1000));
	this.distance = distance;
	this.final_toporleft = get_first_numeric_string(bool_updown_leftright ? this.t.style.top : this.t.style.left)*1 + distance;
	
	this.i = window.setInterval("smoothmove.Instances["+this.id+"].incmove();", this.timeoutamount);
}
smoothmove.prototype.incmove = function() {
	this.currprogress = this.currprogress - this.rootchange;
	if (this.currprogress < 0) {
		this.currprogress = 0;
		window.clearInterval(this.i);
		this.complete = true;
	}
	toporleft_offset = Math.pow(this.currprogress, this.power);
	finalpos = (((this.distance > 0) ? (this.final_toporleft - toporleft_offset) : (this.final_toporleft + toporleft_offset))*1) + "px";
	this.bool_updown_leftright ? this.t.style.top = finalpos : this.t.style.left = finalpos;
}
smoothmove.prototype.stop = function() {
	clearInterval(this.i);
}




var mintop = [];
mintop["small"] = 291;
mintop["med"] = 362;
mintop["lar"] = 453; //where the top of the link graphic is - it doesn't correspond to an html element edge
var toppadding = [];
toppadding["small"] = 70;
toppadding["med"] = 95;
toppadding["lar"] = 120; //how much screen padding you want to see. again it doesn't correspond to an html element edge

var scrollobj;
var currscrollY;

function scrollcheck() {
	var scrollY = getScrollXY()[1];
	if (scrollY != currscrollY) {
		currscrollY = scrollY;
		var newtop = Math.max(0, (scrollY - mintop[size]) + toppadding[size]); //measures only against the current scrollY. When the screen's top edge is toppadding[size] pixels above mintop[size], the 0 barrier is crossed. So the 'top' of links is in effect maintained exactly mintop[size] below the top edge of screen.
		var distance = newtop - get_first_numeric_string(document.getElementById("links").style.top);
		if (scrollobj) scrollobj.stop();
		scrollobj = new smoothmove("links", distance, 1, 3, true);
	}
}

setInterval("scrollcheck();", 100);







el_links = document.getElementById("links");
links_height = el_links.offsetHeight;
el_brush = document.getElementById("brush");
el_brushimg = document.getElementById("brushimg");
el_brush.style.left = "-300px";
var brushscrollobj = new smoothmove("brush", 1, 1, 1);
var curr_finalX;

var brushimgheight = null;
var wrapper1 = document.getElementById("wrapper1");
wrapper1top = {};
wrapper1top["small"] = 250;
wrapper1top["med"] = 313;
wrapper1top["lar"] = 391; //created to get full height of page for brush resizing (to stop it pushing page boundary). Should be same as wrapper1.style.top and add to wrapper1.offsetHeight to give complete page height, but for some reason brush was cut off slightly above page bottom. Trial and error used to get right figure.
if (get_browser_name() != "MSIE") { for (var k in wrapper1top) { wrapper1top[k] += 1; } }

var bool_brushonoff;

links_offsettop = [];
links_offsettop["small"] = 238;
links_offsettop["med"] = 297;
links_offsettop["lar"] = 370; //the top edge of wrapper1, where links is positioned at the start (it has padding, to position the actual links)

brush_mouseleft = [];
brush_mouseleft["small"] = 181;
brush_mouseleft["med"] = 226;
brush_mouseleft["lar"] = 283;
brush_mousetop = [];
brush_mousetop["small"] = 13;
brush_mousetop["med"] = 17;
brush_mousetop["lar"] = 21; //just the coordinates within the actual brush image of the tip to use as 'cursor'

links_max_brushdragright = [];
links_max_brushdragright["small"] = 191;
links_max_brushdragright["med"] = 238;
links_max_brushdragright["lar"] = 239;
curr_roofX = 1000; //used so brush exits sensibly, without first following mouse over to right. It can enter far over on links panel, but once user has moved left it can't go back past this point.

var currentlyhoveringlinknumber = null;

var arr_linkelements = [];
for (var i = 1; i <= 7; i++) {
	arr_linkelements[i] = document.getElementById("l" + i);
}

function brushcheck() {
	links_top = get_first_numeric_string(el_links.style.top)*1 + links_offsettop[size];
	if ((mouseX < document.getElementById("links").offsetWidth) && (mouseY > links_top) && (mouseY < (links_height + links_top))) {
		if (!bool_brushonoff) {
			if (brushscrollobj) brushscrollobj.stop();
			bool_brushonoff = true;
			brushscrollobj = new smoothmove("brush", mouseX - get_first_numeric_string(el_brush.style.left) - brush_mouseleft[size], 0.3, 0.5);
		} else {
			if (el_brushimg.complete) { //do nothing if image still loading
				if (get_browser_name() == "MSIE") document.documentElement.style.cursor = "url(blank.cur)"
				else document.body.style.cursor = "none";
				if (brushscrollobj.complete) {
					if (mouseX > curr_roofX) {
						mouseX = curr_roofX;
					} else {					
						curr_roofX = Math.max(mouseX, links_max_brushdragright[size]);
					}
					el_brush.style.left = Math.min(curr_roofX, (mouseX - brush_mouseleft[size])) + "px";
				} else {
					brushscrollobj.final_toporleft = mouseX - brush_mouseleft[size];
					curr_roofX = Math.max(mouseX, links_max_brushdragright[size]);
				}
			}
		}
		var linksleft = arr_linkelements[1].offsetLeft;
		var linkswidth = arr_linkelements[1].offsetWidth;
		var linkareatop = get_first_numeric_string(el_links.style.top) * 1 + links_offsettop[size] * 1;
		var linkheight = arr_linkelements[1].offsetHeight;
		var foundhoverlinknumber = null;
		if ((mouseX >= linksleft) && (mouseX < (linksleft + linkswidth))) {
			for (var i = 1; i <= (arr_linkelements.length - 1); i++) { //length - 1 because it's numbered from 1, but js arrays always start at 0
				var thislinktop = linkareatop + arr_linkelements[i].offsetTop;
				if ((mouseY >= thislinktop) && (mouseY < (thislinktop + linkheight))) {
					foundhoverlinknumber = i;
					break;
				}
			}
		}
		if (currentlyhoveringlinknumber && (foundhoverlinknumber ? (foundhoverlinknumber != currentlyhoveringlinknumber) : true)) {
			JSFX.fadeOut("link" + currentlyhoveringlinknumber);
			currentlyhoveringlinknumber = null;
		}
		if (foundhoverlinknumber && (foundhoverlinknumber != currentlyhoveringlinknumber)) {
			JSFX.fadeIn("link" + foundhoverlinknumber);
			currentlyhoveringlinknumber = foundhoverlinknumber;
		}
	} else {
		if (get_browser_name() == "MSIE") document.documentElement.style.cursor = "default"
		else document.body.style.cursor = "default";
		if (bool_brushonoff) {
			if (brushscrollobj) brushscrollobj.stop();
			bool_brushonoff = false;
			brushscrollobj = new smoothmove("brush", 0 - el_brush.offsetWidth - get_first_numeric_string(el_brush.style.left), 0.3, 2); //move brush out
		} else {
			if (brushscrollobj.complete) {
				el_brush.style.left = (-el_brush.offsetWidth) + "px";
			}
		}
		if (currentlyhoveringlinknumber) {
			JSFX.fadeOut('link' + currentlyhoveringlinknumber);
			currentlyhoveringlinknumber = null;
		}
	}
	el_brush.style.top = (mouseY - brush_mousetop[size]) + "px";
	if (!brushimgheight) {
		if (el_brushimg.complete) brushimgheight = el_brushimg.offsetHeight;
	} else {
		el_brush.style.height = Math.max(0, (wrapper1.offsetHeight + wrapper1top[size]) - mouseY).toString() + "px";
	}
}

setInterval("brushcheck();", 50);


registerEventHandler(el_brush, 'click', function(event) {
	if (currentlyhoveringlinknumber) {
		self.location = document.getElementById("l" + currentlyhoveringlinknumber).children[0].href;
	}
});
