$(function() {

	$('#home-slideshow').cycle({
		fx: 'fade',
		speed: 1000,
		timeout: 0,
        pager:  '#lower',
//		pagerEvent: 'mouseover.cycle',
		easing: 'easeOutExpo',
        pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#lower li:eq(' + (idx) + ')';
        }
	});

	
	
	$('#lower a').each(function(index){
		var num = (index)+1;	


		$(this).hover(
			function() { 
		    $('#home-slideshow').cycle(num); 
			},
			function() { 
//			$('#home-slideshow').cycle(0); 
			}		
		)
		
		
		
	});



	
/*		
	$('header').hover(
		function() { 
		},
		function() { 		
		$('#home-slideshow').cycle(0); 
		}
	);
*/

	function fadeBack() {
		$('#home-slideshow').cycle(0); 
	}


	$('.header #lower').hoverIntent({
		over: null, 
		timeout: 500, 
		out: fadeBack
	});


	$('.shop table.grid td .product-wrapper').each(function(){
		var hoverContents = $(this).children('.rollover');
		var bg = $(this);
		$(this).hover(
			function() { 
				bg.css('background-position','180px 0');
				hoverContents.css('top', '0');
			},
			function() { 		
				bg.css('background-position','0 0');
				hoverContents.css('top', '250px');
			}
		);
		
	});
	
	$('#newsletter-click').click(function(){
		$('#hidden').load('/newsletter.cfm #newsletter-signup', function() {
			$("#newsletter-signup").modal();   
			if($('.newsletter-text-input').val()=='') {
				$('.newsletter-text-input').blur(function() {
				$(this).val('email');	
				});
				$('.newsletter-text-input').focus(function() {
				$(this).val('');	
				});
			}
			
		});
	})
	
	
//	$.cookie('age_verified', 'no', { expires: 365, path: '/' });	
//	$.cookie('age_verified', null);	
//	alert($.cookie('age_verified'));
	
	$('#verified').click(function(){
		$.cookie('age_verified', 'yes', { expires: 365, path: '/' });	
	});
	
	if ($.cookie('age_verified')=='yes') {
		// do nothing
	} else {
			$("#age-verify").modal({onClose: function (dialog) {
				$.modal.close(); // must call this!
				if ($.cookie('age_verified')=='yes') {
				// do nothing 
				} else {
					window.location = 'http://www.google.com';					
				}
			}});   
	}
	
	$('#detailed-image').hide();
	var originalsrc = 	$('#detailed-image-replace').attr('src');
	var rolloversrc = 	$('#detailed-image').attr('src');

/*	$('#detailed-image-replace').addClass('hover');			


	
	$('#detailed-image-clicker').click(function(){

		var whichImage = $('#detailed-image').attr('src');
		
		if (whichImage==originalsrc) {
			$('#detailed-image-replace').attr('src', rolloversrc);			
		} else {
			$('#detailed-image-replace').attr('src', originalsrc);			
		}
		

		if ($(this).hasClass('hover')) {
			$('#detailed-image-replace').parent().removeClass('hover')			
			$('#detailed-image-replace').parent().addClass('nohover')
		} else if ($(this).hasClass('nohover')) {
			$('#detailed-image-replace').parent().removeClass('nohover')			
			$('#detailed-image-replace').parent().addClass('hover')
		} else {

		}
	});
*/
	
	$('#detailed-image-clicker').hover(
		function(){
		$('#detailed-image-replace').attr('src', rolloversrc)
		},
		function(){
		$('#detailed-image-replace').attr('src', originalsrc)
		}
	);
	
	
});



