// johnny cison
// www.toomuchstupid.com
// if you're swiping the code, please leave my name in it.

function topic_edit(t) { document.location='/edit/?t='+t; }
function topic_sort(t, d) { if (confirm('Are you sure you want to move this topic?')) { req_send('/req/topic_sort.php?t='+t+'&d='+d); } }
function topic_delete(t) { if (confirm('Are you sure you want to delete this topic?')) { req_send('/req/topic_delete.php?t='+t); } }
function topic_history(t) { document.location='/history/?t='+t; }
function topic_report(t) { document.location='/report/?t='+t; }
function topic_new(s) { document.location='/new/?s='+s; }

function edit_ping(t) { req_send('/edit/req/ping.php?t='+t.toString()); }
function image_pick()
{
	var tmsinsertwin=window.open('/edit/image/', 'TMSInsertWin', 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no,width=500,height=400');
	tmsinsertwin.moveTo((screen.width-500)/2, ((screen.height-400)/2)-30); tmsinsertwin.focus();
}
function image_insert(code)
{
	insertatcursor(self.opener.document.getElementById('fi_text'), code);
	self.close();
}
function insertatcursor(field, code)
{
	// based on a script found at alexking.org/projects/js-quicktags
	if (document.selection) { field.focus(); sel=self.opener.document.selection.createRange(); sel.text=code; }
	else if (field.selectionStart || field.selectionStart == '0')
	{
		var startpos=field.selectionStart, endpos=field.selectionEnd;
		field.value=field.value.substring(0,startpos)+code+field.value.substring(endpos, field.value.length);
	}
	else { field.value += code; }
}
