﻿
var _collapseObj = null;
var speed = 5;
var incriment = 5;
var iTimer;


function toggleCBlock(obj)
{
	//find content block
	obj = obj.parentNode.parentNode;

	if (!obj || obj.className.indexOf("cbox") < 0)
		return;

	if (!obj)
		return;

	var obj2 = null;

	for (var i = 0; i < obj.childNodes.length; i++)
	{
		if (obj.childNodes[i].className == "cb_cont")
		{
			obj2 = obj.childNodes[i];
			break;
		}
	}

	if (!obj2)
		return;

	if (obj2.style.display != "block")
	{
		//show
		obj2.style.display = "block";
	}
	else
	{
		//hide
		_collapseObj = obj2;
		collapse();
//		obj2.style.height = "100%";
//		obj2.style.display = "none";
	}
}

function collapse()
{
	var help = _collapseObj;
	
	if (!help)
	{
		clearTimeout(iTimer);
		return;
	}
	
	var height = help.offsetHeight;
	if (height > incriment)
	{
		help.style.height = height - incriment + "px";
		iTimer = setTimeout("collapse()", speed);
	}
	else
	{
		clearTimeout(iTimer);
		help.style.height = "100%";
		help.style.display = "none";
		_collapseObj = null;
	}
}	