jQuery(window).load(function() {
		  	
	var pathname = window.location+"";
	var arr_vars = pathname.split("/");
	
	jQuery(".products_menu h2.title_shopnow").click(function ( event ) {
			event.preventDefault();
			jQuery(this).next().toggle("fast"); 
	});
		
	jQuery(".products_menu ul ul li div.tit a").click(function ( event ) {
		event.preventDefault();
		jQuery(this).parent().next().toggle("fast", function() {
			jQuery('a[href$="'+pathname+'"]').css('color', '#3968b2');
			var c = jQuery(this).parent().attr('id');
			 fixaHeights('li[id$="'+c+'"]');
		}); 
	});
	
	//console.log(jQuery(".products_menu ul ul li div.tit a").height());
	
	
	if(arr_vars[3]=="products-page"){
		if(arr_vars.length<6){
			var subcat = arr_vars[4];
			jQuery('li[class$="'+subcat+'"]').parent().show('fast', function() {
				jQuery('li[class$="'+subcat+'"]').find('#products_page_container').show('fast', function() {
					fixaHeights('li[id$="'+subcat+'"]');	
				});
			});
		}else{
			jQuery('a[href$="'+pathname+'"]').parent().parent().parent().parent().parent().parent().parent().show(0, function() {
				jQuery('a[href$="'+pathname+'"]').parent().parent().parent().parent().parent().show(0, function() {
					jQuery('a[href$="'+pathname+'"]').css('color', '#3968b2');
				});
				
			});
		}
	}
	
	function fixaHeights(d){
		console.log(d);
		jQuery(d).find("a.wpsc_product_title").each(
			function(index){
				jQuery(this).parent().parent().parent().parent().css('height', (jQuery(this).height()+2)+'px');
			}
		);
	}
		
});
		
	
