$(document).ready(function(){

//Store Image paths
var toggleMinus = 'fileadmin/templates/werth_0_1/main/javascript/minus.jpg';
var togglePlus = 'fileadmin/templates/werth_0_1/main/javascript/plus.jpg';

var $subHead = $('.products').parent();

//Add the Plus image to every child by default
//$subHead.prepend('<img src="' + togglePlus + '" alt="collapse this section" /> ');

//By Default put the Menu in collapsed state
$('.products').parent().children('ol').slideUp('slow');

//Expand All Code
$('.expand').click(function() {
	$subHead.children('ol').slideDown('slow');
	$('img', $subHead).attr('src', toggleMinus);
});

//Contract All Code
$('.contract').click(function() {
	$subHead.attr('src', toggleMinus).children('ol').slideUp('slow');
	$('img', $subHead).attr('src', togglePlus);
});

var expandList = function() {
	var toggleSrc = $(this).attr('src');
	if ( toggleSrc == toggleMinus ) {
		$(this).attr('src', togglePlus).parent().children('ol').slideUp('slow');
	} else{
		$(this).attr('src', toggleMinus).parent().children('ol').slideDown('slow');
	};
}

//Expand or Contract one particular Nested ol
//$('img', $subHead).addClass('clickable').click(expandList);
//$('img', $subHead).addClass('clickable').mouseover(expandList);
$('a', $subHead).addClass('clickable').click(expandList);
//$('a', $subHead).addClass('clickable').mouseover(expandList);
});
