var xmlhttp;


function initialise()
{
	xmlhttp=GetXmlHttpObject();
	
	//Event handlers
	window.onresize = recalcframe;
	document.getElementById("picture").onload = recalcframe;
	recalcframe();
}

function do_preload(image_list)
{
	for (i=0, len = image_list.length; i < len; ++i)
	{
		preload_image = new Image();
		preload_image.src = image_list[i];
	}
}


function recalcframe()
{
	thetop = getobjtop(document.getElementById("picture"));
	height = document.getElementById("picture").offsetHeight;
	bottom = thetop + height;
	left = getobjleft(document.getElementById("picture"));
	width = document.getElementById("picture").offsetWidth;
	right = left + width - 1;

	document.getElementById("tr").style.left = right + "px";
	document.getElementById("tr").style.top = thetop + "px";

	temp = height - 50;
	if (temp < 0) { temp = 0; }
	document.getElementById("mr").style.left = right + "px";
	document.getElementById("mr").style.top = thetop + 50 + "px";
	document.getElementById("mr").style.height = temp + "px";

	document.getElementById("bl").style.left = left + "px";
	document.getElementById("bl").style.top = bottom + "px";
	
	temp = width - 51;
	if (temp < 0) { temp = 0; }
	document.getElementById("bm").style.left = left + 50 + "px";
	document.getElementById("bm").style.top = bottom + "px";
	document.getElementById("bm").style.width = temp + "px";

	document.getElementById("br").style.left = right + "px";
	document.getElementById("br").style.top = bottom + "px";
	
	
	
}

function getobjleft(obj)
{
	left = 0;
	while (obj)
	{
		left += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	return left;
}


function getobjtop(obj)
{
	thetop = 0;
	while (obj)
	{
		thetop += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return thetop;
}



function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}


