Updated to support index value for calculating the z-index 

I was using this along with the angularjs-ui (bootstrap) modal and it ended up behind.  I used the same method they are, but added an index value which could be passed in.

This could also support having multiple modals so they are all layered one above another.