/*
 *  Snapple Module 1.0 - jQuery plugin
 *  written by Mike Fey (Hello Monday)	
 *  http://hellomonday.com
 *
 *  Built for jQuery library
 *  http://jquery.com
 *
 *  Controls opening, closing, and functionality
 *  of all modules for snapple.com
 */
 (function($) {

  var hideTimeout = 0;
  var showTimeout = 0;
  var selectedModule;
  var currentSizeObject;
  var curTopOffset = 0;
  var curLeftOffset = 0;
  var curModuleAd = '';
  var bestFanThumbMoveInt = 0;
  var leftOverBestFanThumbAmount = 0;
  var overflowResetTimeout = 0;
  var realFactsTransitionInt = 0;
  var rfCapInInt = 0;
  var rfCapOutInt = 0;
  var curBrowser = navigator.userAgent.toLowerCase();
  var rfCapOverlayDiv = 0;
  var hideOverlayTimeout = 0;
  var pobRotateInt = 0;
  var bfFirstClick = true;
  var pobIframeSrc = '';
  var pobIntroTimeout = 0;
  var proIframeSrc = '';
  var promotionsArray = [];
  var promotionInt = 0;
  var isMobile = false;
  var rfoTo = 0;
  var moduleLoaded = false;
  var p1Timeout = 0;
  var addressArray;
  var curPlusOneDiv;
  var firstPromotion;

  if (curBrowser.indexOf('iphone') != -1 || curBrowser.indexOf('ipod') != -1 || curBrowser.indexOf('ipad') != -1 || curBrowser.indexOf('android') != -1 || curBrowser.indexOf('blackBerry') != -1) {
    isMobile = true;
  }

  var methods = {
     
		//sets up all modules based on their DOM css properties
    init: function(options) {
      return this.each(function() {
        var mainDiv = $(this);

        var ogSizeObject = new Object();
        ogSizeObject.divId = mainDiv.attr('id');
        ogSizeObject.ogWidth = mainDiv.css('width');
        ogSizeObject.ogHeight = mainDiv.css('height');
        ogSizeObject.ogX = mainDiv.css('left');
        ogSizeObject.ogY = mainDiv.css('top');

        var newSizeObject = new Object();

        mainDiv.data('ogSizeObject', ogSizeObject);
        mainDiv.data('newSizeObject', newSizeObject);

        mainDiv.bind('click', expandClick);
        mainDiv.find('.closeButton a').bind('click', closeClick);

      });
    },
    
		//transitions in expanded module
    expand: function(selId, baseUrl) {
      setSelectedModule(selId, baseUrl);
    },
    
		//transitions in all collapsed modules,
		//called on initial site load
    transitionInAll: function() {
      return this.each(function(index) {
        var mainDiv = $(this);
        if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
          mainDiv.css({
            opacity: 0.0
          });

          mainDiv.stop(true, true).delay((index / 20) * 1000).animate({
            opacity: 1.0
          },
          {
            duration: 500,
            specialEasing: {
              opacity: 'easeOutSine'
            }
          });
        } else {
          mainDiv.show();
        }

        $('#bestFanImageBack').show();

      });
    },
    
		//closes all modules
    transitionOutAll: function() {
      returnToOverview();
    },
    
		//hides all modules
    hide: function() {
      return this.each(function() {

      });
    },
    
		//destroys all modules
    destroy: function() {
      return this.each(function() {

      });
    }
  };

  //helper functions
  function setShareButtons() {
    $('.shareButton').each(function() {
      $(this).unbind();
      if ($(this).attr('id') != 'googleShare') {
        $(this).bind('click',
        function() {
          var cl = $(this).find('a').attr('href');
          window.open(cl, "sharepopup", "scrollbars,resizable,width=800,height=600");
          return false;
        });
      }
    });
  }
  
	//the click function for the modules, sets the address
  function expandClick(e) {
    if ($(this).attr('class').indexOf('large-width') != -1 || $(this).attr('class').indexOf('large-height') != -1 || $(this).attr('id') == 'products') {
      var nAd = $(this).attr('id');
      $.address.value(nAd);
      return false;
    }
  }
  
	//the click function for the module close buttons
  function closeClick(e) {
    var nAd = '/';
    $.address.value(nAd);
    return false;
  }
  
	//sets the selected module based on the address
  function setSelectedModule(curAd, baseUrl) {

    clearTimeout(hideOverlayTimeout);

    if ($('#mainLoader').length == 0) {
      $('body').append('<div id="mainLoader"></div>');
    }

    positionLoader();

    var zDiv = Math.floor(500 / ($('.contentModule').length - 1));
    var pageToLoad = '';

    $('.contentModule').each(function(index) {
      if ($(this).attr('id') == curAd) {
        pageToLoad = $(this).find('a').attr('href');
        var curId = $(this).attr('id');
        selectedModule = $('#' + curId);

        var wp = $('#container').offset();

        var newSizeArray = selectedModule.attr('class').split(' ');
        newSizeObject = new Object();
        newSizeObject.newWidth = newSizeArray[1].substr(12, newSizeArray[1].length);
        newSizeObject.newHeight = newSizeArray[2].substr(13, newSizeArray[2].length);
        newSizeObject.newX = ($(window).width() / 2) - (newSizeObject.newWidth / 2) - wp.left;
        newSizeObject.newY = ($(window).height() / 2) - (newSizeObject.newHeight / 2) - wp.top - 20;
      }
    });

    if ($(window).height() > 940) {
      $('body').css({
        'overflow': 'hidden'
      });
    } else {
      if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
        $('body').css({
          'overflow-x': 'hidden'
        });
      }
    }

    $('#moduleOverlay').show();
    $('#moduleOverlay').css({
      opacity: 0.8
    });

    loadPage(pageToLoad, baseUrl, newSizeObject);

  }
  
	//loads the clicked module content via AJAX
  function loadPage(pageToLoad, baseUrl, newSizeObject) {
    try {
      $('#moduleContent').snappleMemoryGame('destroy');
    } catch(err) {
      //do nothing
    }

    $.ajaxSetup({
      cache: false
    });

    $.ajax({
      type: "GET",
      url: pageToLoad,
      success: function(data) {
        preloadModuleImages(data, 'regular', newSizeObject);
      }
    });
  }
  
	//preloads the correct images based on the clicked module
  function preloadModuleImages(data, type, newSizeObject) {

    addressArray = $.address.value().split('/');
    if (addressArray[0] == '') {
      addressArray.splice(0, 1);
    }

    var preloadArray = [];

    if (addressArray[0] == 'best-stuff') {
      preloadArray = ['wp-content/themes/snapple/images/module_best_stuff/best-stuff-expanded-back-bottom.png',
      'wp-content/themes/snapple/images/module_best_stuff/best-stuff-expanded-back-top.png',
      'wp-content/themes/snapple/images/module_best_stuff/best-stuff-expanded-banner.png',
      'wp-content/themes/snapple/images/module_best_stuff/best-stuff-expanded-close-btn.png',
      'wp-content/themes/snapple/images/module_best_stuff/best-stuff-expanded-thumb-back.png'];
    }

    if (addressArray[0] == 'news') {
      preloadArray = ['wp-content/themes/snapple/images/module_news/news-large-ticket.png',
      'wp-content/themes/snapple/images/module_news/news-expanded-back.png',
      'wp-content/themes/snapple/images/module_news/news-expanded-close-btn.png'];
    }

    if (addressArray[0] == 'best-fan') {

      preloadArray = ['wp-content/themes/snapple/images/module_best_fan/best-fan-expanded-badge.png',
      'wp-content/themes/snapple/images/module_best_fan/best-fan-expanded-pic-back.png',
      'wp-content/themes/snapple/images/module_best_fan/best-fan-expanded-text-back.png',
      'wp-content/themes/snapple/images/module_news/news-expanded-close-btn.png',
      'wp-content/themes/snapple/images/module_best_fan/best-fan-expanded-right-btn.png',
      'wp-content/themes/snapple/images/module_best_fan/best-fan-expanded-left-btn.png'];
    }

    if (addressArray[0] == 'campaigns') {
      preloadArray = ['wp-content/themes/snapple/images/module_campaigns/campaigns-expanded-back.png',
      'wp-content/themes/snapple/images/module_campaigns/campaigns-expanded-thumb-container-back.jpg',
      'wp-content/themes/snapple/images/module_news/news-expanded-close-btn.png'];
    }

    if (addressArray[0] == 'pursuit-of-bestness') {
      preloadArray = ['wp-content/themes/snapple/images/module_pursuit_of_bestness/pob-expanded-frame-top.png',
      'wp-content/themes/snapple/images/module_pursuit_of_bestness/pob-expanded-frame-left.png',
      'wp-content/themes/snapple/images/module_pursuit_of_bestness/pob-expanded-frame-right.png',
      'wp-content/themes/snapple/images/module_pursuit_of_bestness/pob-expanded-frame-bottom.png',
      'wp-content/themes/snapple/images/module_news/news-expanded-close-btn.png'];
    }

    if (addressArray[0] == 'promotions') {
      preloadArray = ['wp-content/themes/snapple/images/module_promotions/promotions-expanded-back.png',
      'wp-content/themes/snapple/images/module_news/news-expanded-close-btn.png',
      'wp-content/themes/snapple/images/module_promotions/promotions-expanded-back-card.png',
      'wp-content/themes/snapple/images/module_promotions/promotions-expanded-back-card-2.png'];
    }

    if (addressArray[0] == 'real-facts') {
      preloadArray = ['wp-content/themes/snapple/images/module_real_facts/real-facts-game-back.png',
      'wp-content/themes/snapple/images/module_real_facts/real-facts-game-bottom-cap.png',
      'wp-content/themes/snapple/images/module_real_facts/real-facts-game-cap.png',
      'wp-content/themes/snapple/images/module_real_facts/real-facts-game-number-back.png',
      'wp-content/themes/snapple/images/module_real_facts/real-facts-game-reset-button.png',
      'wp-content/themes/snapple/images/module_real_facts/real-facts-game-text-btn.png',
      'wp-content/themes/snapple/images/module_real_facts/real-facts-transition-cap.png',
      'wp-content/themes/snapple/images/module_real_facts/real-facts-expanded-cap.png',
      'wp-content/themes/snapple/images/module_real_facts/real-facts-expanded-cap-top.png'];
    }

    jQuery.imgpreload(preloadArray, {
      all: function() {
        transitionInModule(data, type, newSizeObject);
      }
    });

  }
  
	//transitions in the module once all images are preloaded
  function transitionInModule(loadedData, type, newSizeObject) {

    $('#moduleContainer').show();

    clearInterval(realFactsTransitionInt);
    clearTimeout(pobIntroTimeout);

    var nhtml;
    var contentHtml = $(loadedData);

    clearTimeout(showTimeout);
    clearTimeout(hideTimeout);
    clearTimeout(overflowResetTimeout);

    curTopOffset = 0;
    curLeftOffset = 0;

    var newContent = contentHtml.find('#moduleContent');

    addressArray = $.address.value().split('/');
    if (addressArray[0] == '') {
      addressArray.splice(0, 1);
    }

    curModuleAd = addressArray[0];

    if (addressArray[0] != 'best-fan') {
      $('#mainLoader').remove();
    } else {
      if (curBrowser.indexOf('msie 8.0') != -1 || curBrowser.indexOf('msie 7.0') != -1) {
        $('#mainLoader').remove();
      }
    }

    $('#moduleContainer').html(newContent);

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#moduleContainer').css({
        opacity: 1.0
      });
    }

    currentSizeObject = newSizeObject;

    var tPos = 0;
    var lPos = 0;
    if ($(window).height() > 945) {
      tPos = (($(window).height() / 2) - (newSizeObject.newHeight / 2));
    } else {
      tPos = ((945 / 2) - (newSizeObject.newHeight / 2));
    }

    if ($(window).width() > 1210) {
      var lPos = (($(window).width() / 2) - (newSizeObject.newWidth / 2));
    } else {
      var lPos = ((1210 / 2) - (newSizeObject.newWidth / 2));
    }

    if ($.address.value() == '/campaigns') {
      if ($(window).height() > 945) {
        tPos = ($(window).height() - newSizeObject.newHeight);
      } else {
        tPos = (945 - newSizeObject.newHeight);
      }
    }

    $('.expandedModuleCloseBtn').bind('click', expandedModuleCloseClick);

    setCaps();

    //best-stuff transition
    if (addressArray[0] == 'best-stuff') {

      setupBestStuffExpanded();

      curTopOffset = 70;

      $('#moduleContainer').css({
        'left': lPos + curLeftOffset + 'px',
        top: -(newSizeObject.newHeight) + 'px'
      });

      $('#moduleContainer').stop(true, true).animate({
        top: tPos + curTopOffset
      },
      {
        duration: 700,
        specialEasing: {
          top: 'easeOutExpo'
        }
      });
    }

    //news transition
    if (addressArray[0] == 'news') {

      setupNewsExpanded();

      curTopOffset = 0;

      $('#moduleContainer').css({
        'left': lPos + curLeftOffset + 'px',
        top: (tPos + curTopOffset) + 'px'
      });

      var mPos = $('#moduleContainer').offset();

      if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
        $('#newsCloseBtn').css({
          opacity: 0.0
        });
        $('#newsExpandedTitleText').css({
          opacity: 0.0
        });
        $('#newsExpandedDescText').css({
          opacity: 0.0
        });

        $('#newsCloseBtn').stop(true, true).delay(600).animate({
          opacity: 1.0
        },
        {
          duration: 300,
          specialEasing: {
            opacity: 'easeOutSine'
          }
        });

      } else {
        setTimeout(function() {
          $('#newsCloseBtn').show();
        },
        600);
        $('#newsExpandedTitleText').hide();
        $('#newsExpandedDescText').hide();
      }

      $('#newsExpandedThumbBack').css({
        'left': -($(window).width() / 2) + mPos.left - $('#newsExpandedThumbBack').width() + 'px'
      });
      $('#newsExpandedThumbBack').stop(true, true).animate({
        left: 0
      },
      {
        duration: 300,
        specialEasing: {
          left: 'easeOutExpo'
        }
      });

      $('#newsExpandedBack').css({
        'left': ($(window).width() - mPos.left) + 'px'
      });
      $('#newsExpandedBack').stop(true, true).delay(300).animate({
        left: 210
      },
      {
        duration: 300,
        specialEasing: {
          left: 'easeOutExpo'
        }
      });

      if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
        $('#newsExpandedShareIcons').show();
        $('#newsExpandedShareIcons').css({
          opacity: 0.0
        });
        $('#newsExpandedShareIcons').stop(true, true).delay(600).animate({
          opacity: 1.0
        },
        {
          duration: 300,
          specialEasing: {
            left: 'easeOutSine'
          }
        });
      } else {
        setTimeout(function() {
          $('#newsExpandedShareIcons').show();
          $('#moduleContainer').show();
        },
        500);
      }


    }

    //best fan transition
    if (addressArray[0] == 'best-fan') {

      setupBestFanExpanded();

      curTopOffset = 50;

      $('#moduleContainer').css({
        'left': lPos + curLeftOffset + 'px',
        top: (tPos + curTopOffset) + 'px'
      });

      if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
        $('#moduleContainer').css({
          opacity: 0.0
        });
      } else {
        $('#moduleContainer').show();
      }

    }

    //campaigns transition
    if (addressArray[0] == 'campaigns') {

      setupCampaignsExpanded();

      curTopOffset = -10;

      $('#moduleContainer').css({
        'left': lPos + curLeftOffset + 'px',
        top: ($(window).height() - curTopOffset) + 'px'
      });

      $('#moduleContainer').show();
      $('#moduleContainer').stop(true, true).delay(300).animate({
        top: tPos + curTopOffset
      },
      {
        duration: 500,
        specialEasing: {
          top: 'easeOutExpo'
        }
      });

    }

    //pursuit-of-bestness
    if (addressArray[0] == 'pursuit-of-bestness') {

      pobIframeSrc = $('#pobExternalPageContentInner').html();
      if (addressArray.length > 1) {
        if (addressArray[1] != 'register') {
          capNum = addressArray[addressArray.length - 1];
          pobIframeSrc = '<iframe src="http://www.snapple.com/bestness/claim/' + capNum + '" width="1045" height="650" scrolling="no"><p>Your browser does not support iframes.</p></iframe>';
        } else {
          pobIframeSrc = '<iframe src="http://www.snapple.com/bestness/index/getregistered" width="1045" height="650" scrolling="no"><p>Your browser does not support iframes.</p></iframe>';
        }
      }

      $('#pobExternalPageContentInner').html('');

      curTopOffset = 40;

      $('#nav_main').hide();

      $('#moduleContainer').css({
        'left': lPos + curLeftOffset + 'px',
        top: -(newSizeObject.newHeight) + 'px'
      });

      $('#moduleContainer').stop(true, true).animate({
        top: tPos + curTopOffset
      },
      {
        duration: 700,
        specialEasing: {
          top: 'easeOutExpo'
        }
      });

      if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
        $('#pobExpandedInner').rotate('-7deg');
      }

      pobIntro();
    }

    //promotions
    if (addressArray[0] == 'promotions') {
      curTopOffset = 0;

      $('#moduleContainer').css({
        'left': lPos + curLeftOffset + 'px',
        top: (tPos + curTopOffset) + 'px'
      });

      if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
        $('#moduleContainer').css({
          opacity: 0.0
        });
      }

      $('#promotionsExpandedCloseBtn').hide();

      $('#promotionsExpandedBg1').css({
        'top': '10px',
        'left': '2px'
      });

      $('#promotionsExpandedBg2').css({
        'top': '10px',
        'left': '2px'
      });

      $('#promotionsExternalPageContent').css({
        'top': '45px',
        'left': '42px'
      });

      promotionsIntro();
    }

    //real facts
    if (addressArray[0] == 'real-facts') {

      curTopOffset = 10;
      $('#moduleContainer').css({
        'left': lPos + curLeftOffset + 'px',
        top: (tPos + curTopOffset) + 'px'
      });

      if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
        $('#moduleContainer').css({
          opacity: 0.0
        });
      } else {
        $('#moduleContainer').hide();
      }

      realFactsIntro();
    }

    if ($(window).height() > 940) {
      $('body').css({
        'overflow': 'hidden'
      });
    } else {
      if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
        $('body').css({
          'overflow-x': 'hidden'
        });
      }
    }

    overflowResetTimeout = setTimeout(resetOverflow, 700);
    addPlusOne();
  }
  
	//adds the Google Plus One button to each module
  function addPlusOne() {

    addressArray = $.address.value().split('/');
    if (addressArray[0] == '') {
      addressArray.splice(0, 1);
    }

    if (addressArray[0] == 'best-stuff') {
      poUrl = 'http://snapple.com/modules/best-stuff/best-stuff-expanded';
    } else if (addressArray[0] == 'news') {
      poUrl = 'http://snapple.com/modules/news/news-expanded';
    } else if (addressArray[0] == 'best-fan') {
      poUrl = 'http://snapple.com/modules/best-fan/best-fan-expanded';
    } else if (addressArray[0] == 'campaigns') {
      poUrl = 'http://snapple.com/modules/campaigns/campaigns-expanded';
    } else if (addressArray[0] == 'pursuit-of-bestness') {
      poUrl = 'http://snapple.com/modules/pursuit-of-bestness/pursuit-of-bestness-expanded';
    } else if (addressArray[0] == 'promotions') {
      poUrl = 'http://snapple.com/modules/promotions/promotions-expanded';
    } else if (addressArray[0] == 'real-facts') {
      poUrl = 'http://snapple.com/modules/real-facts/real-facts-expanded';
    }

    try {
      gapi.plusone.render(
      "googleShare",
      {
        "size": "small",
        "annotation": "none",
        "href": poUrl
      });
    } catch(e) {
      console.log('error rendering plus one: ' + e);
    }

    $('#googleShare').css({
      'margin-top': '1px'
    });

    setShareButtons();

  }
  
	//the function for the close button and overlay click
  function expandedModuleCloseClick() {
    $.address.value('/');
  }
  
	//closes and resets all modules
  function returnToOverview() {

    clearTimeout(showTimeout);
    clearTimeout(hideTimeout);
    clearTimeout(overflowResetTimeout);
    clearInterval(realFactsTransitionInt);
    clearTimeout(hideOverlayTimeout);
    clearTimeout(pobIntroTimeout);

    try {
      $('#moduleContent').snappleMemoryGame('destroy');
    } catch(err) {
      //
      }

    var gpb = $('#googleShare').find('.gpo');
    $('#footerButtonContainerInner').append(gpb);

    $('#productsButton').show();

    pageToLoad = 'pageToLoad';
    transInInt = 0;

    var avs = ($.address.value().toString())
    var cs = avs.split('/')[1];

    if (curModuleAd == 'best-stuff') {

      bestStuffOutro();

      if (cs != 'products' && cs != 'page') {
        hideOverlayTimeout = setTimeout(hideModuleOverlay, 1800);
      }
      showTimeout = setTimeout(checkTransitionOut, 1800);
      overflowResetTimeout = setTimeout(resetOverflow, 1800);
    }

    if (curModuleAd == 'news') {

      newsOutro();

      if (cs != 'products' && cs != 'page') {
        hideOverlayTimeout = setTimeout(hideModuleOverlay, 600);
      }
      showTimeout = setTimeout(checkTransitionOut, 600);
      overflowResetTimeout = setTimeout(resetOverflow, 600);

    }

    if (curModuleAd == 'best-fan') {

      bestFanOutro();
      if (cs != 'products' && cs != 'page') {
        hideOverlayTimeout = setTimeout(hideModuleOverlay, 500);
      }
      showTimeout = setTimeout(checkTransitionOut, 500);
      overflowResetTimeout = setTimeout(resetOverflow, 500);
    }

    if (curModuleAd == 'campaigns') {

      if (cs != 'products' && cs != 'page') {
        hideOverlayTimeout = setTimeout(hideModuleOverlay, 600);
      }
      showTimeout = setTimeout(checkTransitionOut, 600);
      overflowResetTimeout = setTimeout(resetOverflow, 600);

      campaignsOutro();
    }

    if (curModuleAd == 'pursuit-of-bestness') {
      if (cs != 'products' && cs != 'page') {
        hideOverlayTimeout = setTimeout(hideModuleOverlay, 1000);
      }

      showTimeout = setTimeout(checkTransitionOut, 1000);
      overflowResetTimeout = setTimeout(resetOverflow, 1000);


      pobOutro();
    }

    if (curModuleAd == 'promotions') {
      if (cs != 'products' && cs != 'page') {
        hideOverlayTimeout = setTimeout(hideModuleOverlay, 800);
      }

      showTimeout = setTimeout(checkTransitionOut, 800);
      overflowResetTimeout = setTimeout(resetOverflow, 800);

      promotionsOutro();
    }

    if (curModuleAd == 'real-facts') {
      if (cs != 'products' && cs != 'page') {
        hideOverlayTimeout = setTimeout(hideModuleOverlay, 1500);
      }

      showTimeout = setTimeout(checkTransitionOut, 1500);
      overflowResetTimeout = setTimeout(resetOverflow, 1500);

      realFactsOutro();
    }

    if ($(window).height() > 940) {
      $('body').css({
        'overflow': 'hidden'
      });
    } else {
      if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
        $('body').css({
          'overflow-x': 'hidden'
        });
      }
    }
  }
  
	//hides the black overlay
  function hideModuleOverlay() {
    $('#moduleOverlay').stop(true, true).hide();
  }
  
	//resets the site overflow
  function resetOverflow() {
    $('body').css({
      'overflow': 'auto'
    });
  }
  
	//hides the small version of the selected module 
  function hideAllNotSelected() {
    $('.contentModule').each(function() {
      if ($(this).attr('id') != selectedModule.attr('id')) {
        $(this).hide();
      }
    });

    $('body').css({
      'overflow': 'auto'
    });
  }
  
	//clears the content out of the #moduleContainer
  function checkTransitionOut() {
    $('#moduleContainer').html('');
  }
  
	//shows the close button for the module
  function showCloseButton() {
    selectedModule.find('.closeButton').show();
  }
  
	//positions the preloader
  function positionLoader() {
    var tpos = ($(window).height() / 2) - 32;
    if ($(window).height() < 945) {
      tpos = (945 / 2) - 32;
    }

    var lpos = ($(window).width() / 2) - 32;
    if ($(window).width() < 1210) {
      lpos = (1210 / 2) - 32;
    }
    $('#mainLoader').css({
      'top': tpos + 'px',
      'left': lpos + 'px'
    });
  }

  $(window).resize(function() {
    positionModuleContainer();
    if (curModuleAd == 'real-facts') {
      positionRfOverlay();
    }

    if ($('#capLoader').length > 0) {
      positionCapLoader();
    }

  });
  
	//positions the module container
  function positionModuleContainer() {

    try {
      var av = new String($.address.value());
      var addressArray = av.split('/');

      if (addressArray[0] != 'products' && addressArray[0] != 'page') {
        var tPos = 0;
        var lPos = 0;
        if ($(window).height() > 945) {
          tPos = (($(window).height() / 2) - (newSizeObject.newHeight / 2));
        } else {
          tPos = ((945 / 2) - (newSizeObject.newHeight / 2));
        }

        if ($(window).width() > 1210) {
          var lPos = (($(window).width() / 2) - (newSizeObject.newWidth / 2));
        } else {
          var lPos = ((1210 / 2) - (newSizeObject.newWidth / 2));
        }

        if ($.address.value() == '/campaigns') {
          if ($(window).height() > 945) {
            tPos = ($(window).height() - newSizeObject.newHeight);
          } else {
            tPos = (945 - newSizeObject.newHeight);
          }
        }

        $('#moduleContainer').css({
          'top': (tPos + curTopOffset) + 'px',
          'left': (lPos + curLeftOffset) + 'px'
        });
      }

    } catch(err) {
      //do nothing
    }
  }
  
	//positions the second overlay that shows up when the
	//Real Facts game is paused or completed
  function positionRfOverlay() {
    var rfw = $(window).width();
    var rfh = $(window).height();

    var rfl = -$('#moduleContainer').offset().left;
    var rft = -$('#moduleContainer').offset().top;

    if ($(window).width() < 1230) {
      rfw = 1230;
    }

    if ($(window).height() < 945) {
      rfh = 945;
    }

    $('#realFactsGameOverlay').css({
      'width': rfw + 'px',
      'height': rfh + 'px',
      'top': rft + 'px',
      'left': rfl + 'px'
    });
  }

  //creates and returns an array from the current hash mark
  function getCurrentAddressArray() {
    var caa = $.address.value().toString().split('/');
    return caa;
  }


  //sets up the content for the expanded Best Stuff module
  function setupBestStuffExpanded() {
    $('.bestStuffExpandedThumbBlock').each(function(ind) {
      if ($(this).attr('class').indexOf('bseCap') == -1) {
        $(this).bind('mouseenter', {
          ind: ind
        },
        bsetOver);
        $(this).bind('mouseleave', {
          ind: ind
        },
        bsetOut);
        $(this).bind('click', {
          ind: ind
        },
        bsetClick);
      }
    });

    $('#bestStuffExpandedThumbContainer').mouseMoveMenu({
      containerDiv: 'bestStuffExpandedThumbContainer',
      scrollDiv: 'bestStuffExpandedThumbContainerInner'
    });
    $('#bestStuffExpandedThumbBack').hide();



    setTimeout(bestStuffIntro, 200);
  }
  
	//animates out the Best Stuff module
  function bestStuffOutro() {
    $('#bestStuffShareIcons').hide();

    $('#bestStuffExpandedThumbBack').stop(true, true).animate({
      left: 750
    },
    {
      duration: 500,
      specialEasing: {
        left: 'easeOutExpo'
      }
    });

    $('#bestStuffExpandedPaperInner').stop(true, true).delay(500).animate({
      marginTop: -50
    },
    {
      duration: 300,
      specialEasing: {
        marginTop: 'easeOutBack'
      }
    }).animate({
      marginTop: -520
    },
    {
      duration: 300,
      specialEasing: {
        marginTop: 'easeOutBack'
      }
    });

    $('#moduleContainer').stop(true, true).delay(1100).animate({
      top: -950
    },
    {
      duration: 700,
      specialEasing: {
        top: 'easeInOutExpo'
      }
    });

    $('#bestStuffExpandedContent').html('');
    $('#bestStuffExpandedDescText').html('');
    setTimeout(bestStuffOutroP2, 500);
  }
  
	//animates out the Best Stuff module
  function bestStuffOutroP2() {
    $('#bestStuffExpandedThumbBack').hide();
  }
   
	//animates in the Best Stuff module
  function bestStuffIntro() {
    $('#bestStuffExpandedPaperInner').stop(true, true).delay(600).animate({
      marginTop: -50
    },
    {
      duration: 500,
      specialEasing: {
        marginTop: 'easeOutBack'
      }
    }).animate({
      marginTop: 50
    },
    {
      duration: 300,
      specialEasing: {
        marginTop: 'easeOutSine'
      }
    });

    setTimeout(bestStuffIntroP2, 1400);
  }
  
	//animates in the Best Stuff module
  function bestStuffIntroP2() {
    $('#bestStuffExpandedThumbBack').css({
      'left': '750px'
    });
    $('#bestStuffExpandedThumbBack').show();
    $('#bestStuffExpandedThumbBack').stop(true, true).delay(500).animate({
      left: 990
    },
    {
      duration: 500,
      specialEasing: {
        left: 'easeOutExpo'
      }
    });

    setBestStuffClicked(0);
    $('.bestStuffExpandedThumbBlock:first').click();

    $('#bestStuffShareIcons').show();
    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#bestStuffShareIcons').css({
        opacity: 0.0
      });
      $('#bestStuffShareIcons').stop(true, true).delay(300).animate({
        opacity: 1.0
      },
      {
        duration: 500,
        specialEasing: {
          left: 'easeOutExpo'
        }
      });
    }
  }
 	
	//rollover function for the thumbs in the Best Stuff module
  function bsetOver() {
    $(this).find('.bestStuffExpandedThumbTitle').stop(true, true).animate({
      color: '#055fc8'
    },
    {
      duration: 300,
      specialEasing: {
        color: 'easeOutSine'
      }
    });
  }
  
	//rollout function for the thumbs in the Best Stuff module
  function bsetOut() {
    if ($(this).attr('class').indexOf('bstSelected') == -1) {
      $(this).find('.bestStuffExpandedThumbTitle').stop(true, true).animate({
        color: '#666666'
      },
      {
        duration: 300,
        specialEasing: {
          color: 'easeOutSine'
        }
      });
    }
  }
  
	//click function for the thumbs in the Best Stuff module
  function bsetClick(e) {
    var type = $(this).attr('class').split(' ')[1];
    var contentString = '';
    var contentUrl = unescape($(this).find('.bestStuffExpandedThumb img').attr('alt').split("*-*")[0]);
    var descText = unescape($(this).find('.bestStuffExpandedThumb img').attr('alt').split("*-*")[1]);

    setBestStuffClicked(e.data.ind);

    if (type == 'bestStuffSwf') {
      contentString += '<div id="bsSwfContainer"></div>';
    }

    if (type == 'bestStuffImage') {
      contentString += '<img src="' + contentUrl + '" />';
    }

    if (type == 'bestStuffVideo') {
      contentString += contentUrl;
    }

    if (type == 'bestStuffText') {
      descText = '';
      contentString += '<div class="bestStuffTextContainer">' + contentUrl + '</div>';
    }

    if (type == 'bestStuffExternal') {
      contentString += '<div class="bestStuffIframeContainer">';
      contentString += '	<iframe src="' + contentUrl + '" width="940" height="641" scrolling="no">';
      contentString += '		<p>Your browser does not support iframes.</p>';
      contentString += '	</iframe>';
      contentString += '</div>';
    }

    $('#bestStuffExpandedContent').stop(true, true).animate({
      opacity: 0.0
    },
    {
      duration: 100,
      specialEasing: {
        opacity: 'easeOutSine'
      }
    });

    $('#bestStuffExpandedDescText').stop(true, true).animate({
      opacity: 0.0
    },
    {
      duration: 100,
      specialEasing: {
        opacity: 'easeOutSine'
      }
    });

    setTimeout(function() {
      setBestStuffContent(contentString, type, contentUrl, descText);
    },
    100)
  }
  
	//shows correct content when a thumb is clicked the Best Stuff module
  function setBestStuffContent(contentString, type, contentUrl, descText) {
    $('#bestStuffExpandedContentTransBlock').show();

    $('#bestStuffExpandedContent').html(contentString);

    $('#bestStuffExpandedDescText').html(descText);

    if (type == 'bestStuffSwf') {
      var vars = {};
      var params = {
        scale: 'noScale',
        salign: 'lt',
        menu: 'false',
        allowFullScreen: 'true',
        'wmode': 'transparent'
      };
      var attributes = {
        id: 'bsSwfContainer',
        name: 'flash'
      };

      swfobject.embedSWF(contentUrl, "bsSwfContainer", '940', '570', '10', '', vars, params, attributes);
    }

    $('#bestStuffExpandedContent').stop(true, true).delay(200).animate({
      opacity: 1.0
    },
    {
      duration: 200,
      specialEasing: {
        opacity: 'easeOutSine'
      }
    });

    $('#bestStuffExpandedDescText').stop(true, true).delay(200).animate({
      opacity: 1.0
    },
    {
      duration: 200,
      specialEasing: {
        opacity: 'easeOutSine'
      }
    });

    setTimeout(function() {
      $('#bestStuffExpandedContentTransBlock').hide();
    },
    200);
  }
  
	//sets a thumbnail as "clicked" in the Best Stuff module
  function setBestStuffClicked(num) {
    $('.bestStuffExpandedThumbBlock').each(function(ind) {
      if (ind == num) {
        $(this).addClass('bstSelected');
        $(this).find('.bestStuffExpandedThumbTitle').stop(true, true).animate({
          color: '#055fc8'
        },
        {
          duration: 300,
          specialEasing: {
            color: 'easeOutSine'
          }
        });
      } else {
        $(this).removeClass('bstSelected');
        $(this).find('.bestStuffExpandedThumbTitle').stop(true, true).animate({
          color: '#666666'
        },
        {
          duration: 300,
          specialEasing: {
            color: 'easeOutSine'
          }
        });
      }
    });
  }

  //animates the News module out
  function newsOutro() {
    $('#newsCloseBtn').hide();
    $('#newsExpandedTitleText').hide();
    $('#newsExpandedDescText').hide();
    $('#newsExpandedShareIcons').hide();

    var mPos = $('#moduleContainer').offset();

    $('#newsExpandedThumbBack').stop(true, true).animate({
      left: -($(window).width() / 2) + mPos.left - $('#newsExpandedThumbBack').width() + 'px'
    },
    {
      duration: 300,
      specialEasing: {
        left: 'easeOutSine'
      }
    });

    $('#newsExpandedBack').stop(true, true).delay(300).animate({
      left: ($(window).width() - mPos.left)
    },
    {
      duration: 300,
      specialEasing: {
        left: 'easeOutSine'
      }
    });
  }
  
	//sets up the News module content
  function setupNewsExpanded() {
    $('.newsExpandedThumbBlock').each(function(ind) {
      $(this).bind('mouseenter', {
        ind: ind
      },
      newsetOver);
      $(this).bind('mouseleave', {
        ind: ind
      },
      newsetOut);
      $(this).bind('click', {
        ind: ind
      },
      newsetClick);
    });

    setNewsClicked(0);

    setTimeout(function() {
      $('.newsExpandedThumbBlock:first').click();
    },
    500);

    $('#newsExpandedThumbContainer').mouseMoveMenu({
      containerDiv: 'newsExpandedThumbContainer',
      scrollDiv: 'newsExpandedThumbInner',
      offset: 15
    });
  }
  
	//the rollover function for the thumbs in the News module
  function newsetOver() {
    $(this).find('.newsExpandedThumbTitle').stop(true, true).animate({
      color: '#055fc8'
    },
    {
      duration: 300,
      specialEasing: {
        color: 'easeOutSine'
      }
    });
  }
  
	//the rollout function for the thumbs in the News module
  function newsetOut() {
    if ($(this).attr('class').indexOf('newstSelected') == -1) {
      $(this).find('.newsExpandedThumbTitle').stop(true, true).animate({
        color: '#666666'
      },
      {
        duration: 300,
        specialEasing: {
          color: 'easeOutSine'
        }
      });
    }
  }
  
	//the click function for the thumbs in the News module
  function newsetClick(e) {
    var type = $(this).attr('class').split(' ')[1];
    var contentString = '';
    var contentUrl = unescape($(this).find('.newsExpandedThumb img').attr('alt').split("*-*")[0]);
    var titleText = unescape($(this).find('.newsExpandedThumbTitle').html());
    var descText = unescape($(this).find('.newsExpandedThumb img').attr('alt').split("*-*")[1]);

    setNewsClicked(e.data.ind);

    if (type == 'newsImage') {
      contentString += '<img src="' + contentUrl + '" />';
    }

    if (type == 'newsVideo') {
      contentString += contentUrl;
    }

    if (type == 'newsText') {
      descText = contentUrl;
    }

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#newsExpandedContent').stop(true, true).animate({
        opacity: 0.0
      },
      {
        duration: 300,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });

      $('#newsExpandedTitleText').stop(true, true).animate({
        opacity: 0.0
      },
      {
        duration: 300,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });

      $('#newsExpandedDescText').stop(true, true).animate({
        opacity: 0.0
      },
      {
        duration: 300,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });
    } else {
      $('#newsExpandedContent').hide();
      $('#newsExpandedTitleText').hide();
      $('#newsExpandedDescText').hide();
    }

    setTimeout(function() {
      setNewsContent(contentString, type, contentUrl, titleText, descText);
    },
    300)
  }
  
	//sets the proper content for the News module based on the clicked thumb
  function setNewsContent(contentString, type, contentUrl, titleText, descText) {
    $('#newsExpandedContent').html(contentString);
    $('#newsExpandedTitleText').html(titleText);
    $('#newsExpandedDescText').html(descText);

    if (type == 'newsText') {
      $('#newsExpandedTitleText').css({
        'top': '50px'
      });
      $('#newsExpandedDescText').css({
        'top': '75px'
      });
    } else {
      $('#newsExpandedTitleText').css({
        'top': '425px'
      });
      $('#newsExpandedDescText').css({
        'top': '450px'
      });
    }

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#newsExpandedContent').stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 500,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });

      $('#newsExpandedTitleText').stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 500,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });

      $('#newsExpandedDescText').stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 500,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });
    } else {
      $('#newsExpandedContent').show();
      $('#newsExpandedTitleText').show();
      $('#newsExpandedDescText').show();
    }
  }
  
	//sets a thumbnail as "clicked" in the News module
  function setNewsClicked(num) {
    $('.newsExpandedThumbBlock').each(function(ind) {
      if (ind == num) {
        $(this).addClass('newstSelected');
        $(this).find('.newsExpandedThumbTitle').stop(true, true).animate({
          color: '#055fc8'
        },
        {
          duration: 300,
          specialEasing: {
            color: 'easeOutSine'
          }
        });
      } else {
        $(this).removeClass('newstSelected');
        $(this).find('.newsExpandedThumbTitle').stop(true, true).animate({
          color: '#666666'
        },
        {
          duration: 300,
          specialEasing: {
            color: 'easeOutSine'
          }
        });
      }
    });
  }

  //animates the Best Fan module out
  function bestFanOutro() {
    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#moduleContainer').stop(true, true).animate({
        opacity: 0.0
      },
      {
        duration: 500,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });
    } else {
      $('#moduleContainer').hide();
    }
  }
  
	//sets up the content for the expanded Best Fan module
  function setupBestFanExpanded() {
    $('.bestFanExpandedThumbBlock').each(function(ind) {
      $(this).bind('mouseenter', {
        ind: ind
      },
      bestFanEtOver);
      $(this).bind('mouseleave', {
        ind: ind
      },
      bestFanEtOut);
      $(this).bind('click', {
        ind: ind
      },
      bestFanEtClick);
    });

    bestFanThumbMoveInt = 0;
    leftOverBestFanThumbAmount = 0;

    var totalThumbWidth = $('.bestFanExpandedThumbBlock').length * 185;
    $('#bestFanExpandedThumbInner').css({
      'width': totalThumbWidth + 'px'
    });

    $('#bestFanThumbLeftBtn').css({
      opacity: 0.3
    });
    $('#bestFanThumbRightBtn').css({
      opacity: 0.3
    });

    $('#bestFanExpandedTextOnlyBack').hide();

    $('#bestFanThumbLeftBtn').bind('mouseenter', {
      btnType: 'left'
    },
    bestFanAbOver);
    $('#bestFanThumbLeftBtn').bind('mouseleave', {
      btnType: 'left'
    },
    bestFanAbOut);
    $('#bestFanThumbLeftBtn').bind('click', {
      btnType: 'left'
    },
    bestFanAbClick);

    $('#bestFanThumbRightBtn').bind('mouseenter', {
      btnType: 'right'
    },
    bestFanAbOver);
    $('#bestFanThumbRightBtn').bind('mouseleave', {
      btnType: 'right'
    },
    bestFanAbOut);
    $('#bestFanThumbRightBtn').bind('click', {
      btnType: 'right'
    },
    bestFanAbClick);

    if ($('.bestFanExpandedThumbBlock').length < 5) {
      $('#bestFanThumbRightBtn').hide();
      $('#bestFanThumbLeftBtn').hide();
    }

    if ($('.bestFanExpandedThumbBlock').length < 4) {
      $('#bestFanExpandedThumbContainer').css({
        'margin-left': (400 - (($('.bestFanExpandedThumbBlock').length * 149) / 2)) + 'px'
      });
    }

    var thumbSetAmount = Math.ceil($('.bestFanExpandedThumbBlock').length / 4);
    var extraAmount = ($('.bestFanExpandedThumbBlock').length % 4);
    var fullSetAmount = ($('.bestFanExpandedThumbBlock').length - extraAmount) / 4;
    leftOverBestFanThumbAmount = ((fullSetAmount - 1) * 4) + (extraAmount);

    var bfPlArray = [];
    bfPlArray.push(unescape($('.bestFanExpandedThumb img:first').attr('alt').split("*-*")[0]));
    $('.bestFanExpandedThumb img').each(function() {
      bfPlArray.push($(this).attr('src'));
    });

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      preloadBestFan(bfPlArray);
    } else {
      setbestFanClicked(0);
      $('.bestFanExpandedThumbBlock:first').click();
    }

  }
  
	//preloads the best fan images so they can fade in nicely
  function preloadBestFan(arr) {
    jQuery.imgpreload(arr, {
      all: function() {
        bestFanIntro();
      }
    });
  }
  
	//the intro for the expanded Best Fan module
  function bestFanIntro() {
    bfFirstClick = true;

    $('#mainLoader').remove();

    $('#moduleContainer').before('<div id="bfFlashOverlay"></div>');
    if ($(document).width() < 1240) {
      $('#bfFlashOverlay').css({
        'width': '1230px'
      });
    } else {
      $('#bfFlashOverlay').css({
        'width': '100%'
      });
    }

    if ($(document).height() <= 965) {
      $('#bfFlashOverlay').css({
        'height': '965px'
      });
    } else {
      $('#bfFlashOverlay').css({
        'height': '100%'
      });
    }

    $('#moduleContainer').css({
      opacity: 1.0
    });

    $('#bfFlashOverlay').stop(true, true).animate({
      opacity: 'hide'
    },
    {
      duration: 500,
      complete: function() {
        $('#bfFlashOverlay').remove()
      },
      specialEasing: {
        opacity: 'easeOutSine'
      }
    });

    setbestFanClicked(0);
    $('#bestFanExpandedBadgeContainer').css({
      opacity: 0.0
    });
    $('.bestFanExpandedThumbBlock:first').click();
  }
  
	//the rollover function for the Best Fan thumbnail arrows
  function bestFanAbOver(e) {
    $(this).stop(true, true).animate({
      opacity: 1.0
    },
    {
      duration: 200,
      specialEasing: {
        opacity: 'easeOutSine'
      }
    });
  }
  
	//the rollout function for the Best Fan thumbnail arrows
  function bestFanAbOut(e) {
    $(this).stop(true, true).animate({
      opacity: 0.3
    },
    {
      duration: 500,
      specialEasing: {
        opacity: 'easeOutSine'
      }
    });
  }
  
	//the click function for the Best Fan thumbnail arrows
  function bestFanAbClick(e) {
    var dir = e.data.btnType;
    moveBestFanThumbs(dir)
  }
  
	//moves the Best Fan thumbnails when the arrows are clicked
  function moveBestFanThumbs(dir) {
    var moveOffset = 0;
    if ($('.bestFanExpandedThumbBlock').length % 4 != 0)
    {
      moveOffset = 4 - ($('.bestFanExpandedThumbBlock').length % 4);
    }

    var shouldAnimate = false;
    if (dir == 'left') {
      if (bestFanThumbMoveInt > 0) {
        bestFanThumbMoveInt--;
        shouldAnimate = true;
      }
    }

    if (dir == 'right') {
      if (bestFanThumbMoveInt < leftOverBestFanThumbAmount) {
        bestFanThumbMoveInt++;
        shouldAnimate = true;
      }
    }

    $('#bestFanExpandedThumbInner').stop(true, true).animate({
      marginLeft: -(bestFanThumbMoveInt * 185) + 20
    },
    {
      duration: 500,
      specialEasing: {
        marginLeft: 'easeInOutExpo'
      }
    });

    checkButtons();
  }
  
	//checks thumbnail positions and "disables" the
	//arrow buttons based on their positions
  function checkButtons() {
    if (bestFanThumbMoveInt == leftOverBestFanThumbAmount) {
      //$('#bestFanThumbRightBtn').css({opacity : 0.3});
    } else {
      //$('#bestFanThumbRightBtn').css({opacity : 1.0});
    }

    if (bestFanThumbMoveInt == 0) {
      //$('#bestFanThumbLeftBtn').css({opacity : 0.3});
    } else {
      //$('#bestFanThumbLeftBtn').css({opacity : 1.0});
    }
  }
  
	//the rollover function for the Best Fan thumbnails
  function bestFanEtOver() {

    $(this).find('.bestFanExpandedThumb').css({
      'box-shadow': '0 0 15px #ffffff'
    });
    $(this).find('.bestFanExpandedThumbTitle').stop(true, true).animate({
      color: '#055fc8'
    },
    {
      duration: 300,
      specialEasing: {
        color: 'easeOutSine'
      }
    });
  }
  
	//the rollout function for the Best Fan thumbnails
  function bestFanEtOut() {

    if ($(this).attr('class').indexOf('bestFantSelected') == -1) {
      $(this).find('.bestFanExpandedThumb').css({
        'box-shadow': '0 0 0px #ffffff'
      });
      $(this).find('.bestFanExpandedThumbTitle').stop(true, true).animate({
        color: '#666666'
      },
      {
        duration: 300,
        specialEasing: {
          color: 'easeOutSine'
        }
      });
    }
  }
  
	//the click function for the Best Fan thumbnails
  function bestFanEtClick(e) {
    var type = $(this).attr('class').split(' ')[1];
    var contentString = '';
    var contentUrl = unescape($(this).find('.bestFanExpandedThumb img').attr('alt').split("*-*")[0]);
    var titleText = unescape($(this).find('.bestFanExpandedThumbTitle').html());
    var descText = unescape($(this).find('.bestFanExpandedThumb img').attr('alt').split("*-*")[1]);
    var iconString = '';

    setbestFanClicked(e.data.ind);

    if (type == 'bestFanImage') {
      contentString += '<img src="' + contentUrl + '" />';
      iconString = '<img src="' + 'wp-content/themes/snapple/images/module_news/news-photo-icon.png' + '" />';
    }

    if (type == 'bestFanVideo') {
      contentString += contentUrl;
      iconString = '<img src="' + 'wp-content/themes/snapple/images/module_news/news-film-icon.png' + '" />';
    }

    if (type == 'bestFanText') {
      descText = contentUrl;
      iconString = '<img src="' + 'wp-content/themes/snapple/images/module_news/news-text-icon.png' + '" />';
    }

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {


      $('#bestFanExpandedImageContent').stop(true, true).animate({
        opacity: 0.0
      },
      {
        duration: 300,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });

      $('#bestFanExpandedTextContainer').stop(true, true).animate({
        opacity: 0.0
      },
      {
        duration: 300,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });

    } else {
      $('#bestFanExpandedImageContent').hide();
      $('#bestFanExpandedTextContainer').hide();
    }

    if (type == 'bestFanText') {

      if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
        $('#bestFanExpandedImageBack').stop(true, true).animate({
          opacity: 'hide'
        },
        {
          duration: 300,
          specialEasing: {
            opacity: 'easeOutSine'
          }
        });

        $('#bestFanExpandedTextBack').stop(true, true).animate({
          opacity: 'hide'
        },
        {
          duration: 300,
          specialEasing: {
            opacity: 'easeOutSine'
          }
        });

        $('#bestFanCloseBtn').stop(true, true).animate({
          opacity: 'hide'
        },
        {
          duration: 300,
          specialEasing: {
            opacity: 'easeOutSine'
          }
        });

        $('#bestFanExpandedBadgeContainer').stop(true, true).animate({
          opacity: 'hide'
        },
        {
          duration: 300,
          specialEasing: {
            opacity: 'easeOutSine'
          }
        });

      } else {
        $('#bestFanExpandedTextBack').hide();
        $('#bestFanExpandedImageBack').hide();
        $('#bestFanCloseBtn').hide();
        $('#bestFanExpandedBadgeContainer').hide();
      }
    }

    setTimeout(function() {
      setbestFanContent(contentString, type, contentUrl, titleText, descText, iconString);
    },
    300)
  }
  
	//sets the proper content for the Best Fan module when a thumbnail is clicked
  function setbestFanContent(contentString, type, contentUrl, titleText, descText, iconString) {
    $('#bestFanExpandedImageContent').html(contentString);
    $('#bestFanExpandedTextTitle').html(titleText);
    $('#bestFanExpandedTextContent').html(descText);
    $('#bestFanExpandedTextIcon').html(iconString);

    $('#bestFanCloseBtn').stop(true, true).show();
    $('#bestFanExpandedBadgeContainer').stop(true, true).show();
    $('#bestFanExpandedTextContainer').stop(true, true).show();

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#bestFanCloseBtn').stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 300,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });

      $('#bestFanExpandedBadgeContainer').stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 300,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });

      $('#bestFanExpandedTextContainer').stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 500,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });

      $('#bestFanExpandedImageContent').stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: bfiFadeTime,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });
    }

    var bfiFadeTime = 500;
    if (bfFirstClick == true) {
      bfiFadeTime = 6000
    }

    $('#bestFanExpandedImageContent').stop(true, true).show();


    if (type != 'bestFanText') {

      $('#bestFanExpandedTextContainer').css({
        'left': '415px',
        'width': '425px',
        'height': '250px'
      });
      $('#bestFanExpandedTextTitle').css({
        'width': '345px'
      });
      $('#bestFanExpandedTextContent').css({
        'width': '345px'
      });
      $('#bestFanExpandedTextContent').css({
        'height': '100px'
      });
      $('#bestFanExpandedTextBack').css({
        'left': '430px'
      });
      $('#bestFanExpandedTextContainer').css({
        'left': '410px'
      });
      $('#bestFanCloseBtn').css({
        'left': '840px'
      });
      $('#bestFanExpandedBadgeContainer').css({
        'left': '452px'
      });

      if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
        $('#bestFanExpandedImageBack').show();
        $('#bestFanExpandedImageBack').stop(true, true).animate({
          opacity: 1.0
        },
        {
          duration: 300,
          specialEasing: {
            opacity: 'easeOutSine'
          }
        });

      } else {
        $('#bestFanExpandedImageBack').show();
      }

      bfFirstClick = false;
    }

    if (type == 'bestFanText') {

      $('#bestFanExpandedTextContainer').css({
        'left': '275px',
        'width': '385px',
        'height': '358px'
      });
      $('#bestFanExpandedTextTitle').css({
        'width': '365px'
      });
      $('#bestFanExpandedTextContent').css({
        'width': '365px'
      });
      $('#bestFanExpandedTextBack').css({
        'left': '250px'
      });
      $('#bestFanExpandedTextContainer').css({
        'left': '220px'
      });
      $('#bestFanCloseBtn').css({
        'left': '660px'
      });
      $('#bestFanExpandedBadgeContainer').css({
        'left': '272px'
      });
    }

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#bestFanExpandedTextBack').stop(true, true).show();
      $('#bestFanExpandedTextBack').stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 300,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });
    } else {
      $('#bestFanExpandedTextBack').show();
    }

  }
  
	//sets a thumbnail as "clicked" in the Best Fan module
  function setbestFanClicked(num) {
    $('.bestFanExpandedThumbBlock').each(function(ind) {
      if (ind == num) {
        $(this).addClass('bestFantSelected');
        $(this).find('.bestFanExpandedThumb').css({
          'box-shadow': '0 0 15px #ffffff'
        });
        $(this).find('.bestFanExpandedThumbTitle').stop(true, true).animate({
          color: '#055fc8'
        },
        {
          duration: 300,
          specialEasing: {
            color: 'easeOutSine'
          }
        });
      } else {
        $(this).removeClass('bestFantSelected');
        $(this).find('.bestFanExpandedThumb').css({
          'box-shadow': '0 0 0px #ffffff'
        });
        $(this).find('.bestFanExpandedThumbTitle').stop(true, true).animate({
          color: '#666666'
        },
        {
          duration: 300,
          specialEasing: {
            color: 'easeOutSine'
          }
        });
      }
    });
  }

  //the outro for the expanded Campaigns module
  function campaignsOutro() {

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {

      $('#campaignsExpandedContent').html('');
      $('#moduleContainer').stop(true, true).animate({
        top: $(window).height() - curTopOffset
      },
      {
        duration: 300,
        specialEasing: {
          top: 'easeOutExpo'
        }
      });
    } else {
      $('#moduleContainer').hide();
    }

  }
  
	//sets up content for the expanded Campaigns module
  function setupCampaignsExpanded() {
    $('.campaignsExpandedThumbBlock').each(function(ind) {
      $(this).bind('mouseenter', {
        ind: ind
      },
      campaignsetOver);
      $(this).bind('mouseleave', {
        ind: ind
      },
      campaignsetOut);
      $(this).bind('click', {
        ind: ind
      },
      campaignsetClick);
    });

    setCampaignsClicked(0);
    $('.campaignsExpandedThumbBlock:first').click();

    $('#campaignsExpandedThumbContainer').mouseMoveMenu({
      containerDiv: 'campaignsExpandedThumbContainer',
      scrollDiv: 'campaignsExpandedThumbInner',
      offset: 8
    });

    $('#campaignsExpandedStatic').hide();
  }
  
	//the rollover function for the expanded Campaigns module thumbnails
  function campaignsetOver() {
    $(this).find('.campaignsExpandedThumbTitle').stop(true, true).animate({
      color: '#e7e7e7'
    },
    {
      duration: 300,
      specialEasing: {
        color: 'easeOutSine'
      }
    });
  }
  
	//the rollout function for the expanded Campaigns module thumbnails
  function campaignsetOut() {
    if ($(this).attr('class').indexOf('campaignstSelected') == -1) {
      $(this).find('.campaignsExpandedThumbTitle').stop(true, true).animate({
        color: '#666666'
      },
      {
        duration: 300,
        specialEasing: {
          color: 'easeOutSine'
        }
      });
    }
  }
   
	//the click function for the expanded Campaigns module thumbnails
  function campaignsetClick(e) {
    var type = $(this).attr('class').split(' ')[1];
    var contentUrl = unescape($(this).find('.campaignsExpandedThumb img').attr('alt'));
    var titleText = unescape($(this).find('.campaignsExpandedThumbTitle').html());

    setCampaignsClicked(e.data.ind);

    $('#campaignsExpandedStatic').show();

    $('#campaignsExpandedContent').stop(true, true).animate({
      opacity: 0.0
    },
    {
      duration: 300,
      specialEasing: {
        opacity: 'easeOutSine'
      }
    });

    setTimeout(function() {
      setCampaignsContent(type, contentUrl, titleText);
    },
    300);
  }
  
	//sets the proper content for the expanded Campaigns module
  function setCampaignsContent(type, contentUrl, titleText) {
    $('#campaignsExpandedContent').html(contentUrl);
    $('#campaignsExpandedContent').stop(true, true).animate({
      opacity: 1.0
    },
    {
      duration: 500,
      specialEasing: {
        opacity: 'easeOutSine'
      }
    });
  }
  
	//sets a thumbnail as "clicked" for the expanded Campaigns module
  function setCampaignsClicked(num) {
    $('.campaignsExpandedThumbBlock').each(function(ind) {
      if (ind == num) {
        $(this).addClass('campaignstSelected');
        $(this).find('.campaignsExpandedThumbTitle').stop(true, true).animate({
          color: '#e7e7e7'
        },
        {
          duration: 300,
          specialEasing: {
            color: 'easeOutSine'
          }
        });
      } else {
        $(this).removeClass('campaignstSelected');
        $(this).find('.campaignsExpandedThumbTitle').stop(true, true).animate({
          color: '#666666'
        },
        {
          duration: 300,
          specialEasing: {
            color: 'easeOutSine'
          }
        });
      }
    });
  }

  //the outro function for the expanded Pursuit of Bestness module 
  function pobOutro() {
    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#pobExpandedInner').stop(true, true).animate({
        rotate: '-7deg'
      },
      500);
    }

    $('#pobExternalPageContentInner').html('');

    $('#moduleContainer').stop(true, true).animate({
      top: -880
    },
    {
      duration: 1000,
      specialEasing: {
        top: 'easeInOutExpo'
      }
    });
  }
  
	//the intro function for the expanded Pursuit of Bestness module
  function pobIntro() {
    pobIntroTimeout = setTimeout(pobIntro1, 100)
  }
  
	//Another intro function for the expanded Pursuit of Bestness module,
	//makes the "frame" swing
  function pobIntro1() {
    $('#pobExpandedInner').stop(true, true).animate({
      rotate: '3deg'
    },
    300);
    pobIntroTimeout = setTimeout(pobIntro2, 300)
  }
  
	//Another intro function for the expanded Pursuit of Bestness module
	//makes the "frame" swing
  function pobIntro2() {
    $('#pobExpandedInner').stop(true, true).animate({
      rotate: '-2deg'
    },
    300);
    pobIntroTimeout = setTimeout(pobIntro3, 300)
  }
  
	//Another intro function for the expanded Pursuit of Bestness module
	//makes the "frame" swing
  function pobIntro3() {
    $('#pobExpandedInner').stop(true, true).animate({
      rotate: '1deg'
    },
    400);
    pobIntroTimeout = setTimeout(pobIntro4, 400)
  }
  
	//Another intro function for the expanded Pursuit of Bestness module
	//makes the "frame" swing
  function pobIntro4() {
    $('#pobExpandedInner').stop(true, true).animate({
      rotate: '0deg'
    },
    500);
    pobIntro5();
  }
  
	//When the frame is done swinging, load in the correct content vie iFrame.  The iFrame
	//url is in a div element #pobExternalPageContentInner
  function pobIntro5() {
    $('#pobExternalPageContentInner').html(pobIframeSrc);
  }

  //the outro function for the expanded Promotions module
  function promotionsOutro() {
    $('#promotionsExpandedCloseBtn').hide();
    $('#promotionsExpandedPrevBtn').hide();
    $('#promotionsExpandedNextBtn').hide();
    $('#promotionsExpandedShareIcons').hide();

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#moduleContainer').stop(true, true).animate({
        opacity: 0.0
      },
      {
        duration: 300,
        specialEasing: {
          top: 'easeOutExpo'
        }
      });
    } else {
      $('#promotionsExpandedCloseBtn').hide();
    }

    $('#promotionsExternalPageContent').html('');
  }
  
	//the intro function for the expanded Promotions module
  function promotionsIntro() {
    firstPromotion = true;

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#moduleContainer').stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 300,
        specialEasing: {
          top: 'easeOutExpo'
        }
      });

      setTimeout(promotionsIntro2, 100);
    } else {
      $('#promotionsExpandedCloseBtn').show();
    }

    promotionsArray = [];
    promotionInt = 0;

    $('.promotionsExpandedBlock').each(function() {
      promotionsArray.push($(this));
    });

    $('#promotionsExpandedPrevBtn').hide();
    $('#promotionsExpandedNextBtn').hide();

    if (promotionsArray.length > 1) {
      $('#promotionsExpandedPrevBtn').bind('click', pepClick);
      $('#promotionsExpandedNextBtn').bind('click', penClick);
      setTimeout(function() {
        $('#promotionsExpandedPrevBtn').show().css({
          opacity: 0.0
        });
        $('#promotionsExpandedNextBtn').show().css({
          opacity: 0.0
        });
        $('#promotionsExpandedPrevBtn, #promotionsExpandedNextBtn').stop(true, true).animate({
          opacity: 1.0
        },
        {
          duration: 500,
          specialEasing: {
            opacity: 'easeOutExpo'
          }
        });
      },
      300)
    }

    showPromotion();
  }

	//the second part of the promotions intro
  function promotionsIntro2() {
    $('#promotionsExpandedCloseBtn').show();
    $('#promotionsExpandedCloseBtn').css({
      opacity: 0.0
    });
    $('#promotionsExpandedCloseBtn').stop(true, true).delay(300).animate({
      opacity: 1.0
    },
    {
      duration: 500,
      specialEasing: {
        opacity: 'easeOutExpo'
      }
    });

    $('#promotionsExpandedShareIcons').show();


    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#promotionsExpandedShareIcons').css({
        opacity: 0.0
      });
      $('#promotionsExpandedShareIcons').stop(true, true).delay(300).animate({
        opacity: 1.0
      },
      {
        duration: 500,
        specialEasing: {
          top: 'easeOutExpo'
        }
      });
    }
  }
  
	//the left arrow click for the expanded Promotions module
  function pepClick(e) {
    promotionInt--;

    if (promotionInt < 0) {
      promotionInt = promotionsArray.length - 1;
    }

    showPromotion();
  }
  
	//the right arrow click for the expanded Promotions module
  function penClick(e) {
    promotionInt++;

    if (promotionInt > promotionsArray.length - 1) {
      promotionInt = 0;
    }

    showPromotion();
  }
  
	//selects the proper promotions card to animate in
  function showPromotion() {
    $('.promotionsExpandedBlock').hide();
    promotionsArray[promotionInt].show();
    $('#promotionsExpandedTransBg').css({
      'z-index': '800'
    }).show();

    if (firstPromotion == false) {
      promotionsChangeTransition();
    } else {
      $('#promotionsExpandedTransBg').css({
        'z-index': '400',
        'top': '10px'
      });
    }

    firstPromotion = false;

  }
  
	//animates a promotion "card" in
  function promotionsChangeTransition() {
    $('#promotionsExpandedTransBg').stop(true, true).delay(100).animate({
      top: -640
    },
    {
      duration: 300,
      specialEasing: {
        top: 'easeOutExpo'
      }
    });

    setTimeout(promotionsChangeTransition2, 400);
  }
  
	//part 2 of the "card" animation
  function promotionsChangeTransition2() {
    $('#promotionsExpandedTransBg').css({
      'z-index': '400'
    });
    $('#promotionsExpandedTransBg').stop(true, true).animate({
      top: 10
    },
    {
      duration: 300,
      specialEasing: {
        top: 'easeOutExpo'
      }
    });

    setTimeout(hideTransitionBg, 300);
  }
  
	//hides the transition card
  function hideTransitionBg() {
    $('#promotionsExpandedTransBg').hide();
  }

  //the outro function for the expanded Real Facts module
  function realFactsIntro() {
    curModuleAd = 'real-facts';

    showRealFactsExContent();

    $('#realFactsGameOverlay').css({
      opacity: 0.0
    }).hide();

    $('#realFactsGameTextBtn').bind('click', rfgtClick);
    if (curBrowser.indexOf('msie 8.0') == -1 && isMobile == false) {
      $('#realFactsGameTextBtn').bind('mouseenter', rfgtOver);
      $('#realFactsGameTextBtn').bind('mouseleave', rfgtOut);
    }

    $('#realFactsGameOverlay').bind('click', rfgoFc);

    $('#realFactsGameOverlay').show();
    $('#realFactsGameOverlay').css({
      opacity: 0.8
    });

    $('#realFactsSignupText').hide();
    $('#realFactsPhone').hide();
    $('#realFactsTextHeader').hide();

    $('#realFactsGameStartBtn').bind('click', rfgoFc);

  }
  
	//the click function for the overlay in the expanded Real Facts pod
  function rfgoFc() {
    clearTimeout(rfoTo);

    $('#moduleContent').snappleMemoryGame();
    $('#realFactsGameOverlay').unbind();
    $('#realFactsGameOverlay').bind('click', rfgtOverlayClick);
    $('#realFactsGameOverlay').hide();

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#realFactsPopup').stop(true, true).animate({
        opacity: 0.0
      },
      {
        duration: 1000,
        specialEasing: {
          opacity: 'easeOutExpo'
        }
      });
      rfoTo = setTimeout(function() {
        $('#realFactsPopup').hide();
      },
      1000)
    } else {
      $('#realFactsPopup').hide();
    }
  }
  
	//the rollover function for the text button in the expanded Real Facts pod
  function rfgtOver(e) {
    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $(this).stop(true, true).animate({
        opacity: 0.8
      },
      {
        duration: 200,
        specialEasing: {
          opacity: 'easeOutExpo'
        }
      });
    }
  }
  
	//the rollout function for the text button in the expanded Real Facts pod 
  function rfgtOut(e) {
    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $(this).stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 300,
        specialEasing: {
          opacity: 'easeOutSine'
        }
      });
    }
  }
  
	//the click function for the text button in the expanded Real Facts pod 
  function rfgtClick(e) {
    clearTimeout(rfoTo);

    $('#realFactsGameContinueBtn').show();

    $('#realFactsGameOverlay').unbind();
    $('#realFactsGameOverlay').bind('click', rfgtOverlayClick);

    $('#realFactsGameContinueBtn').unbind();
    $('#realFactsGameContinueBtn').bind('click', rfgtOverlayClick);

    $('#realFactsGameOverlay').show();
    $('#realFactsGameOverlay').css({
      opacity: 0.8
    });

    $('#realFactsSignupText').show();
    $('#realFactsPhone').show();
    $('#realFactsTextHeader').show();

    $('#realFactsStartHeader').hide();
    $('#realFactsStartText').hide();
    $('#realFactsGameStartBtn').hide();

    $('#realFactsWonHeader').hide();
    $('#realFactsWonText').hide();
    $('#realFactsWonTime').hide();
    $('#realFactsGameReplayBtn').hide();

    $('#realFactsPopup').show();
    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#realFactsPopup').css({
        opacity: 0.0
      });
      $('#realFactsPopup').stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 2000,
        specialEasing: {
          opacity: 'easeOutExpo'
        }
      });
    } else {
      $('#realFactsPopup').show().css({
        'visibility': 'visible'
      });
    }

    $('#moduleContent').snappleMemoryGame('destroy');
  }
  
	//the click function for the overlay in the expanded Real Facts pod 
  function rfgtOverlayClick(e) {
    clearTimeout(rfoTo);
    $('#realFactsGameOverlay').hide();
    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#realFactsPopup').stop(true, true).animate({
        opacity: 0.0
      },
      {
        duration: 1000,
        specialEasing: {
          opacity: 'easeOutExpo'
        }
      });
      rfoTo = setTimeout(function() {
        $('#realFactsPopup').hide();
      },
      1000)
    } else {
      $('#realFactsPopup').hide();
    }

    $('#moduleContent').snappleMemoryGame({
      reset: true
    });

  }
  
	//the outro for the expanded Real Facts pod 
  function realFactsOutro() {

    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#moduleContainer').stop(true, true).animate({
        opacity: 0.0
      },
      {
        duration: 500,
        specialEasing: {
          top: 'easeOutExpo'
        }
      });
    } else {
      $('#moduleContainer').hide();
    }

    setTimeout(function() {
      $('#moduleOverlay').hide()
    },
    500);
  }
  
	//the second part of the outro for the expanded Real Facts pod 
  function realFactsOutro2() {
    rfCapInInt = 0;
    rfCapOutInt = 0;

    $('#moduleContainer').after('<div id="realFactsOverlay"></div>');

    if ($(document).width() < 1240) {
      $('#realFactsOverlay').css({
        'width': '1230px'
      });
    } else {
      $('#realFactsOverlay').css({
        'width': '100%'
      });
    }

    if ($(window).height() <= 945) {
      $('#realFactsOverlay').css({
        'height': '945px'
      });
    } else {
      $('#realFactsOverlay').css({
        'height': '100%'
      });
    }

    rfCapOverlayDiv = Math.floor($('#realFactsOverlay').height() / 195);
    addRealFactsTransitionStrip();
    startRealFactsTransition();
  }
  
	//functions for an old transition, no longer used.  Kept here just in case.
  function addRealFactsTransitionStrip() {
    $('#realFactsOverlay').append('<div class="realFactsTransitionStrip" style="top:' + (rfCapInInt * 195) + 'px;"></div>');
  }

  function removeRealFactsTransitionStrip() {
    $('.realFactsTransitionStrip:eq(0)').remove();
  }

  function startRealFactsTransition() {
    realFactsTransitionInt = setInterval(rfCapsIn, 100);
  }

  function endRealFactsTransition() {
    removeRealFactsTransitionStrip();
    realFactsTransitionInt = setInterval(rfCapsOut, 100);
  }

  function rfCapsIn() {
    rfCapInInt++;
    addRealFactsTransitionStrip();
    if (rfCapInInt == rfCapOverlayDiv) {
      clearInterval(realFactsTransitionInt);
      endRealFactsTransition();
    }
  }

  function rfCapsOut() {
    rfCapOutInt++;
    removeRealFactsTransitionStrip();
    if (rfCapOutInt == rfCapOverlayDiv) {
      clearInterval(realFactsTransitionInt);
      $('#realFactsOverlay').remove();
      if ($.address.value() == '/real-facts') {
        showRealFactsExContent();
      }
    }
  }
  
	//shows the content for the Real Facts expanded pod
  function showRealFactsExContent() {
    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#moduleContainer').stop(true, true).stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 500,
        specialEasing: {
          top: 'easeOutExpo'
        }
      });
    } else {
      $('#moduleContainer').show();
    }

    positionRfOverlay();

    $('#realFactsPopup').show();
    if (curBrowser.indexOf('msie 8.0') == -1 && curBrowser.indexOf('msie 7.0') == -1) {
      $('#realFactsPopup').css({
        opacity: 0.0
      });
      $('#realFactsPopup').stop(true, true).animate({
        opacity: 1.0
      },
      {
        duration: 2000,
        specialEasing: {
          opacity: 'easeOutExpo'
        }
      });
    } else {
      $('#realFactsPopup').show().css({
        'visibility': 'visible'
      });
      $('#realFactsPopup').css({
        opacity: 1.0
      });
    }
  }
  
	//the click function for hidden Caps
  function setCaps() {
    $('.hiddenCap').bind('click', pobCapClick);
  }
  
	//the click function for Pursuit of Bestness Caps
  function pobCapClick(e) {
    var hrAr = $(this).find('a').attr('href').split('/');
    var code = hrAr[hrAr.length - 1];
    $.address.value('/pursuit-of-bestness/' + code);
    return false;
  }
  
	//positions the spinning cap preloader (not currently used)
  function positionCapLoader() {
    var lp = ($(window).width() / 2) - 130;
    if ($(window).width() < 1230) {
      lp = 500;
    }

    var tp = ($(window).height() / 2) - 90;
    if ($(window).height() < 945) {
      tp = 383;
    }

    $('#capLoader').css({
      'top': tp + 'px',
      'left': lp + 'px'
    });
  }
  
	//spins the loading caps
  function spinLoadingCap() {

    rflFrameInt++;

    if (rflFrameInt > 5) {
      rflFrameInt = 0;
      rflSpinSetInt++;
    }

    var lPos = 0;

    switch (rflFrameInt) {
    case 0:
      lPos = -2;
      break;
    case 1:
      lPos = -200;
      break;
    case 2:
      lPos = -400;
      break;
    case 3:
      lPos = -600;
      break;
    case 4:
      lPos = -800;
      break;
    case 5:
      lPos = -1000;
      break;
    default:
      lPos = -2;
      break;
    }

    $('#capLoader').css({
      'background-position': String(lPos) + 'px 0px'
    });
  }

  //calls the proper method based on the string passed 
  $.fn.snappleModule = function(method) {
    if (methods[method]) {
      return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
    } else if (typeof method === 'object' || !method) {
      return methods.init.apply(this, arguments);
    } else {
      $.error('Method ' + method + ' does not exist on snappleModule');
    }
  };

})(jQuery);
