
//onload
$(function(){

	$('#results div.result').each(function(){
	
		var prev = $(this).prev();
		if(prev.hasClass('result-more')){
			$('div.close a',prev).click(function(e){ 
				prev.hide();
				e.preventDefault();
			});
			
			$('div.image a, div.info a, div.avail a.more, div.avail a.order',this).click(function(e){
				
				if($(this).attr('href') == '#'){
					prev.show();
					e.preventDefault();
				} else {
					return true;
				}
			});
			
			$('#search-submit,#pager div.buttons a, .filter .list a').click(function(){ $('#loading').show(); });
		}
	
	});
	
	$('.filter > div').each(function(){
		if ($('.list', this)[0].scrollHeight-5 < 30) {
			$('.showHide', this).remove();
		} else {
			$('.showHide', this).show();
		}
		var list = $('.list', this).data('height', $('.list', this)[0].scrollHeight-5)
		if (!$('.showHide', this).hasClass('opened') ) {
			list.css({'height' : '19px'});
		}
		$('.showHide', this).click(function(e){
			e.preventDefault();
			if ($(this).hasClass('closed')) {
				var height = list.data('height');
				var text = $(this).text().replace('show all', 'show less');
				$(this).removeClass('closed').text(text).addClass('opened');
			} else {
				var height = 19;
				var text = $(this).text().replace('show less', 'show all');
				$(this).removeClass('opened').text(text).addClass('closed');
			}
			list.stop(true).animate({'height' : height + 'px'});
		});
	});

});
