$(function(){
  $('#sortby').children('li[class!=sort-title]').each(function(){
	$(this).children('a').bind({
	  click:sortBy
	});
  });
});

function sortBy(){
  $(this).parent('li').siblings().children('a').removeClass('active');
  $(this).addClass('active');
  var sorttype = $(this).attr('title');
  var sortBy = 'client/' + $(this).attr('title');
  $.ajax({
	url : sortBy,
	type : 'POST',
	success:function(response){
	  $('#client-update').html(response);
	},
	complete: function(){
	  if(sorttype == 'featured'){
		$('.client-list-box h3').html('Featured Clients');
		$('.client-list-box p.copy').html('Because we believe in supporting our community, we offer an adjusted rate for all qualified non-profit organizations');
	  } else if(sorttype == 'industry') {
		$('.client-list-box h3').html('Clients By Industry');
		$('.client-list-box p.copy').html('');
	  } else {
		$('.client-list-box h3').html('Clients Alphabetically');
		$('.client-list-box p.copy').html('');
	  }
	}
  });
  return false;
}

