JQuery popup iframe with cookies problem

JQuery popup iframe with cookies problem

I am making a popup system with bPopup with an iFrame loaded and I would like to load the popup only if it hasn't been loaded yet. Here is the part of the code that, in my opinion, should do it, but somehow it doesn't work.

 
  1. <script>
  2. // Semicolon (;) to ensure closing of earlier scripting
  3. // Encapsulation
  4. // $ is assigned to jQuery
  5. ;
  6. var cvalue = $.cookie('xVisited');
  7. if (cvalue != true) {
  8. $.cookie('xVisited', 'true');
  9. (function($) {

  10. $(window).bind('load', function (e) {
  11. // DOM Ready
  12. $(function() {

  13. // Binding a click event
  14. // From jQuery v.1.7.0 use .on() instead of .bind()


  15. // Prevents the default action to be triggered.
  16. e.preventDefault();

  17. // Triggering bPopup when click event is fired

  18. $('#element_to_pop_up').bPopup();

  19. }


  20. )}


  21. )}

  22. )}(jQuery);
  23. </script>

Do you have any idea what I need to change in order to make it work?