jQuery(document).ready(function ($) {
var cookie = $.readCookie('appStarted');
if(cookie){

pageTracker._trackEvent('Application', 'Home Page App Reminder', 'App Reminder Display');

$('#columnCenter').prepend('<a href="https://www.hagerty.com/Pub/network_login.aspx?Source=PreviousApplication" onClick="pageTracker._trackEvent(\'Application\', \'Home Page App Reminder\', \'App Reminder Click\');"><img id="theImg" src="/uploadedImages/Hagerty_Home_Page/Featured_Content/HomepagePlayer-returntoapp.jpg" /></a>')
} else {
    $('div.content').css('display', 'block');
    var onMouseOutOpacity = 0.67;
    $('#thumbs ul.thumbs li').opacityrollover({
        mouseOutOpacity: onMouseOutOpacity,
        mouseOverOpacity: 1.0,
        fadeSpeed: 'fast',
        exemptionSelector: '.selected'
    });
    var gallery = $('#thumbs').galleriffic({
        delay: 5500,
        numThumbs: 6,
        preloadAhead: 10,
        enableTopPager: false,
        enableBottomPager: false,
        maxPagesToShow: 7,
        imageContainerSel: '#slideshow',
        controlsContainerSel: '#controls',
        captionContainerSel: '',
        loadingContainerSel: '#loading',
        renderSSControls: true,
        renderNavControls: true,
        playLinkText: '',
        pauseLinkText: '',
        prevLinkText: '',
        nextLinkText: '',
        nextPageLinkText: 'Next ›',
        prevPageLinkText: '‹ Prev',
        enableHistory: false,
        enableKeyboardNavigation: false,
        autoStart: true,
        syncTransitions: true,
        defaultTransitionDuration: 900,
        onSlideChange: function (prevIndex, nextIndex) {
            this.find('ul.thumbs').children().eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end().eq(nextIndex).fadeTo('fast', 1.0);
        },
        onPageTransitionOut: function (callback) {
            this.fadeTo('fast', 0.0, callback);
        },
        onPageTransitionIn: function () {
            var prevPageLink = this.find('a.pageLink').css('visibility', 'hidden');
            var nextPageLink = this.find('a.pageLink').css('visibility', 'hidden');
            if (this.displayedPage > 0) prevPageLink.css('visibility', 'visible');
            var lastPage = this.getNumPages() - 1;
            if (this.displayedPage < lastPage) nextPageLink.css('visibility', 'visible');
            this.fadeTo('fast', 1.0);
        }
    });
    gallery.find('a.prev').click(function (e) {
        gallery.previousPage();
        e.preventDefault();
    });
    gallery.find('a.next').click(function (e) {
        gallery.nextPage();
        e.preventDefault();
    });

    function pageload(hash) {
        if (hash) {
            $.galleriffic.gotoImage(hash);
        } else {
            gallery.gotoIndex(0);
        }
    }
}
});
