$('document').ready(function(){
	
	
	
	$('#LayoutColumn1 .SideCategoryListClassic li:first-child').not('ul ul li').addClass('firstchild');
	var id = 0;
	$('#LayoutColumn1 .SideCategoryListClassic li.firstchild').each(
			function(){
				
				var anchor = $(this).find('a:first');
				var t = $(anchor).text();
				
				if( t == "Extended Warranty" ) return;
				$(anchor).addClass('noLink');
				$(anchor).addClass('link_'+id);
				$(anchor).attr('href',anchor.attr('href')+"#link_"+ id);
				
				$(this).find('a').each(function(){
					$(this).not('.noLink').attr('href',$(this).attr('href')+"#link_"+ id);
				});
				
				id++;
			}
	);
	
	$('#LayoutColumn1 .SideCategoryListClassic a.noLink').click(
	  function (event) {
		event.preventDefault();
		event.stopPropagation();
		//$('#LayoutColumn1 .SideCategoryListClassic li.firstchild > ul').hide('slow');
		$(this).next().toggle('slow');
		$(this).focus();
		return false;
	  }
	);
	
	//menu
	//$('.menu .SideCategoryListClassic li:first-child').not('ul li ul li').css('border','1px solid #c00');
	$('.menu .SideCategoryListClassic li:first-child').not('ul li ul li').addClass('firstchild');
	var id = 0;
	$('.menu .SideCategoryListClassic li.firstchild').each(
			function(){
				var anchor = $(this).find('a:first');
				$(anchor).addClass('noLink');
				$(anchor).addClass('link_'+id);
				$(anchor).attr('href',anchor.attr('href')+"#link_"+ id);
				
				$(this).find('a').each(function(){
					$(this).not('.noLink').attr('href',$(this).attr('href')+"#link_"+ id);
				});
				
				id++;
			}
	);
	
	/*$('.menu .SideCategoryListClassic a.noLink').click(
	  function (event) {
		
		event.preventDefault();
		event.stopPropagation();
		$('#LayoutColumn1 .SideCategoryListClassic li.firstchild > ul').hide('slow');
		$(this).next().show('slow');
		$(this).focus();
		return false;
	  }
	);*/
	
	//cut string to desired length
	$('.ProductList .ProductDetails a').each(
		function(){
			var atext = $(this).text();
			if(atext.length > 50){
				$(this).text( atext.substr(0,50)+"..." );
			}
		
		}
	);
	
	$('.featured-products .ProductDetails a').each(
		function(){
			var atext = $(this).text();
			if(atext.length > 50){
				$(this).text( atext.substr(0,50)+"..." );
			}
		
		}
	);
	
	var hash = location.hash;
	//alert(hash);
	hash = hash.substr(1,hash.length);
	if(hash.length>0){
		$('.'+hash).click();
	}
	
	
	var s = "";
	$('img').each(function(){
		s = s + $(this).attr("src") + " w:" + $(this).parent().width() + " h:" + $(this).parent().height() + " -- ";
	});
	//$('#dbgx').html(s);
});
