Thank you for providing your login details. (I have left everything as I found it.)
Having run a few tests, I can confirm that as far as your server is concerned, your main page and your pop-up window are one and the same page and they cannot be distinguished using $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"] as the same value is returned for each.
I have also tried $_SERVER["HTTP_REFERER"] and $_SERVER["PHP_SELF"] but to no avail.
As there is no way to check using PHP whether the shortcode_handler() function is being run inside a frame or pop-up window, the only other possible solution I can think of at the moment is to:
(1) Disable processing of the Juicebox shortcode by default.
(2) Pass a query string variable in the URL to be opened by your pop-up window.
(3) Check (within the shortcode_handler() function) to see if the variable is present and process the shortcode if it is.
This would require that you change your shortcode_handler() conditional to the following:
if (is_singular() || $_GET['jb'] == true) {
... and you would also have to ensure that your pop-up window links are changed from:
<a href="http://www.alexis.it/fashion-week/parigi/parigi-guy-laroche-en-bleu" rel="#pin-1622" class="whitebox">
... to:
<a href="http://www.alexis.it/fashion-week/parigi/parigi-guy-laroche-en-bleu?jb=true" rel="#pin-1622" class="whitebox">
If the code that generated the links currently look like this:
<a href="<?php the_permalink(); ?>" rel="#pin-<?php the_ID(); ?>
... then change it to:
<a href="<?php the_permalink(); ?>?jb=true" rel="#pin-<?php the_ID(); ?>
This solution should work fine.
I do not know where the code for your links is generated within your theme but I tested it on your main page and it works as expected.
With regard to the CSS clashes resulting in odd formatting of your galleries, currently the only solution (other than changing the CSS within your theme) would be to create your galleries on your computer (i.e. not using WP-Juicebox) and then embed them in iframes as I have previously suggested.