function insertSpans(parentid)
{
	var parent = document.getElementById(parentid);
	var containers = parent.getElementsByTagName('div');
	var container = containers[0];
	if(!container) return;
	
	var lasty = 0;
	var lastheight = 0;
	var containerPos = findPos(container);
	
	containerChild = container.childNodes[0];
	
	var repetitions = 0;
	
	//stop if the next line would increase the height
	while((lasty + lastheight < containerPos + container.offsetHeight) && repetitions < 10 )
	{
		var spacer = document.createElement('span');
		spacer.className = 'curveSpacer';
		container.insertBefore(spacer, containerChild);
		lasty = findPos(spacer);
		var width = getWidth(lasty);
		if(width == -1)
		{
			spacer.style.width = 0;
			return;
		}
		else
		{
			spacer.style.width = width + 'px';
			lastheight = spacer.offsetHeight;
		}
		repetitions++;
	}
}

function findPos(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop;
		}
	}	
	return curtop;
}

function getWidth(pos)
{
	maxwidth = 200;
	
	//width = Math.log(pos-200) * 20
	//width = 300 - (Math.pow(pos/23, 2));
	//width = 100 + Math.cos((pos-150)/100) * 100;
	//width = 400 - (Math.log(pos-170) * 70);
	width = Math.cos((pos-205)/60) * 105;
	
	if(width > maxwidth)
		return maxwidth;
	if(width <= 0)
		return -1; 
		//in this case we want to stop when width gets to 0
		// but might want another ending criteron, like the value of pos
	
	return width;
}