function checkall() {
	var r = 0;
	for (var i=0;i<document.msgfrm.elements.length;i++)
	{
		var e = document.msgfrm.elements[i];
		if (e.name != 'allmsg' && e.name != 'msgids[]' && e.name != 'flids[]' && e.name != 'isnew' && e.name != 'btnsubmit' &&
			e.name != 'delete' && e.name != 'restore' && e.name != 'del' &&
			e.name != 'ac' && e.name != 'fldid' && e.name != 'mrkact')
		{
			e.checked = document.msgfrm.allmsg.checked;
			checkone(e,r,e.checked);
			r++;
		}
	}
}

function checkone(el,id,state) {
	if (el.checked) document.getElementById('tr'+id).className = 'green5';
	else document.getElementById('tr'+id).className = document.getElementById('isnew'+id).value;
	document.msgfrm.allmsg.checked = state;
}

function trashmsgs()
{
	if (confirm("Are you sure you want to delete selected messages?"))
	{
		document.msgfrm.ac.value="tra"
		document.msgfrm.submit();
	}
}

function trashmsg()
{
	if (confirm("Are you sure you want to delete this message?"))
	{
		document.msgfrm.ac.value="trashmsg"
		document.msgfrm.submit();
	}
}

function movemsgs(fld)
{
	if (confirm("Move messages?"))
	{
		document.msgfrm.fldid.value=fld;
		document.msgfrm.ac.value="mov";
		document.msgfrm.submit();
	}
}

function markmsgs(markact)
{
	document.msgfrm.mrkact.value=markact;
	document.msgfrm.ac.value="mrk";
	document.msgfrm.submit();
}

function sortby(sbyact)
{
	document.msgfrm.sortact.value=sbyact;
	document.msgfrm.ac.value="sby";
	document.msgfrm.submit();
}

function deletemsgs()
{
	if (confirm("Message(s) will be permanently deleted!\r\nProceed?"))
	{
		document.msgfrm.ac.value = "tra";
		document.msgfrm.del.value = 1;
		document.msgfrm.submit();
	}
}

function restoremsgs()
{
	document.msgfrm.ac.value = "tra";
	document.msgfrm.del.value = 0;
	document.msgfrm.submit();
}

function trashflirts()
{
	if (confirm("Are you sure you want to delete selected flirts?"))
	{
		document.msgfrm.ac.value = "tra";
		document.msgfrm.del.value = 1;
		document.msgfrm.submit();
	}
}