// JavaScript Document

function reportPost(index, table) {
	if (confirm('Are you sure you want to report this post as inappropriate?')) {
		new Ajax.Request(dirLevel+'includes/reportPost.php', {
			method: 'post',
			parameters: {
				table: table,
				index: index,
				cid: communityID,
				loc: escape(window.location)
			},
			onSuccess: showReportPostResult}
		);
		//alert("bad post report! " + table+", "+index);
	}
}

function showReportPostResult(transport) {
	alert(transport.responseText);
	
}

function filterShortName(item) {
	//alert(item.value);
	var val = item.value;
	val = val.toLowerCase();
	val = val.replace(/[^a-z1-9]/g, '');
	item.value = val;
}

function radioClicked(id) {
	$(id).checked = true;
}

function checkboxClicked(id) {
	$(id).checked = !$(id).checked;
}

function confirmDeleteItem(name) {
	return confirm('Are you sure you want to delete the item "'+name+'"?');
}

function updateCommentCount(ml, name) {
	var comment = jQuery('#'+name+'Input').attr('value');
	var l = comment.length;
	jQuery('#'+name+'CharCount').html('('+l+ ' of '+ml+' Chars)');
}


function zebraLog(msg) {
	zebraWriteToLog('Debug', msg);
}

function zebraAlert(msg) {
	alert(msg);
	zebraWriteToLog('Alert', msg);
}

function zebraWriteToLog(label, msg) {
	if ($('zebraLogContent'))
		$('zebraLogContent').innerHTML += label+': '+msg+'<br /><br />';
}

function zebraClearDebug(label, msg) {
	if ($('zebraLogContent'))
		$('zebraLogContent').innerHTML = '';
}

function zebraShowDebug(showit) {
	if (showit) {
		$('zebraLog').style.display = 'block';
		$('zebraDebug').style.display = 'none';
	} else {
		$('zebraLog').style.display = 'none';
		$('zebraDebug').style.display = 'block';
	}
}



function dump(arr,level) {
	var r = '';
	for (var a in arr) {
		r += a+"\n";	
	}
	return r;
} 