// Renders divs invisiable and strips selected style from unused tabs 
function prepSheets() {
	$('#col2 div').hide(); 
	$('#col2 .tabs li a').removeClass('selected');
}

$(document).ready(function(){
	
	// Manages category menus on categories page
	// --------------------------------------------------
	$('#category-cols div ul ul').hide();  // hides sub categories 
	$('#category-cols div ul li.sub-cat').toggle(function() {  // toggles visibility of sub categories
		$(this).addClass('open');
		$(this).children("ul").show();
	}, function() {
		$(this).removeClass('open');
		$(this).children("ul").hide();
	});
	$('#category-cols div ul li.sub-cat span').hover(  // adds link-like styles to top-level <li> text 
	      function () {
	        $(this).addClass('hover');
	      }, 
	      function () {
	        $(this).removeClass('hover');
	      }
	    );
	$("#category-cols div ul ul li").click(function(){  // makes links on subcategories work
		  window.location=$(this).find("a").attr("href"); return false;
		});

	// Manages product slide show on categories page
	// --------------------------------------------------
	$('#product-seq').innerfade({
		speed: 'slow',
		timeout: 5000,
		type: 'sequence',
		containerheight: '170px'
	});
	
	// Manages product sheet tabs on product page
	// --------------------------------------------------
	$('#specifications,#information,#downloads').hide();  //First hide unused sheets
	
    $('#description-tab').click(function() {
	   	 prepSheets();
			$('#description').show();
			$('#description-tab a').addClass('selected');
			return false
    	});

	$('#specifications-tab').click(function() {
			prepSheets();
			$('#specifications').show();
			$('#specifications-tab a').addClass('selected');
			return false 
    	});

    $('#information-tab').click(function() {
			prepSheets();
			$('#information').show();
			$('#information-tab a').addClass('selected');
			return false
	    });  

     $('#downloads-tab').click(function() {
			prepSheets();
			$('#downloads').show();
			$('#downloads-tab a').addClass('selected');
			return false
	    });   
});                          
