// layout

$(window).load( function() {

	$('#retailer_search #results ul').each(function() {
		var width = $(this).outerWidth();
		var parentWidth = $(this).parents('div.reseller').outerWidth();
		var margin = parseInt((parentWidth - width) / 2);	
		$(this).css({'margin-left' : margin + 'px' });
	});

// vertically center brand logos if there are no methods

	$('#retailer_search #results div.reseller').each(function() {
		$content = $(this).find('.content');
		var contentHeight = $content.height();
		var parentHeight = $(this).height();
		
		var margin = parseInt((parentHeight - contentHeight) / 2);
		$content.css({'margin-top': margin + 'px' });
				
	});

	$('#search').bind('submit', function() {
		var noTerms=false;
		if(!$('#search #place').val() && !$('#search #term').val()) noTerms = true;
		if(noTerms) {
			var noBrands=true;
			$('#search input[type=checkbox]').each(function() {
				if($(this).attr('checked')) noBrands = false;
			});
		}
		
		if(noTerms && noBrands) { $('#error').fadeIn(); setTimeout(function() { $('#error').fadeOut() }, 2000); return false; }
	});

});
