$(function(){
					 
	// attach colorbox to all links with rel=lightbox
	$("a[rel='lightbox']").colorbox({photo:true, opacity:0.4});
	
	// make the subnav work
	$("#leftnav a").click(function(e) {
		var subnav = $(this).parent().find("ul");

		if (subnav.length > 0) {
			$("#leftnav ul ul").hide();
			subnav.show();
			e.preventDefault();
		}
	});
	
	// Loop over each product, adding a click event that redirects to the link in the h2
	$(".snippet, .featured-product, #cart-panel" ).each(function(){
			var link = $(this).contents().find("a").attr("href");
			$(this).bind ("click",function(){	window.location = link;	});
			$(this).css('cursor','pointer');
	});
	
	// validate any forms with class *validate*
	$("form.validate").validate();
	
	// setup the news archive
	$("#news-archive").treeview({
		animated: "medium",
		collapsed: true,
		unique: true
	});
	
});

