$(document).ready(function() { 
     $('.nav-tabs ul').superfish({
        hoverClass: 'sfHover',
        delay:      1500, 
        animation:  {height:'show'},
        speed:      'fast', 
        autoArrows: false,
        pathClass:  'current'
     });   
    $('#lid-search input, #flavorfinder input').clearonfocus();
    $('.ro').hover(function() {
        var newImage = $(this).attr('src').replace(/^(.*?)(\.(?:gif|jpg|png))$/, "$1_o$2");
        $(this).attr('src', newImage);
    },
    function() {
        var newImage = $(this).attr('src').replace('_o.', '.');
        $(this).attr('src', newImage);
    });
    $('#site-switcher').change(function(){
        var newSite = $(this).val();
        if (newSite !== 'default') {
            window.open(newSite);
        }
    });
    
     $("div#shoponline:contains('Sandwiches')").css("display", "none").add("#global-landing-left #flavorfinder").css("border", "none");
     $("div#shoponline:contains('Uncrustables')").css("display", "none").add("#global-landing-left #flavorfinder").css("border", "none");
     
     
});

//Flavor Finder
function FlavorFinder() {
    var w = window.open('http://productlocator.infores.com/productlocator/resources/13/SMCK/sm_default.htm', 'pop', 'width=530,height=530,menubar=no,resizable=yes,scrollbars=yes');
}

function FlavorFinderSearch(upc, zip) {
    if (upc.toString().length <= 0 || zip.toString().length != 5) {
        FlavorFinder();
    }
    else{
        var loc = "http://productlocator.infores.com/productlocator/servlet/ProductLocator?productid=" + upc + "&zip=" + zip + "&searchradius=5&image.x=22&image.y=9&productfamilyid=SMCK&template=smuckers.xsl&clientid=13&stores=1&storespagenum=1&storesperpage=5&etailers=0&etailerspagenum=1&producttype=upc";
        var w = window.open(loc, 'pop', 'width=530,height=530,menubar=no,resizable=yes,scrollbars=yes');
    }
}

//Pop Up
function popup(url, width, height, moreAttributes) {

    if (typeof width == "undefined") {
        width = "400";
    }
    if (typeof height == "undefined") {
        height = "350";
    }
    if (typeof moreAttributes == "undefined")
    {
        moreAttributes = "menubar=no,resizable=yes,scrollbars=no";
    }

    var attributes = "width=" + width + ",height=" + height + "," + moreAttributes;

    var w = window.open(url, 'pop', attributes);
}