function COutline_onClick()
{
	if (this.outlineContents.style.display == "none")
	{
		// Open the closed item 
		COutline_OpenItem(this);
		
		// Close any open items
		// Let's skip this part - JMH
/*		if (this.group != null)
		{
			var group = groups[this.group];
			if (group.COutline_openEl != null)
			{
				if (group.COutline_openEl!=this)
				{
					COutline_CloseItem(group.COutline_openEl);
				}
			}
			
			group.COutline_openEl = this;
		}
*/
	}
	else
	{
		// Close the open item
		COutline_CloseItem(this);
	}
}

function COutline_OpenItem(el)
{
		el.outlineContents.style.display = "block";
		if (el.img)
		{
			el.img.src=el.img.opensrc;
		}
}

function COutline_CloseItem(el)
{
		el.outlineContents.style.display = "none";
		if (el.img)
		{
			el.img.src=el.img.closedsrc;
		}
}

function COutline(el)
{
	el.onclick=COutline_onClick;
	if (this.count==null)
	{
		this.count=0;
	}
	else
	{
		this.count++;
	}

	th=document.all("outlineContents", this.count);
	if (!th)
	{
		alert("Can't find element to hide - number " + this.count);
		return;
	}
	
	el.outlineContents=th;
	
	el.img=null;
	
	var im=el.all("img",0);
	if (im)
	{
		if (im.opensrc)
		{
			im.closedsrc=im.src;
			el.img=im;
		}
	}
		
	if (el.outlineContents.style.display=="")
	{
		COutline_CloseItem(el);
		return;
	}

	// Ensure only one item in a group is open
	if (el.group == null)
	{
		return;
	}
	
	if (el.outlineContents.style.display!="block")
	{
		return;
	}

	// assume display == "block" 
	group = groups[el.group];
	if (group.COutline_openEl == null)
	{
		group.COutline_openEl = el;
		COutline_OpenItem(el);
	}
	else
	{
		COutline_CloseItem(el);
	}
}

bindings.outline=new CBinding(COutline);
