jQuery(document).ready(function($) {
	// Make language link accurate
	//$('#languageLink').attr('href',window.location.pathname.replace('/en/','/fr/'));

	
	// Fade In the homepage and newsletter mastheads
	$('#home #hero').delay(250).animate({'opacity':'1'});
	$('#newsletter #hero').delay(250).animate({'opacity':'1'});
	
	
	// Set the destination for the middle promo snack-size-selector
	$('.promo-2 input').change(function() {
		var href = $('.promo-2 input:checked').val();
		//alert(href);
		$('#showMeLink').attr({'href':href+'.php'});
	});
	
	
	// Share your Story
	$('#displayRules').click(function() {
		$('#rules').slideToggle();
		return false;
	});
	
	// Set up cycler on 'Good to Go'
	$('#goodtogiveCycler').cycle({
		fx: 'fade',
		speed: 200,
		timeout: 0,
		pager: '#heroPagination'
	});
	$('#goodtogive_hero1Link').click(function() {
		$('#goodtogiveCycler').cycle(1);
	});
	
	
	// Cycler for product selector groups of 4 products
//	$('#productSelector').cycle({
//		fx: 'fade',
//		speed: 200,
//		timeout: 0,
//		pager: '#productPager',
//		pagerAnchorBuilder: function(idx, slide) { 
	//		var paw = idx+1;
//			return '<a href="#" class="paw'+paw+'">'+paw+'</a>';
	//	}
//	});
	
	
	// Cycle to navigate between product information panels
	$('.product-info-area').cycle({
		fx: 'fade',
		speed: 200,
		timeout: 0,
		height: '240px'
	});
	
	// Pager for product information
	$('#right_links .d_button ').click(function() {infoArea(0,'d');});
	$('#right_links .fg_button').click(function() {infoArea(1,'fg');});
	$('#right_links .i_button ').click(function() {infoArea(2,'i');});
	$('#right_links .n_button ').click(function() {infoArea(3,'n');});
	
	function infoArea(slide,btn) {
		$('.product-info-area').cycle(slide);
		$('.activeInfo').removeClass('activeInfo');
		$('#right_links .'+btn+'_button').addClass('activeInfo');
		return false;
	}
	
	

	
	// Pager for products
	$('.prodName_0').click(function() {activeProduct(0);});
	$('.prodName_1').click(function() {activeProduct(1);});
	$('.prodName_2').click(function() {activeProduct(2);});
	$('.prodName_3').click(function() {activeProduct(3);});
	$('.prodName_4').click(function() {activeProduct(4);});
	$('.prodName_5').click(function() {activeProduct(5);});
	$('.prodName_6').click(function() {activeProduct(6);});
	$('.prodName_7').click(function() {activeProduct(7);});
	$('.prodName_8').click(function() {activeProduct(8);});
	$('.prodName_9').click(function() {activeProduct(9);});
	
	function activeProduct(slide) {

		$('#product-details').cycle(slide);
		$('#productSelector').cycle(slide);
	//	$('.activeProduct').removeClass('activeProduct');
		$('.prodName_'+slide).addClass('activeProduct');

		return false;
	}
	
	
	
});
