
/***
discover section scripts
***/

// set bar order for thumbnail hover
var barThumbs = new Array(
	"", // leave empty to start counting at 1
	"99-cocoa",
	"90-cocoa",
	"85-cocoa",
	"70-cocoa",
	"almond-brittle",
	"nut-crunch",
	"sweet-dark",
	"intense-orange",
	"sea-salt",
	"chili",
	"intense-mint",
	"black-currant",
	"cranberry",
	"roasted-almond",
	"white-coconut",
	"vanilla",
	"extra-creamy",
	"toffee-crunch"
);

var total_bars = barThumbs.length - 1;

$(document).ready(function(){
	
	// previous/next arrows
	$("div#nextThumb").css({opacity: 0});
	$("div#previousThumb").css({opacity: 0});
	
		// previous/next clicks
		$("ul#prevNextArrows li#previousBar a").click(
			function(){
				if ( currentBar == 1 ){
					$(this).attr({ href: "excellence-" + barThumbs[total_bars] + ".php" });
				} else {
					$(this).attr({ href: "excellence-" + barThumbs[currentBar-1] + ".php" });
				}		
			}
		);
		$("ul#prevNextArrows li#nextBar a").click(
			function(){
				if ( currentBar == total_bars ){
					$(this).attr({ href: "excellence-" + barThumbs[1] + ".php" });
				} else {
					$(this).attr({ href: "excellence-" + barThumbs[currentBar+1] + ".php" });
				}		
			}
		);
		
		// hover effect to show previous/next bar thumbnail
		$("ul#prevNextArrows li#previousBar a").hover(
			// mouseover
			function(){
				if ( currentBar == 1 ){
					
					$("div#previousThumb")
						.css({backgroundImage: "url(../img/content/bar-thumb-" + barThumbs[total_bars] + ".gif)"})
						.animate({opacity: 1},{queue: false, duration: 250});
				} else {
					
					$("div#previousThumb")
						.css({backgroundImage: "url(../img/content/bar-thumb-" + barThumbs[currentBar-1] + ".gif)"})
						.animate({opacity: 1},{queue: false, duration: 250});
				}
			},
			// mouseout
			function(){
				$("div#previousThumb").animate({opacity: 0},{queue: false, duration: 250});
			}
		);
		
		$("ul#prevNextArrows li#nextBar a").hover(
			// mouseover
			function(){
				if ( currentBar == total_bars ){
					
					$("div#nextThumb")
						.css({backgroundImage: "url(../img/content/bar-thumb-" + barThumbs[1] + ".gif)"})
						.animate({opacity: 1},{queue: false, duration: 250});				
				} else {
					
					$("div#nextThumb")
						.css({backgroundImage: "url(../img/content/bar-thumb-" + barThumbs[currentBar+1] + ".gif)"})
						.animate({opacity: 1},{queue: false, duration: 250});
				}
			},
			// mouseout
			function(){
				$("div#nextThumb").animate({opacity: 0},{queue: false, duration: 250});
			}
		);


	// bar packaging hover effect
		
		// preload nutritional facts
		/* $("div#barPackage").hover(
			function(){
				$("div#back").css({top: "0px"});
				$("div#front").animate({opacity: 0}, {queue: false, duration: 500});
			},
			function(){$("div#front").animate({opacity: 1}, {queue: false, duration: 500});}
		); */
	
	// bar link adjustments	
	$("ul#barBottomLinks li:last").css({borderLeft: "1px solid #513933", paddingRight: "0px"});
	
});

