
function AdminMembersGridModify( uid ) {
	window.open( 'edit.php?mode=modify&uid='+uid , '_blank' , AdminMembersGridJsParams );
}

function AdminMembersGridSelectMember( member_id , callback , callback_param ) {
	eval( "window.opener."+callback+"('"+callback_param+"','"+member_id+"');" );
	window.close();
}

function AdminMembersGridAction( n , action , params ) {
	if ($("#"+FNTHSuperGrid_ToolbarId( n , action )).hasClass( "dsb" )) return;
	switch (action) {
	case "new":
		window.open( 'edit.php?mode=new' , '_blank' , AdminMembersGridJsParams );break;
	case "modify":
		AdminMembersGridModify( $("#"+n).data( "selecteds" )[0] , AdminMembersGridJsParams );
		break;
	case "delete":
		AdminMembersGridDelete( params.member_id );
		break;
	case "expire":
		AdminMembersGridExpire( params.member_id );
		break;
	case "filter":
		$("#frm_AdminMembersGrid").append( "<input type=\"hidden\" name=\"task\" value=\"filter\" />" );
		document.frm_AdminMembersGrid.submit();
		break;
	case "status_regen":
		if (!window.confirm( aJSLangDefs.memberspage_confirm_Status_regeneration )) return;
		BGAction( n , action );
		break;
	case "status_send":
		if (!window.confirm( aJSLangDefs.memberspage_confirm_Status_send )) return;
		BGAction( n , action );
		break;
	case "view_status_mail":
		if (typeof AdminMailtemplatesGridModify != "function") break;
		AdminMailtemplatesGridModify( params["mail_template_id"] );
		break;
	case "status_activate":
		if (!window.confirm( aJSLangDefs.memberspage_confirm_Activate_status_email )) return;
		BGAction( n , action , params );
		break;
	case "status_deactivate":
		if (!window.confirm( aJSLangDefs.memberspage_confirm_Deactivate_status_email )) return;
		BGAction( n , action , params );
		break;
	}
}

function AdminMembersGridSelectionChanged( tblid , chk , id ) {
	BGSelectionChanged( tblid , chk , id );
	AdminMembersChanged( tblid  );
}

function AdminMembersChanged( tblid ) {
	BGSelectionChangedDefaultAMD( tblid );
	var t = $("#"+tblid );
	var a = t.data( "selecteds" );
	if (a.length>0) {
		$("#"+tblid+"_tbrbutton_status_send").removeClass( "dsb" );
	} else {
		$("#"+tblid+"_tbrbutton_status_send").addClass( "dsb" );
	}
}

function AdminMembersGridSelectAll( tblid , val ) {
	BGSelectAll( tblid , val );
	AdminMembersChanged( tblid );
}

function AdminMembersGridDeleteCancel( member_id ) {
	$("#dlg_delete_member").dialog( "close" );
	$("#dlg_delete_member").dialog( "destroy" );
}

function AdminMembersGridSoftDelete( member_id ) {
	if (!window.confirm( aJSLangDefs.memberspage_confirm_Delete_members )) {
		AdminMembersGridDeleteCancel( member_id );
	} else {
		document.frm_delete_member.task.value="soft_delete";
		document.frm_delete_member.member_id.value=member_id;
		document.frm_delete_member.submit();
	}
}

function AdminMembersGridRealExpire( member_id ) {
	if (!window.confirm( aJSLangDefs.memberspage_confirm_Expire_members )) {
		AdminMembersGridDeleteCancel( member_id );
	} else {
		document.frm_delete_member.task.value="to_expire";
		document.frm_delete_member.member_id.value=member_id;
		document.frm_delete_member.submit();
	}
}

function AdminMembersGridHardDelete( member_id ) {
	if (!window.confirm( aJSLangDefs.memberspage_confirm_Delete_members )) {
		AdminMembersGridDeleteCancel( member_id );
	} else {
		document.frm_delete_member.task.value="hard_delete";
		document.frm_delete_member.member_id.value=member_id;
		document.frm_delete_member.submit();
	}
}

function AdminMembersGridDelete( member_id ) {
	var btns = {};
	btns[aJSLangDefs.Cancel]=function() { AdminMembersGridDeleteCancel( member_id ); }
	btns[aJSLangDefs.memberspage_Soft_delete]=function() { AdminMembersGridSoftDelete( member_id ); }
	btns[aJSLangDefs.memberspage_Hard_delete]=function() { AdminMembersGridHardDelete( member_id ); }

	$("#dlg_delete_member").dialog(
		{
			title: aJSLangDefs.memberspage_Delete_members,
			modal: true,
			width: 500,
			height: 200,
			buttons: btns
		
		}
	);
}

function AdminMembersGridExpire( member_id ) {
	var btns = {};
	btns[aJSLangDefs.Cancel]=function() { AdminMembersGridDeleteCancel( member_id ); }
	btns[aJSLangDefs.memberspage_Expire]=function() { AdminMembersGridRealExpire( member_id ); }

	$("#dlg_expire_member").dialog(
		{
			title: aJSLangDefs.memberspage_Expire_members,
			modal: true,
			width: 500,
			height: 200,
			buttons: btns
		
		}
	);
}

