<p>Suppose I have a page that I am writing a javascript plugin for on the domain <code>first.com</code>.  The javascript plugin injects an iframe pointing to a login page (of domain <code>second.com</code>) into the <code>first.com</code> page and displays it as a popup so that the user can login.</p>

<p>Is there anyway for me to hide/close the iframe after the user logs in with it?  I can inject any javascript necessary into the <code>first.com</code> page and I control both the client and server side code on the login page within the iframe.</p>

<p>The main issue is that the iframe cannot access it's parent window to hide itself and the parent window cannot see any changes made in the contents of the iframe because of the same origin policy.  Is there anyway around this or should I just lose the iframe idea and instead open a new window?</p>

I think the issue you're running into is the browser stopping the cross-domain communication from happening.  There is a way to
sign your javascript
but it is pretty much breaking the browser security model and isn't suggested unless absolutely necessary.
Is there any way that the login form is based on URL submition?  You could create a simple sign in form and use AJAX to get your response back to ensure a successful login.  This solution depends on having a RESTful login and again, I'm not sure about the implementation of your second.com.
If you're wondering about how to use the ajax to submit a form, I'd check
this
out (it is in jQuery but it applies to just about any framework.)  View the source on that and see if that could work in your situation.