var open = false; //set footer pop up to true.
$(document).ready(function () {
    init();
    pipeNav();
    borderRemove();
    $('a.outbound').click(function () {
        var $a = $(this);
        var href = $a.attr('href');
        var category = 'outbound'; // set this to whatever you want
        var event = 'click'; // set this to whatever you want
        var label = href; // set this to whatever you want
        _gaq.push(['_trackEvent', category, event, href]);
        setTimeout('document.location = "' + href + '"', 200);
    });
});

function init() {
    Cufon.replace('.tagList li');
    Cufon.replace('h1');
    Cufon.replace('h2');
    Cufon.replace('h3', {
        hover: true
    });
    Cufon.replace('#newsletter_button');
    directoryListingsSlider();
    newsletterModal();
}

function pipeNav() {
    $("#top_nav ul li:last-child, #footer_nav ul li:first-child").css('border', 'none');
}

function borderRemove() {
    $('.articles table tr:last-child td').css('border-bottom', 'none');
}

function directoryListingsSlider() {
    if ($('#slider').length) {
        $("#slider").easySlider({
            auto: true,
            continuous: true,
            pause: 3000,
            controlsShow: false
        });
    }
}

function newsletterModal() {
    /* newsletter handlers */
    $('#newsletter_button').click(function (e) {
        $('#newsletter_modal').modal({
            overlayClose: true,
            zIndex: 9999999,
            onOpen: function (dialog) {
                dialog.overlay.fadeIn('slow', function () {
                    dialog.container.slideDown('slow', function () {
                        dialog.data.fadeIn('slow');
                        //_gaq.push(['_trackEvent', 'Newsletter Sign-up', 'Click']);
                    });
                });
            },
            onClose: function (dialog) {
                dialog.data.fadeOut('slow', function () {
                    dialog.container.slideUp('slow', function () {
                        dialog.overlay.fadeOut('slow', function () {
                            $.modal.close(); // must call this!
                        });
                    });
                });
            }
        });
        return false;
    });
}
