$(function()
{
	stripeRows('#service_providers_list tbody');
	initAsyncServiceProviderPagination();
	initInfoDivs();
});

function initAsyncServiceProviderPagination()
{
	$('#service_providers_list .PaginationLinks a, #service_providers_list thead a').click(function()
	{
		$('#service_providers_list').fadeTo('fast', 0.1);

		$('#content').loading(true);
		var href = $(this).attr('href');
		
		/* fetch the content
		 */
		$.ajax({
			url: href,
			cache: false,
			success: function(html)
			{
				$('#content').loading(false);
				$('#service_providers_list').replaceWith(html).fadeTo('slow', 100);
				stripeRows('#service_providers_list tbody');
				initAsyncServiceProviderPagination();
				initInfoDivs();
				$('.Obfuscated').each(deObfuscateEmail);
			}
		});
		return false;
	});	
}

function initInfoDivs()
{
	$('#service_providers_list tbody a.ServiceProviderProfileTrigger').click(function()
	{
		/* IE7 has a bug that causes content to disappear on toggle/slideToggle. The
		 * fix is to animate the opacity.
		 * $(this).next('div.ServiceProviderProfile').slideToggle();
		 */
		$(this).next('div.ServiceProviderProfile').animate({ height: "toggle", opacity: "toggle"}, 1000);
		return false;
	});
	
	/* avoid IE < 8
	 */
	/*
	if (!$.browser.msie || navigator.userAgent.indexOf('Trident') > -1)
	{
		$('.ServiceProviderContact, .ServiceProviderDescription').dropShadow(
			{opacity: 0.3, blur:3, left:5, top:5}
		);
		DD_roundies.addRule('.dropShadow', 10, true);
		DD_roundies.addRule('.PartnerContact', 10, true);
		DD_roundies.addRule('.PartnerDescription', 10, true);
	}
	*/
	if (!$.browser.msie)
	{
		$('.ServiceProviderContact, .ServiceProviderDescription').dropShadow(
			{opacity: 0.2, blur:3, left:3, top:3}
		);
	}
	$('.dropShadow').corner('10px');
	$('.ServiceProviderContact').corner('10px');
	$('.ServiceProviderDescription').corner('10px');
}

