function closePopup() {
    jQuery.unblockUI();
}

//jQuery
jQuery(function() {
  //make all external links open in a new window (page 57)
  jQuery("a[href^=http://]").attr("target","_blank");

  //Exit Disclaimer
  jQuery("a[href^=http://]").click(function() {
      var href=jQuery(this).attr("href");
      var alt=jQuery(this).attr("alt");
      var nobr=jQuery(this).attr("nobr");
      var takenTo=((nobr==null || nobr=="0" || nobr=="false") ? ":<br />" : " ") + "<b>" + ((alt==null) ? href : alt) + "</b>";

      if (takenTo != "bypass") {
      jQuery.blockUI({ 
      message: "<div class=\"exitPopup\"><p>Thank you for visiting JJDentalProfessional.com</p><p>By clicking 'Continue', you will be taken to" + takenTo + "</p><p>This is a Web site to which our Privacy Policy does not apply. You are solely responsible for your interactions with such Web sites.</p><p><a href=\"" + href + "\" target=\"_blank\" onclick=\"closePopup();\">Continue</a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href=\"javascript:closePopup();\">Cancel</a></p></div>",
      
      css: {  
        width:          '590px', 
        padding:        '10px', 
        margin:         0,   
        color:          '#333', 
        textAlign:      'left', 
        border:         '1px solid #999', 
        backgroundColor:'#fff', 
        cursor:         'wait' 
      }, 
      
      // styles for the overlay 
      overlayCSS:  {  
        backgroundColor:'#000',  
        opacity:        '0.1'  
      }
      
      });
      return false;
      }
  });
  
  //make all links to PDFs open a new window (p23 and 57)
  jQuery("a[href$=.pdf]").attr("target","_blank");
  jQuery("a[href$=.PDF]").attr("target","_blank");
  jQuery("a[href$=.doc]").attr("target","_blank");
  jQuery("a[href$=.DOC]").attr("target","_blank");
  
  //make all links to PDFs and DOCs call Google Analytics (also requires 4 lines of code above, which open new window, to function properly)
  jQuery("a[href$=.pdf]").attr("onClick","javascript: pageTracker._trackPageview(jQuery(this).attr('href'));");
  jQuery("a[href$=.PDF]").attr("onClick","javascript: pageTracker._trackPageview(jQuery(this).attr('href'));");
  jQuery("a[href$=.doc]").attr("onClick","javascript: pageTracker._trackPageview(jQuery(this).attr('href'));");
  jQuery("a[href$=.DOC]").attr("onClick","javascript: pageTracker._trackPageview(jQuery(this).attr('href'));");
  
  //zebra-strip the 'even' rows in all tables
  jQuery("table tr:nth-child(even)").addClass("even");
  
  //add the 'first' and 'last' CSS classes to the first and last list item in each list (p67)
  jQuery("li:first").addClass("first");
  jQuery("li:last").addClass("last");
  
  // Reset Font Size
  var originalFontSize = jQuery('html').css('font-size');
  jQuery(".resetFont").click(function(){
  jQuery('html').css('font-size', originalFontSize);
  });
  // Increase Font Size
  jQuery(".increaseFont").click(function(){
    var currentFontSize = jQuery('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*1.2;
    jQuery('html').css('font-size', newFontSize);
    return false;
  });
  // Decrease Font Size
  jQuery(".decreaseFont").click(function(){
    var currentFontSize = jQuery('html').css('font-size');
    var currentFontSizeNum = parseFloat(currentFontSize, 10);
    var newFontSize = currentFontSizeNum*0.8;
    jQuery('html').css('font-size', newFontSize);
    return false;
  });
  
  //DENT-452 - links to ALTA now just open in the browser, not in shadowbox anymore.
  //references: 
  //http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._link
  //http://code.google.com/apis/analytics/docs/gaJS/gaJSApiDomainDirectory.html#_gat.GA_Tracker_._linkByPost
  jQuery("a[href=https://listerine.directdentalsales.com/StoreFront/IAFDispatcher]").click(function() {
          //DENT-506
          pageTracker._trackPageview('/buy-products.html');
          pageTracker._link(this.href);
          return false;
    });
  
  //convert all left nav and h1 (R) symbols to superscript
  var rText = '';
  jQuery('#sidebar-left a').each(function() {
    rText  = jQuery(this).text().replace('®','<sup>&reg;</sup>');
    jQuery(this).html(rText);
   });
  jQuery('h1.title').each(function() {
    rText  = jQuery(this).text().replace('®','<sup>&reg;</sup>');
    jQuery(this).html(rText);
  });
});

//Generate random number for interior page callout
function getRandom()
{
    var ranNum = Math.floor(Math.random()*14);
    return ranNum;
}

//Write the random image callout to the screen
jQuery(document).ready(function(){
    var whichImage = getRandom();
    var imageString = "";

    // images: [ image/map name, alt tag, url, rel (shadowbox) ]
    var imageArray = [
            [ 'interior-callout-fight-excuses', 'Fight excuses with the facts', '/excuse-eliminator.html', '', ''],
            [ 'interior-callout-grab-plaque', 'GRAB Even More Plaque', '/global/why-reach-flosses.html', '', '' ],
            [ 'interior-callout-eliminate-excuses', 'Help eliminate kids excuses', '/excuse-eliminator.html?category=kids', '', ''],
            [ 'interior-callout-attack-plaque', 'Attack Their Plaque', '/global/why-reach-brushes.html', '', '' ],
            [ 'interior-callout-grab-plaque-office', 'GRAB Plaque at the Office', '/global/why-reach-flosses.html', '', '' ],
            [ 'interior-callout-ultraclean', 'Effective and Easy', '/global/why-reach-flosses.html', '', '' ],
            //[ 'interior-callout-ultraclean-complete', 'Complete the ULTRACLEAN Experience', '/global/why-reach-brushes.html', '', '' ],
            [ 'interior-callout-recommend-listerine', 'Recommend Brush, Floss, LISTERINE', '/global/why-listerine.html', '', '' ],
            [ 'interior-callout-big-deal', 'Big Deal for Your Chairside', '/buy-products.html', '',  '' ],
            //[ 'interior-callout-floss-video', 'See Our New Floss In Action', '/global/why-reach-flosses.html', '', '' ],
            [ 'interior-callout-advancing-oral-care', 'Advancing Oral Care', '/global/why-listerine.html', '', '' ],
            [ 'interior-callout-big-deal-little-kids', 'Big Deal for Little Kids', '/buy-products.html', '', '' ],
            [ 'interior-callout-smart-option-little-kids', 'Smart Option for Little Kids', '/buy-products.html', '', '' ],
            //[ 'interior-callout-listerine-toothpaste', 'LISTERINE Essential Care Toothpaste', '/buy-products.html', '', '' ],
            [ 'interior-callout-total-care', '6 Benefits in One Rinse', '/listerine-total-care-landing.html', '', '' ],
            //[ 'interior-callout-less-intensity', 'Less Intensity, Equal Efficacy', '' ],
            [ 'interior-callout-seal-the-deal', 'Seal the Deal', '/global/why-listerine.html', '', '', '' ],
            [ 'interior-callout-fun-way', 'The Fun Way to Help Kids Clean Better', '/available-products.html', '', '' ]
            //[ 'interior-callout-extra-whitening', 'New! Extra Whitening Power!' ]
            //[ 'interior-callout-whitening-easier', 'Whitening Just Got Easier' ]
              
            ];
                
    for (i = 0; i < imageArray.length; i++) {
        if (i == whichImage ) {
            imageString = '<a href="' + imageArray[i][2] + '" rel="' + imageArray[i][3] + '"  onclick="' + imageArray[i][4] + '"><img src=' + '"/images/interior-callouts/' + imageArray[i][0] + '.jpg"' + 'alt="' + imageArray[i][1] + '" /></a>';
        }
    }
    
   jQuery(".interior-callouts").html(imageString);
});