$(function() {
	// Give external links a new window
	$("a[rel='external']").each(function() {
		$(this).attr("target", "_blank");
	});
	
	// Open new window for terms and conditions
	$("a[rel='window']").click(function() {
		window.open(this.href+"?text", '_blank', 'height=500, width=960, scrollbars, resizable');
		return false;
	});
	
	// Cart status animation
	$("#cart-status em").animate({"opacity": "1"}, 500, function() {
		$(this).animate({"opacity" : "0.25"}, 375, function () {
			$(this).animate({"opacity" : "1"}, 375, function () {
				$(this).delay(5000).fadeOut('slow');
			});
		});
	});
	
	// Nav rollover for IE6-
	$("#navigation li").mouseover(function() {
		$(this).find("ul").css("display", "block");
	});
	$("#navigation li").mouseout(function() {
		$(this).find("ul").css("display", "none");
	});
	
	// Rotate testimonial
	var testimonialParent = "#testimonial-overlay";
	var testimonialWidth = $(testimonialParent).width();
	var testimonialPos = 1;
	var testimonialCount = $(testimonialParent+" li").length-1;
	var testimonialDelay = 7500;
	
	function testimonialRotate()
	{
		$(testimonialParent).delay(testimonialDelay).animate({"scrollLeft" : testimonialPos*testimonialWidth}, 500, function () {
			if (testimonialPos>=testimonialCount)
			{
				testimonialPos = 0;
			}	
			else
			{
				testimonialPos++;
			}
			testimonialRotate();
		});
	}
	
	// Reset
	$(testimonialParent).find("ul").css("width", (testimonialCount+1)*testimonialWidth);
	$(testimonialParent).animate({"scrollLeft" : "0"}, 1);
	
	// Kick things off...
	testimonialRotate();
});
