function toggleCheckAll()
{
	var form = document.forms[0];
	var bool = ($('checkAll').checked) ? true : false;
	for (var i=0; i<form.elements.length; i++)
	{
		if (form.elements[i].type == 'checkbox')
		{
			form.elements[i].checked = bool;
		}
	}
}

function getCheckedCount(form)
{
	form = $(form);
	var count = 0;
	for (var i=0; i<form.elements.length; i++)
	{
		if (form.elements[i].type == 'checkbox' && form.elements[i].checked)
		{
			if (form.elements[i].name != 'checkAll') count++;
		}
	}
	return count;
}

function submitSelected(term, form, obj, type)
{
	if (obj.disabled) return;
	var count = 1;
	if (type != 'single')
	{
		count = getCheckedCount(form);
		if (count == 0)
		{
			alert('You have no items selected.');
			return;
		}
	}
	if (confirm('Are you sure you want to ' + term + ' ' + ((count == 1) ? 'this' : 'these') + '?'))
	{
		obj.disabled = true;
		$(form).process.value = term;
		$(form).submit();
	}
}

function submitShoppingCart(id)
{
	if ($(id).disabled) return;
	toggleById(id);
	$('shoppingCartForm').submit();
}

function getURL(obj, url)
{
	if (obj.disabled) return;
	toggleByObj(obj);
	window.location = url;
}

function toggleByObj(obj)
{
	if (!obj.disabled)
	{
		obj.disabled = true;
	}
	else
	{
		obj.disabled = false;
	}
}

function toggleById(id)
{
	var obj = $(id);
	toggleByObj(obj);
}