$(function() {	
	$('.fancybox').fancybox({
		ajax: { cache: false },
		onComplete: function() {
			$.fancybox.resize();
		}
	});
	
	$('#social-network-tabs a').click(function(e) {		
		e.preventDefault();
		
		var current = $(this);
		if (current.hasClass('disabled') || current.hasClass('selected')) {
			return false;
		}		
		else {		
			current.siblings().removeClass('selected').end().addClass('selected disabled');
			showLoader();
			
			var loadUrl = $(this).attr('href');
			$.ajax({
				cache: false,
				dataType: 'html',
				type: 'post',
				url: loadUrl,
				success: function(data) {
					hideLoader();
					$('div.tab-content').stop(true, true).fadeOut('normal', function() {
						$('div.tab-content').hide().html(data).fadeIn();
					});
					current.removeClass('disabled');
				}
			});
		}
	});
	
	$('#slideshow').cycle({
		activePagerClass: 'selected',
		pager: '#slideshow-pager'
	});
});

function showLoader(loader) {
	if (typeof(loader) == 'undefined') {
		loader = 'div.loader';
	}
	$(loader).css({opacity: 1, visibility: 'visible'});
}
function hideLoader(loader) {
	if (typeof(loader) == 'undefined') {
		loader = 'div.loader';
	}
	$(loader).fadeTo(250, 0);
}
