
function isIE()
{
	var ua = navigator.userAgent.toLowerCase();
	if (ua.indexOf("msie") != -1) return true;
	return false;
}

function toggle(id, expand, contract)
{
	var div = document.getElementById(id + '_div');
	var a = document.getElementById(id + '_a');
	if (div && a)
	{
		if (div.style.display == 'none')
		{
			div.style.display = 'inline';
			a.innerHTML = contract;
		}
		else
		{
			div.style.display = 'none';
			a.innerHTML = expand;
		}
	}
}

function setDeleteButton(id)
{
	sel = document.getElementById(id + '_selector');
	con = document.getElementById(id + '_a');

	if (sel && con && sel.selectedIndex != -1)
	{
		var style = sel.options[sel.selectedIndex].style;
		if (style.textDecoration && style.textDecoration == 'line-through')
			con.innerHTML = 'Undelete';
		else
			con.innerHTML = 'Delete';
	}
}

function toggleDelete(id)
{
	sel = document.getElementById(id + '_selector');
	con = document.getElementById(id + '_a');

	var deltext = "(DELETE) ";

	if (sel && con && sel.selectedIndex != -1)
	{
		var option = sel.options[sel.selectedIndex];
		var style = option.style;
		var hiddenname = id + '-delete-' + option.value;
		var hidden = document.getElementById(hiddenname);

		if (!hidden) return;

		if (!style.textDecoration || style.textDecoration == 'none')
		{
			style.textDecoration = 'line-through';
			if (isIE()) option.text = deltext + option.text;
			hidden.value = 'yes';
			setDeleteButton(id);
		}
		else
		{
			style.textDecoration = 'none';
			if (isIE()) option.text = option.text.substring(deltext.length);
			hidden.value = 'no';
			setDeleteButton(id);
		}
	}
}


