$(function () {//general jQuery stuff on every page


	
  //$(".footer_blog").animate( { backgroundColor: '#2a4534' }, 1000)
   // .animate( { backgroundColor: '#273d30' }, 1000, johnny);
	//function johnny() {$(".footer_blog").animate( { backgroundColor: '#2a4534' }, 1000)
    //.animate( { backgroundColor: '#273d30' }, 1000, johnny);
		
	//}


	
	//$("#nav li").click(function(){
	 //var add =$(this).find("a").attr("href");
	// console.log(add);
	// condole.log(window.location); 
	//});

	
	
	$("a img:not(.logo)").css("opacity", 0.7 )//Image fade for images that are links (except logo)
	$("a img:not(.logo)").hover(function(){ 
		$(this).stop().fadeTo("fast", 1.0);
	},function(){
		$(this).stop().fadeTo("fast", 0.7);
	});

	 var body =	$('body').attr('class');//add selected class to NAV on each page from body class
 	var thing = 'li.'+ body;
 	$(thing).addClass('selected');

	$('#faq dd').hide();// set up for FAQ clicks
	$('#faq dd img').show();
	$('#faq dt').css('cursor', 'pointer');
	$('#bread dd').hide();// set up for FAQ clicks
	$('#bread dd img').show();
	$('#bread dt').css('cursor', 'pointer');
	
	
	
	$('#faq dt').click(function(){// FAQ click functionality
		var $this = $(this);
		($this).addClass('this_one');
		$('#faq dt:not(.this_one)').hide();
		($this).next().fadeIn();
	});
	
		$('#bread dt').click(function(){// BREAD FAQ click functionality
		var $this = $(this);
		($this).addClass('this_one');
		$('#bread dt:not(.this_one)').hide();
		($this).next().fadeIn();
	});
	
	$('#about_box dd img').css("opacity", 0.6 )//Image fade for images that are links (except logo)
	$('#about_box dd img').hover(function(){ 
		$(this).stop().fadeTo("fast", 1.0);
	},function(){
		$(this).stop().fadeTo("fast", 0.8);
	});
	
	$('#faq dd img').click(function() {// about bread links and FAQ
		$('#faq dd').fadeOut('fast');
		$('#faq dt').fadeOut('fast');
		$('#faq').fadeOut(dave);
		function dave() {
			$('#faq dd').show().hide();
			$('#faq dt').removeClass().fadeIn(steve);
		}
		
		function steve(){
			$('#faq').fadeIn();
		}
	});
	
	
		$('#bread dd img').click(function() {// about bread links and FAQ
		$('#bread dd').fadeOut('fast');
		$('#bread dt').fadeOut('fast');
		$('#bread').fadeOut(dave);
		function dave() {
			$('#bread dd').show().hide();
			$('#bread dt').removeClass().fadeIn(steve);
		}
		
		function steve(){
			$('#bread').fadeIn();
		}
	});
	
	$('#bread').hide();
			$('.about #buy_nav a').click(function(){
				var $this = $(this);
				$('#faq').toggle();
				$('#bread').toggle();
				$('#buy_nav a').removeClass();
				$this.addClass('selected');
				return false;
			})
			
			
			$('#buy_nav').show();
			$('#buy_welcome').show();
			$('.map_no_javascript').hide();
			
	
			
	
			$("#content .pop_link").css("opacity", 0.5 )//prev and next link fades
			$("#content .pop_link").hover(function(){ 
			$(this).stop().fadeTo("fast", 1.0);
			},function(){
				$(this).stop().fadeTo("fast", 0.5);
			});
			
			
			$('.product_title').css('cursor','pointer');
			$('.bread_group').hide();
			$('#british').show();
			
			$('#product_nav li a').click(function(){
				var $this =	$(this);
				var bread = $this.parent().attr('title');
				var breadgroup = '#'+ bread;
				
				$('#product_nav li a').removeClass('selected');
				$($this).addClass('selected');
				$('.bread_group').hide();
				$(breadgroup).show();
				return false;
			});
			
			
			
			
			
			$('#content .product_title').click(function(){ //show popout
				var $this = $(this);
				var height = $(document).height();//make sure overlay is right height
				var scroll = $(window).scrollTop(); 
				//console.log(scroll);
				$('.popout').css({'margin-top': (scroll+50)});
					$('#overlay').css({'height': height}).fadeIn('fast',barry);
					function barry(){
					$($this).next().addClass('visible');
					//var height = $($this).next().height();
					//console.log(height);
					//$('#popoutoverlay').css('height', height);
					//$('#popoutoverlay').fadeIn('fast');
					$($this).next().fadeIn();
					
				}		
			});
			
			$('#overlay').click(function(){ // close popout
				$('#content .visible').removeClass('visible').fadeOut('fast', james);
					
					function james(){
						$('#overlay').fadeOut('fast');
						$('#popoutoverlay').fadeOut('fast');
					}
			});
			
			$('#content .popout_mid .cross img').click(function(){ // close popout with cross
				$('#content .visible').removeClass('visible').fadeOut('fast', james);
					
					function james(){
						$('#overlay').fadeOut('fast');
						$('#popoutoverlay').fadeOut('fast');
					}
					
			});		
			$('#content .popout_mid .cross span').click(function(){ // close popout with span IE
				$('#content .visible').removeClass('visible').fadeOut('fast', james);
					
					function james(){
						$('#overlay').fadeOut('fast');
						$('#popoutoverlay').fadeOut('fast');
					}
					
			});
			
			 
			$('.prev:not(.first)').click(function(){// PREVIOUS FUNCTION
				var $this = $(this).parent().parent();
				$($this).removeClass('visible').fadeOut( function(){
				$($this).prev().prev().addClass('visible').fadeIn();
				});
			});
			
			$('.next:not(.last)').click(function(){// NEXT FUNCTION
				var $this = $(this).parent().parent();
				$($this).removeClass('visible').fadeOut('fast', function(){
				
				$($this).next().next().addClass('visible').fadeIn('fast');
				});
			});
			
			

			
	
});
