AdminNewsletterUsersGridJsParams = "width=800,height=600";

function AdminNewsletterUsersGridModify( uid ) {
	window.open( 'user_edit.php?mode=modify&uid='+uid , '_blank' , AdminNewsletterUsersGridJsParams );
}

function AdminNewsletterUsersGridAction( n , action , params ) {
	if ($("#"+FNTHSuperGrid_ToolbarId( n , action )).hasClass( "dsb" )) return;
	switch (action) {
	case "new":
		window.open( 'user_edit.php?mode=new' , '_blank' , AdminNewsletterUsersGridJsParams );break;
	case "modify":
		AdminNewsletterUsersGridModify( $("#"+n).data( "selecteds" )[0] , AdminNewsletterUsersGridJsParams );
		break;
	case "delete":
		if (!window.confirm( aJSLangDefs.newsletters_Confirm_delete_newsletter_user )) return;
		BGAction( n , action );
		break;
	case "filter":
		$("#frm_AdminNewsletterUsersGrid").append( "<input type=\"hidden\" name=\"task\" value=\"filter\" />" );
		document.frm_AdminNewsletterUsersGrid.submit();
		break;
	case "import":
		var newsletter_group_id = 0;
		if (typeof params != "undefined" && typeof params["newsletter_group_id"]!="undefined")
			newsletter_group_id = params["newsletter_group_id"];
		AdminNewsletterUsersImport( newsletter_group_id );
		break;
	case "export":
		window.open( document.location.href + "&export=1" , '_blank' );
		break;
	case "add_to_group":
		if (!window.confirm( aJSLangDefs.newsletters_Confirm_add_users_to_group )) return;
		BGAction( n , action , params );
		break;
	case "del_from_group":
		if (!window.confirm( aJSLangDefs.newsletters_Confirm_del_users_from_group )) return;
		BGAction( n , action , params );
		break;
	}
}

function AdminNewsletterUsersGridSelectionChanged( tblid , chk , id ) {
	BGSelectionChanged( tblid , chk , id );
	AdminNewsletterUsersChanged( tblid  );
}

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

function AdminNewsletterUsersGridSelectAll( tblid , val ) {
	BGSelectAll( tblid , val );
	AdminNewsletterUsersChanged( tblid );
}

