function $(id)
{
	return document.getElementById(id);
}
function collapse_onclick(index, flag, count)
{
	var obj = $('collapse' + index), img = $('collapse_img' + index);
	if (obj == null || img == null) return false;
	try
	{
		var text1 = '顯示全部', text2 = '隱藏';
		if ((flag == 1 || flag == 2) && count != null && (isNaN(count) || parseInt(count) <= 0)) flag = 0;
		if (flag == 1 || flag == 2)
		{
			var i = 0;
			if (count == null) count = obj.children.length;
			for (; i < count && i < obj.children.length; obj.children[i++].style.display = '');
			for (; i < obj.children.length; obj.children[i++].style.display = 'none');
			obj.style.display = '';
			flag = (flag == 2) ? 0 : 2;
			var b = (count < obj.children.length && flag == 2);
			if (count == obj.children.length) flag = 0;
			img.onclick = function () {collapse_onclick(index, flag);};
			img.title = (b) ? text1 : text2;
			img.src = '../images/icon/' + ((b) ? 'arrow_down.gif' : 'arrow_up.gif');
		}
		else
		{
			obj.style.display = (obj.style.display == 'none') ? '' : 'none';
			var b = obj.style.display == 'none';
			img.onclick = function () {collapse_onclick(index, 0);};
			img.title = (b) ? text1 : text2;
			img.src = '../images/icon/' + ((b) ? 'arrow_down.gif' : 'arrow_up.gif');
		}
		return true;
	}
	catch (e)
	{
		obj.style.display = '';
		img.style.display = '';
		img.onclick = function() {collapse_onclick(index, 0);};
		img.title = '收合';
		img.src = '../images/icon/arrow_up.gif';
		return false;
	}
}


