$(document).ready(function() {
	$(".hidden").hide();

	$('.residential').each(function() {
		$(this).hide();
	});
	//$('#commercial-error').hide();
	var errorCheck = function(){
		if ($('#commercial-listings ul').children().length <= 1) {
			if ($('#commercial-error').length == 0) {
				$('#commercial-listings ul').append('<br /><blockquote class="side-quote"><p>We are sorry, we currently do not have any listings for this commercial space. Please search our other listing types to find a space that may work for you or <a href="contact/index/?type=commercial" title="Contact Us">contact us</a> for more information and upcoming availabilities.</p></blockquote>');
			} else {
				$('#commercial-error').show();
			}
		}
	};
	//this. = errorCheck;
	$('#sort_office').click(function () {
		var checkedState = $(this).attr('checked');

		$('.office').each(function() {
			$(this).toggle(checkedState);
		});
		errorCheck();
	});

	$('#sort_retail').click(function () {
		
		var checkedState = $(this).attr('checked');

		$('.retail').each(function() {
			$(this).toggle(checkedState);
		});
		errorCheck();
	});

	$('#sort_professional').click(function () {
		var checkedState = $(this).attr('checked');

		$('.professional').each(function() {
			$(this).toggle(checkedState);
		});
		errorCheck();
	});

	$('#sort_all').click(function () {
		var checkedState = $(this).attr('checked');

		$('.office').each(function() {
			$(this).toggle(checkedState);
		});

		$('.professional').each(function() {
			$(this).toggle(checkedState);
		});

		$('.retail').each(function() {
			$(this).toggle(checkedState);
		});
	});
	errorCheck();
});
