jQuery(function($) {
	
	$('#nav ul li').each(function() {
		if($(this).find('ul').length > 0) {
			$(this).find('ul').append('<li class="last"></li>');
		}
	});
	
	$('#nav ul li').hover(function() {
		$(this).find('a:eq(0)').addClass('hover');
		$(this).find('ul').show();
	}, function() {
		$(this).find('a:eq(0)').removeClass('hover');
		$(this).find('ul').hide();
	});
	
	var scopeView = false;
	var sightView = false;
	var scopeLoc = null;
	var sightLoc = null;
	stats_old_height = parseInt($('.prstats').height());
	stats_height = parseInt($('#content').height() - $('#prnav').height());
	if (stats_old_height < stats_height) {
		$('.prstats').css('height', stats_height);
	};
	
	$('.product .scope-button').live('click', function() {
		$(this).parent('.product').find('.img2').toggleClass('hover');
		return false;
	});
	$('.product .sight-button-trt').live('click', function() {
		$(this).parent('.product').find('.img2').toggleClass('hover');
		sightLoc = $(this).parent('.product').find('.img2');
		if (sightView){
			sightView = false;
		} else {
			sightView = true;
		}
		if (scopeView) {
			scopeLoc.toggleClass('hover');
			scopeView = false;
		}
		return false;
	});
	
	$('.product .scope-button-legacy-cs').live('click', function() {
		$(this).parent('.product').find('.img2').toggleClass('hover');
		return false;
	});
	$('.product .scope-button-legacy-hd').live('click', function() {
		$(this).parent('.product').find('.img2').toggleClass('hover');
		return false;
	});
	$('.product .scope-button-trt').live('click', function() {
		$(this).parent('.product').find('.img3').toggleClass('hover');
		scopeLoc = $(this).parent('.product').find('.img3');		
		if (scopeView){
			scopeView = false;
		} else {
			scopeView = true;
		}
		if (sightView) {
			sightLoc.toggleClass('hover');
			sightView = false;
		}
		return false;
	});
	
	// Summit 150 Bow
	$('.product .value-button-summit').live('click', function() {
		$(this).parent('.product').find('.img2').toggleClass('hover');
		sightLoc = $(this).parent('.product').find('.img2');
		if (sightView){
			sightView = false;
		} else {
			sightView = true;
		}
		if (scopeView) {
			scopeLoc.toggleClass('hover');
			scopeView = false;
		}
		return false;
	});
	
	$('.product .sight-button-summit').live('click', function() {
		$(this).parent('.product').find('.img3').toggleClass('hover');
		scopeLoc = $(this).parent('.product').find('.img3');		
		if (scopeView){
			scopeView = false;
		} else {
			scopeView = true;
		}
		if (sightView) {
			sightLoc.toggleClass('hover');
			sightView = false;
		}
		return false;
	});
	// End
	
	//$('.features ul li a').hover('hover', function() {  - the 'hover' delays the action until rollout
	
	$('.features ul li a').hover(function() {
		var src = $(this).attr('class');
		var img = $(this).parents('.features:eq(0)').find('.image');
		img.attr('src', src);
		return false;
	});
	
	$('#prnav li').hover(function() {
		$(this).find('a:eq(0)').addClass('hover');
		$(this).find('.dd').show();
	}, function() {
		$(this).find('a:eq(0)').removeClass('hover');
		$(this).find('.dd').hide();
	});
	
	$('a[rel^=prettyPhoto]').prettyPhoto({
		
	});
});