/***************************************************************************
*
* IMPORTANT: This is a commercial product made by AntonLV and cannot be modified for other than personal usage. 
* This product cannot be redistributed for free or a fee without written permission from AntonLV. 
* This notice may not be removed from the source code.
*
***************************************************************************/

function alv_bnr_executeRequest(sAction, aParams, onResult, sType) {
	if(onResult == undefined || onResult == null) 
		onResult = function(){};
	if(sType == undefined || sType == "")
		sType = 'xml';

	var oDate = new Date();
	aParams._t = oDate.getTime();
	$.post(sAlvBnrHomeUrl + 'actions/'+ sAction + '.php', aParams, onResult, sType);
}
function alv_bnr_approve(oLink, iId) {
	alv_bnr_executeRequest(
		'approve',
		{id:iId},
		function(oData) {
			alert(oData.message);
			if(oData.code != 0) return;

			$(oLink).parents('#ban_info_' + oData.id).find("div.bnr_ban_stats > span.bnr_ban_status").html(oData.status);
		},
		'json'
	);

	return true;
}
function alv_bnr_reject(oLink, iId) {
	alv_bnr_executeRequest(
		'reject',
		{id:iId},
		function(oData) {
			alert(oData.message);
			if(oData.code != 0)	return;
			
			$(oLink).parents('#ban_info_' + oData.id).find("div.bnr_ban_stats > span.bnr_ban_status").html(oData.status);
		},
		'json'
	);

	return true;
}
function alv_bnr_delete(iId) {
	if(!confirm(sAlvBnrWrnDelete)) return;

	alv_bnr_executeRequest(
		'delete',
		{id:iId},
		function(oData) {
			if(oData.code != 0) {
				alert(oData.message);
				return;
			}

			$("#ban_view_" + oData.id + ",#ban_info_" + oData.id).fadeOut('slow', function(){
				$(this).remove();
			});
		},
		'json'
	);

	return true;
}