 $.fn.smartBackgroundImage = function(url){
  var t = this;
  //create an img so the browser will download the image:
  $('<img />')
    .attr('src', url)
    .load(function(){ //attach onload to set background-image
       t.each(function(){
          $(this).css('backgroundImage', 'url('+url+')' ).fadeIn();
       });
    });
   return this;
 }


$(document).ready(function(){
    $("ul.sf-menu").supersubs({
        minWidth:    12,   // minimum width of sub-menus in em units
        maxWidth:    27,   // maximum width of sub-menus in em units
        extraWidth:  1     // extra width can ensure lines don't sometimes turn over
    // due to slight rounding differences and font-family
    }).superfish({
        autoArrows: false,
        dropShadows: true
    });

    //Default Action
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content

    //On Click Event
    $("ul.tabs li").click(function() {
        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        return false;
    });

    $(".wines ul.tabs li").click(function() {
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn('fast',function() {$.scrollTo('#tabs');}); //Fade in the active content
    })


    $('.read-more').click(function() {
        $(this).next('div').show();
        $(this).hide();
        return false;
    });
    $('.close-more').click(function() {
        $(this).parent('div').hide();
        $(this).parent().prev('a.read-more').show();
        return false;
    });

    $('a.details').click(function() {
        $(this).next('div').toggle();
        return false;
    })

});


