/* Britvic Drop Down */
$(document).ready(function(){
			$("#nav-one li").hover(
				function(){ $("ul", this).fadeIn("fast"); }, 
				function() { } 
			);
	  	if (document.all) {
				$("#nav-one li").hoverClass ("sfHover");
			}
	  });
	  
		$.fn.hoverClass = function(c) {
			return this.each(function(){
				$(this).hover( 
					function() { $(this).addClass(c);  },
					function() { $(this).removeClass(c); }
				);
			});
		};
		

/* Zebra Styling on Table class - general */
$(document).ready( function() {
      $("#content #nutritional-data table").find("tr:nth-child(even)").each(
        function(i) {
          if( 0 == $(this).find("th").length ) {
            $(this).addClass("even");
          }
        }
      );
    } );

/* Anchor */
$(document).ready(function() {
	anchor.init()
});

anchor = {
	init : function()  {
		$("a.anchorLink").click(function () {	
			elementClick = $(this).attr("href")
			destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 1100 );
		  	return false;
		})
	}
}

/* FAQs */
$.fn.orphans = function(){
  var ret = [];
  this.each(function(){$.each(this.childNodes, function() {
    if (this.nodeType == 3 && $.trim(this.nodeValue)) ret.push(this)
    })}); 
   return $(ret);
}
//http://www.learningjquery.com/2008/02/simple-effects-plugins
jQuery.fn.blindToggle = function(speed, easing, callback) {
  var h = this.height() + parseInt(this.css('paddingTop')) + parseInt(this.css('paddingBottom'));
  return this.animate({marginTop: parseInt(this.css('marginTop')) < 0 ? 0 : -h}, speed, easing, callback); 
};
jQuery.fn.fadeToggle = function(speed, easing, callback) {
  return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
};
$(document).ready(function() {
//s/jq/a
    $('.expand').css('cursor','pointer').orphans().wrap('<a href="#expand/collapse" title="expand/collapse"></a>');
    $('.collapse').hide(); 
    
    $('#show .expand').click(function() {
        $(this).toggleClass("arrow-up");
        $(this).next('.normal').toggle();
        $(this).next('.slow').toggle('slow');
    });
    
    $('#slide .expand').click(function() {
        $(this).toggleClass("arrow-up");
        $(this).next('.normal').slideToggle();
        $(this).next('.slow').slideToggle('slow');
    });
    
    $('#tabbed .expand').click(function() {
        $(this).toggleClass("arrow-up");
        $(this).next('.normal').fadeToggle();
        $(this).next('.slow').fadeToggle('slow');
    });
});


/* Fade Brand Logos */
$(document).ready(function(){
$("#brands img").fadeTo("slow", 0.7); // This sets the opacity of the thumbs to fade down to 60% when the page loads

$("#brands img").hover(function(){
$(this).fadeTo("slow", 1.0); // This should set the opacity to 100% on hover
},function(){
$(this).fadeTo("slow", 0.7); // This should set the opacity back to 60% on mouseout
});
});

/* New Window */
$(function(){
$('a.external').click(function(){
window.open(this.href);
return false;
});
});




