﻿/* Create a namespace */
var CampbellSoup = {};

/* Brand List content scrollbar */
CampbellSoup.styleContentScroll = function() {
    $('#list-wrapper').jScrollPane({ scrollbarWidth: 150, showArrows: true });
};

/* Modal windows */
CampbellSoup.enableModalPop = function() {
    if (!($.cookie('new_look'))) {
        $('#home-overlay-modal').jqm({ modal: true, toTop: true, onShow: configureModal, target: 'div#jqmAjaxTarget', ajax: '/Content/HomeOverlay.html' }).jqmShow();
        $.cookie('new_look', 'true', { expires: 10000, path: '/' });
    }
    var configureModal = function(hash) {
        windowHeight = $(window).height();
        linkOffset = $(window).scrollTop();
        hash.w.css('top', linkOffset + (windowHeight * .1)).show();
    };
};	

/* Brand Landing preview */
CampbellSoup.brandLandingSoupSelection = function() {
    $('#brand-soups .dropdown').change(function() {
        var productURL = $('#brand-soups .dropdown option:selected').val();
        top.location.href = productURL;
    });
};

/*  Media Mind Click Tag Function */
CampbellSoup.ebConversionTracker = function(conv) {
    var ebConversionImg = new Image();
    var ebConversionURL = "HTTP://bs.serving-sys.com/BurstingPipe/ActivityServer.bs?";
    var ebRandClick = Math.random() + '';
    ebRandClick = ebRandClick * 1000000;

    ebConversionURL += "cn=as&ActivityID=" + conv + "&ns=1&rnd=" + ebRandClick;
    ebConversionImg.src = ebConversionURL;
};

/* Initialize when page is ready */
$(document).ready(function() {
    CampbellSoup.styleContentScroll();
    CampbellSoup.enableModalPop();
    CampbellSoup.brandLandingSoupSelection();
});


/*******Print function*******/

$(function printRecipe() {
    $('.flavor-crazy .print').click(function() {

        $('body').addClass('printing-recipe');
        window.print();

        setTimeout("$('body').removeClass('printing-recipe')", 500);

        //setTimeout('$("#content form").submit();', 500);

    });
});

/****************************/
