//Dynamic relative positioning.

function imgRelpos(anchorid, targetdiv, xoffset, yoffset, imgpath, usemap)
{
		 
	this.anchor = document.getElementById(anchorid);
	this.target = document.getElementById(targetdiv);
	this.targimg = document.createElement('img');
	this.map = '#' + usemap;
	if (this.map != '')
	{
		this.targimg.useMap = this.map;		
	}
	
	this.targimg.setAttribute('src', imgpath);
	this.targimg.onclick = function () {document.getElementById('currentcourses').style.visibility = 'visible';} 
//	this.targimg.addEventListener('click',function () {document.getElementById('currentcourses').style.visibility = 'visible'},false)

	this.anchor.coords = irpos_getposition(this.anchor);
//	var coords = new Array(this.anchor.coords.split(","));
//	coords.xandy = coords[0];
//	var x = coords.xandy[0];
//	var y = coords.xandy[1];
	var x = this.anchor.coords[0];
	var y = this.anchor.coords[1];
	x = parseInt(parseInt(x) + xoffset);
	y = parseInt(parseInt(y) + yoffset);
	x = (x + 'px');
	y = (y + 'px');
	if (targetdiv == 0)
	{
		document.body.appendChild(this.targimg);
		this.targimg.style.position="absolute";
		this.targimg.style.top=y;;
		this.targimg.style.left=x;	
	}
	else
	{
		this.target.appendChild(this.targimg);
		this.target.style.position="absolute";
		this.target.style.top=y;;
		this.target.style.left=x;
	}
	
}

//------------------------------------------------------------------------------
// Gets the x and y positions of the anchor object so we can then then use CSS 
// to position the target relative to the anchor. This means screen resolution
// and browser incompatabilities shouldn't have any effect.

function irpos_getposition(image)
{
	var postop = 0;
	var posleft = 0;
	if (image.offsetParent) 
	{
		do 
		{
			posleft += image.offsetLeft;
			postop += image.offsetTop;
		} while (image = image.offsetParent);
	}
	return [posleft,postop];
}



