var groupName;

/**
* This is a modified version of toggle_collapse() to collapse a group of things
*
* @param	string	The name attribute to be collapsed
*
* @return	boolean	false
*/
function toggleMultiCollapse(groupName) {
	if (!is_regexp) {
		return false;
	}

	// thanks a bunch for deprecating the name attribute, XHTML
	var group = document.getElementsByTagName('table');
	var regExp = new RegExp('^' + groupName + '\\d+$');
	var i = 0;

	while (group[i]) {
		if (!regExp.test(group[i].id)) {
			i++;
			continue;
		}
		obj = fetch_object('collapseobj_' + group[i].id);
		img = fetch_object('collapseimg_' + group[i].id);
		cel = fetch_object('collapsecel_' + group[i].id);

		if (!obj) {
			// nothing to collapse!
			if (img) {
				// hide the clicky image if there is one
				img.style.display = 'none';
			}
		}

		if (obj.style.display == 'none') {
			obj.style.display = '';
			save_collapsed(groupName, false);

			if (img) {
				img_re = new RegExp("_collapsed\\.gif$");
				img.src = img.src.replace(img_re, '.gif');
			}
			if (cel) {
				cel_re = new RegExp("^(thead|tcat)(_collapsed)$");
				cel.className = cel.className.replace(cel_re, '$1');
			}
		}
		else {
			obj.style.display = 'none';
			save_collapsed(groupName, true);

			if (img) {
				img_re = new RegExp("\\.gif$");
				img.src = img.src.replace(img_re, '_collapsed.gif');
			}
			if (cel) {
				cel_re = new RegExp("^(thead|tcat)$");
				cel.className = cel.className.replace(cel_re, '$1_collapsed');
			}
		}

		i++;
	}
}
