How do I get the current record ID in a script?

Hopefully a fairly simple question:  I am modifying an AJAX js for a quote building tool, that pops out product creation to a child window that lets me build a product from several options.  The problem, is that I cannot figure out how to send the current record ID to the external page so it can put the product in the database.  I can usually get this from the document.uri with some trimming, but I notice that doesn't have the record ID when coming in from the detail view to the edit view.  Is there an easy way to do this, or should I just also modify the PHP to create an easily acces