cjuidialog conditional redirect

Hi, is anyone familiar with a cjuidialog conditional redirect, but where one of the options for redirecting is to the existing (same page) that the dialog box originated?

I have 2 instances where I use a cjuidialog for a login:

  1. Home page-> click on login and submit redirects to user account summary page. This works fine.

  2. Product gallery -> as a guest, clicking on "Buy Product" forces user to login via cjuidialog. I am using the same file/model as in #1. But I would like the login from this page to redirect back to the same exact product gallery page. Right now, login from the product page just redirects me to the user account summary page, just like in #1.

Any thoughts? Thanks.