$(document).ready(function() {
	
	var getheight = $(document).height()-145;
	var getheight2 = $(window).height()-104;
	var getheight3 = $('.ct2').height()+122;
	$('.home-left').css('height',getheight);
	$('.home-right').css('height',getheight);
	
	if (getheight2 <= getheight3) {
		$(".carousel img").each(function(){
			$(this).css('height',getheight3);
		});
	} else {
		$(".carousel img").each(function(){
			$(this).css('height',getheight2);
		});
	}
	
	$('.carousel ul').cycle({ 
			fx: 'fade' 
	});
	
	$(".header ul>li").hover(
		function () {
			$(this).children('div.popup').show();
			$(this).children('a').addClass('hover');
		},
		function () {
			$(this).children('div.popup').hide();
			$(this).children('a').removeClass('hover');
		}
	);
	
	var signup = $(".header .signup").html();
	$(".header ul div.popup").each(function(){
		$(this).append(signup);
	});
	
	$(".listing li div a").hover(
			
		function () {
			$(this).children('img').eq(1).fadeOut();
		},
		function () {
			// Dan - added '.stop(true, true)'
			$(this).children('img').eq(1).stop(true, true).fadeIn();
		}
	);


	
	$(".get-the-look").append('<div id="products-shadowbox-wrap" class="hide"><div id="products-shadowbox"></div></div>');
	
	$(".get-the-look ul input:checked").each(function(){
		var product = $(this).parent('p').parent('div').parent('li').html();
		$('#products-shadowbox').append(product);
	});
	
	$(".get-the-look ul input").click(function(){
		Shadowbox.clearCache();
		Shadowbox.setup();
		if ($(this).is(':checked')) {
		var product = $(this).parent('p').parent('div').parent('li').html();
			$("#products-shadowbox").append(product);
		} else {
			var product = $(this).attr('alt');
			$("#products-shadowbox div").remove('.'+product);
		}
	});
	
	/* NEEDED TO SHIW ONLY FIRST ITEM READY FOR SCROLL 
	$('#products-shadowbox .product-item').hide();
	$('#products-shadowbox .product-item:first').show();*/
	
		
	$('.product-gallery li a').click(function() {
		var imgmedium = $(this).children('img').attr('name');
		var imglarge = $(this).attr('rel');
		$('.product-main').children('a').children('img').attr('src',imgmedium);
		$('.product-main').children('a').attr('href',imglarge);
		Shadowbox.clearCache();
		Shadowbox.setup();
		return false;
	});
	
	$('#care-show').click(function() {
		$(this).css("fontWeight","bold");
		$('#delivery-show').css("fontWeight","normal");
		$('#delivery-info').hide();
		$('#care-info').slideDown();
		return false;
	});
	
	$('#delivery-show').click(function() {
		$(this).css("fontWeight","bold");
		$('#care-show').css("fontWeight","normal");
		$('#care-info').hide();
		$('#delivery-info').slideDown();
		return false;
	});
	
	$('.add').click(function() {
		var qty1 = $(this).prev('input').val();
		var qty2 = $(this).prev('input');
		$(qty2).attr('value',parseInt(qty1)+1);
		return false;
	});
	
	$('.remove').click(function() {
		var qty1 = $(this).prev('a').prev('input').val();
		var qty2 = $(this).prev('a').prev('input');
		if (qty1 > 1) {
			$(qty2).attr('value',parseInt(qty1)-1);
		}
		return false;
	});
	
	var signupbox = $(".frm-signup .form-text");
	var searchbox = $(".header .search .form-text");
	signupbox.focus(function(){
		if($(this).attr("value") == "Enter your email address") $(this).attr("value", "");
	});
	signupbox.blur(function(){
		if($(this).attr("value") == "") $(this).attr("value", "Enter your email address");
	});
	searchbox.focus(function(){
		if($(this).attr("value") == "Search") $(this).attr("value", "");
	});
	searchbox.blur(function(){
		if($(this).attr("value") == "") $(this).attr("value", "Search");
	});
	
	// Dan - I have commented this out and updated LB.html to work without depending on it!
	// $('a').click(function() {
	// 		$('body').removeClass('sb-isvideo');
	// 		return false;
	// 	});
	
	$('a[href$="mp4"]').click(function() {
		$('body').addClass('sb-isvideo');
		return false;
	});
	
});

Cufon.replace('.cufon')
