function ExpandAll() {
	$$('.Categories_Admin').setStyle('display', '');
	$('ExpandCollapse').set('html', '<a href="#" onClick="CollapseAll(); return false;">Collapse All Categories</a>');
}

function CollapseAll() {
	$$('.Categories_Admin').setStyle('display', 'none');
	$('Categories_Admin_Parent_0').setStyle('display', '');
	$('ExpandCollapse').set('html', '<a href="#" onClick="ExpandAll(); return false;">Expand All Categories</a>');
}

function DeleteConfirmation(varURL, varText) {
	var conf = confirm('Are you sure you wish to permanently delete this ' + varText + '?');
	
	if (conf) {
		location.replace(varURL);
	}
}

function MultiSelect(select, varElementName) {
	var option = select.options[select.selectedIndex];
	var ul = document.getElementById(varElementName + 'UL');
	
	if (!ul) {
		ul = document.createElement("ul");
		ul.id = varElementName + 'UL';
		ul.setAttribute('class', 'options');
		select.parentNode.insertBefore(ul, select.nextSibling);
	}
	
	var choices = ul.getElementsByTagName('input');
	for (var i = 0; i < choices.length; i++) {
		if (choices[i].value == option.value) {
			return;
		}
	}
	
	var li = document.createElement('li');
	var input = document.createElement('input');
	var text = document.createTextNode(option.firstChild.data);
	
	input.type = 'hidden';
	input.name = varElementName + '[]';
	input.value = option.value;
	input.setAttribute('class', 'hidden_field novalidate');
	
	li.appendChild(input);
	li.appendChild(text);
	li.setAttribute('onclick', 'this.parentNode.removeChild(this);');
	
	ul.appendChild(li);
	
	select.selectedIndex = 0;
}
