	$(document).ready(function() {

	$('.addToVisit,.sendToFriend,.printOptions button').mouseup(function(){
		$(this).css('opacity','1');
	}).mousedown(function(){
		$(this).css('opacity','.70');
	});
	
	$('.addToVisit,.sendToFriend,.printOptions button').mouseout(function(){
		$(this).css('opacity','1');
	});


	//reload image

	$('.captcha').livequery('click', function(){
		$(this).attr('src','/assets/captcha/captcha.php?'+Math.random());
	});

	
	$('#cartLink').click(function(){
		return false;
	});
	$('#cartLink .viewCart').click(function(){
		window.location='/shop/cart/';
		$('#cartBubble').fadeOut('fast');
	});
	$('#cartLink .reportIssue').click(function(){
		window.location='/shop/cart/report/';
		$('#cartBubble').fadeOut('fast');
	});
	
	
	$('#cartLink').hover(function(){
	
		$('#cartBubble').show();
	
	}, function(){
		
		$('#cartBubble').hide();
	
	});
	
	

	//nicer forms overlay text etc
	$('.sendForm input[@type="text"], .sendForm textarea').livequery('keyup', function(){
		$(this).removeClass('error');
		$(this).css('color','#000');
	});
	$('.sendForm input[@type="text"], .sendForm textarea').each(function(){							
		$(this).val($(this).attr('title')).css('color','#777');
	});
	$('.sendForm input[@type="text"], .sendForm textarea').livequery('focus', function(){
		if ($(this).val() == $(this).attr('title')){
			$(this).val('').css('color','#000');
		}
	});
	$('.sendForm input[@type="text"], .sendForm textarea').livequery('blur', function(){
		if ($(this).val() == ''){
			$(this).val($(this).attr('title')).css('color','#777');
		}
	});


	//send to friend
	$('#sendToFriendForm').livequery('submit', function(){
		
		
		$('#sendToFriend').block({  
		message: '<img src="/assets/img/ajax-loader.gif" width="31" height="31" border="0" alt="" style="margin: 0 0 0 -5px; padding: 0;" />',
		css: { border: 'none',
		       padding: '8px 15px', 
		       backgroundColor: '#816985', 
		       '-webkit-border-radius': '5px', 
		       '-moz-border-radius': '5px', 
		       opacity: '0.9',
		 	   fontSize: '11px',
		       color: '#fff',
		 	   textAlign: 'center'
			}, 
		overlayCSS:  {  
	        backgroundColor: '#d4b9e2',  
	        opacity:        '0.5'  
	    },
		centerX: true, // <-- only effects element blocking (page block controlled via css above) 
	    centerY: true
	});
		
		
		
		var captcha = ($('#captchaText').val() != '' || $('#captchaText').val() != undefined) ? $('#captchaText').val() : '';
		$.ajax({
			url: "/assets/tools.ajax.php",
			type: "POST",
			data: "captcha="+captcha,
			dataType: "html",
			success: function(data){
				
				$('#sendToFriend').unblock();
				
				//alert(data);
				if (data[0] == 1){
				
					var formdata = $('#sendToFriendForm').serialize();
					//alert(formdata);
					
					$.ajax({
						url: "/assets/tools.ajax.php",
						type: "POST",
						data: "sendToFriend=1&url="+$('#sendToFriendURL').val()+"&"+formdata,
						dataType: "html",
						success: function(msg){
							
							$('#sendToFriend').slideUp('fast',function(){alert(msg);});
							
							
							
						}
					});
							
				} else {
					$('#captchaText').val('Incorrect Word. Try another.').focus().select().addClass('error');
					$('.captcha').attr('src','/assets/captcha/captcha.php?'+Math.random());
				}

			}, error: function(data){
					
			}
		});
		return false;
	});


	$('.sendToFriend').click(function(){
		
		$(this).parent('div').append('<div id="sendToFriend" class="sendForm"><div class="innerContainer"><h4>close</h4><div class="content"><form id="sendToFriendForm"><label><input type="text" name="friendname" title="Friend\'s Name" /></label><label><input type="text" name="friendemail" title="Friend\'s Email" /></label><hr size="2" color="#d4e2eb" /><label><input type="text" name="yourname" title="Your Name" /></label><label><input type="text" name="youremail" title="Your Email" /></label><textarea name="message" title="Your Message"></textarea><hr size="2" color="#d4e2eb" /><label><input type="text" id="captchaText" title="Type the Word Below" /></label><div style="clear:both;"></div><img src="" alt="Security" class="captcha" width="200" height="50" /><button type="submit">Send to a Friend</button></form></div></div></div>');
	
		
			$('.sendForm input[@type="text"], .sendForm textarea').each(function(){							
				$(this).val($(this).attr('title')).css('color','#777');
			});

	
		$('#sendToFriend').slideToggle('fast',function(){
			if ($(this).is(':visible')){
				 $('.captcha').attr('src','/assets/captcha/captcha.php?'+Math.random());
			}
		});
	});
	
	//closer
	$('.sendForm .innerContainer h4').livequery('click', function(){
		$(this).parent().parent().slideUp('fast');
	});
















		//hide everything but coffee
		$("#left-nav li").children('ul').hide();
		$("#left-nav li#open").children('ul').show();
		

		$("#left-nav li a.head").click(function() {
			
			//alert($(this).text());
			
		//	alert($(this).parent('li').attr('id'));
			
			$(this).parent('li').siblings('li').children('ul').slideUp('fast');
			$(this).parent('li').children('ul').slideDown('fast');
			
			
			//$(this).next().toggle('fast');
			return false;
		});
		
		//.next().hide();





	// Javascript for IE6 Drop Downs
	// make open class active
	$("#nav li.open").addClass('active');
	// set hover states for LIs
	jQuery('#nav li').hover(function() {
		$("#nav li.open").removeClass('active');
		$(this).addClass('active');
	}, function() {
		$(this).removeClass('active');
		$("#nav li.open").addClass('active');
	});

	
	
	
	
/*
	$(".atc-add").click(function(){
		$(this).parent().siblings(".add_to_cart").trigger('click');
	});
*/
	
	
	
	
	$(".ourpick_container .add_to_cart").click(function(){
	
	if ($(this).siblings('.add_to_cart_menu').is(':hidden')){
	
		$(this).animate({top: 0, right: 0},200,function(){
			$(this).css('background-image','url(/assets/img/shop-featured-item-details.gif)');
			
			$(this).siblings('.add_to_cart_menu').slideDown('fast');
		
		});
	
	} else {
	
		$(this).siblings('.add_to_cart_menu').slideUp('fast',function(){
			$(this).siblings('.add_to_cart').animate({top: ($(this).parent('.ourpick_container').height() - $(this).siblings('.add_to_cart').height()) +'px', bottom: 0, right:0},200);
			$(this).siblings('.add_to_cart').css('background-image','url(/assets/img/shop-ourpicks-add.gif)');
		});

	}
	
	});


/*
		$(".ourpick_container").hover(function(){
		
		//on hover
		
		}, function(){
			$(this).children('.add_to_cart_menu').slideUp('fast',function(){
	
				$(this).siblings('.add_to_cart').animate({top: ($(this).parent('.ourpick_container').height() - $(this).siblings('.add_to_cart').height()) +'px', bottom: 0, right:0},200);
				$(this).siblings('.add_to_cart').css('background-image','url(/assets/img/shop-ourpicks-add.gif)');
			});
		
		});
*/
		
		
		
		
});
