Well, the first step would be to add a few lines to your xorg.conf, mouse section:
Option "Buttons" "7"
Option "ZAxisMapping" "6 7"
to specify the amunt of buttons and make the scrollwheel work, but I guess you allready have these if your scrollwheel works.. Oh yeah, dont be fooled by the big numbers.. The buttons are in this order:
1. left mouse button
2. middle mouse button
3. right mouse button
4. thumb button 1
5. thumb button 2
6. scrollwheel up/down (dun remember which order)
7. scrollwheel up/down (dun remember which order)
Im not absolutely sure on the order (see xmodmap note later on)
So, once you have all your buttons ready for use, now we can use some program to bind them. Now, you might have the buttons in the wrong order, heres a short script I fix my ordering with upon X startup:
/usr/X11R6/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5"
I personally use xbindkeys to bind my mouse buttons, but that can only do shell commands.. But, ive noticed that if I dont have xbindkeys on, firefox can figure out we have more buttons than usually, and use the thumb buttons for back / next.. There are other nifty progs too, but sorry, cant remember names..
Hope this babble helps.. (;