var canvasDiv   = "flashcontent";
var containerW  = 800;
var containerH	= 600;

// get the page height and width of the canvas, in object form
function getCanvas()
{
	// get the canvas width
	if (document.width) this.w = document.width;
	else if (document.documentElement && document.documentElement.clientWidth) this.w = document.documentElement.clientWidth;
	else if (document.body && document.body.clientWidth) this.w = document.body.clientWidth;
	else if (window.innerWidth) this.w = window.innerWidth;
	else this.w = 0;
	// get the canvas height
	if (document.height) this.h = document.height;
	else if (document.documentElement && document.documentElement.clientHeight) this.h = document.documentElement.clientHeight;
	else if (document.body && document.body.clientHeight) this.h = document.body.clientHeight;
	else if (window.innerHeight) this.h = window.innerHeight;
	else this.h = 0;
	// return canvas object
	return this;
}

//function to let you centre the main content div
function setCanvas()
{
	// get the canvas width and height
	canvas = new getCanvas();
	// calculate the centering information
	var canvasLeft = (canvas.w - containerW) / 2;
	var canvasTop  = ((canvas.h - containerH) / 2) -10;
	// check offset valid
	if (canvasLeft < 0) canvasLeft = 0;
	if (canvasTop < 0) canvasTop = 0;
	// move the div
	myFind(canvasDiv).style.left = canvasLeft + "px";
	myFind(canvasDiv).style.top = canvasTop + "px";
	// resize the div
	myFind(canvasDiv).style.width = containerW + "px";
	myFind(canvasDiv).style.height = containerH + "px";
}

// function to centre and setup the div in the centre of the page
function redrawCanvas()
{
	// Position the canvas div
	setCanvas();
	window.onresize = setCanvas;
}

// function to find a page element
function myFind(id, frame, d)
{
	// try to find the relative element
	var img = null;
	if (!d) {
		if (frame && top[frame]) d = top[frame].document;
		else d = document;
		if (!d) return null;
	}
	if (d.layers) {
		img = d.layers[id];
		if(!img) img = d.links[id];
		if(!img) img = d.images[id];
	}
	else if (d.getElementById) img = d.getElementById(id);
	// loop through child elements
	for (var i=0; !img && d.layers && i<d.layers.length; i++){
		img = myFind(id, null, d.layers[i].document);
	}
	return img;
}