function previewPosts( id, CMPage_id )
{
	previewModuleItem("CoalSpeak.inlinePostDisplay&SpeakPost_id=","coalspeak",id);
}

function editPosts( id, CMPage_id )
{
	closePopovers();
	editModuleItem("CoalSpeak.editPost&SpeakPost_id=","coalspeak",id,CMPage_id);
}

function confirmDelete( deleteUrl )
{
	shouldDelete = confirm("Are you sure you want to delete this post?");
	if (shouldDelete != false)
	{
		top.location = deleteUrl;
	}
}

function uncheckBatchFields(actions, rowId)
{
	for (i=0;i<actions.length;i++)
	{
		document.getElementById("SpeakPost_"+actions[i]+"_ids["+rowId+"]batchForm").checked=false;
	}
}
function handleSpeakBatchClick(callingField, action, rowId)
{
	switch(action)
	{
		case "add":
			uncheckBatchFields(new Array("remove","removeAll","delete"),rowId);
			break;
		case "remove":
			uncheckBatchFields(new Array("add","removeAll","delete"),rowId);
			break;
		case "removeAll":
			uncheckBatchFields(new Array("remove","add","delete"),rowId);
			break;
		case "delete":
			uncheckBatchFields(new Array("remove","removeAll","add","touch"),rowId);
			break;
		case "touch":
			uncheckBatchFields(new Array("delete"),rowId);
			break;
		case "active":
			break;
	}
}

function SpeakBatchConfirm(theForm)
{
	var skipConfirm = true;
	for (e=0;e<theForm.length;e++)
	{
		if( theForm[e].type.toLowerCase() == "checkbox"
			&& theForm[e].name.indexOf("SpeakPost_delete_ids") > -1
			&& theForm[e].checked != false )
		{
			skipConfirm = false;
		}
	}

	return (skipConfirm || window.confirm("At least one post has been marked for permanant deletion.  Proceed?"));

}