$(function()
{
	if( document.location == 'http://nebit.ru/' || document.location == 'http://www.nebit.ru/' )
	{
		$.post('/showcase/showcase.php?page=0', {tstamp: new Date().getTime()}, function(data)
		{
			$('#showcase').html(data);
			$('.slideshow').cycle({
				fx: 'fade',
				random: 1,
				speed: 3000, 
				timeout: 5000
			});
		});

		$('.pagination a').live( 'click', function()
		{
			var href = $(this).attr('href');
	
			$.post( href, {tstamp: new Date().getTime()}, function(data)
			{
				$('#showcase').html(data);
				$('.slideshow').cycle({
					fx: 'fade',
					random: 1,
					speed: 3000, 
					timeout: 5000
				});
				
				$('#showcase .images').each(function()
				{
					var positionleft = ( $(this).parent().width() - $(this).width() ) / 2;
					var positiontop = ( $(this).parent().height() - $(this).height() ) / 2;
						
					//$(this).css('position','absolute');
					$(this).css('left',positionleft);
					$(this).css('top',positiontop);
				});
				
			});
	
			return false;
		});
	}
/*
$(els).each(function(i) {
	var positionleft = ( $(this).parent().width() - $(this).width() ) / 2;
	var positiontop = ( $(this).parent().height() - $(this).height() ) / 2;
	
	$(this).css('left',positionleft);
	$(this).css('top',positiontop);
});
*/
	$(window).load(function(){
		$('.images').each(function()
		{
			var positionleft = ( $(this).parent().width() - $(this).width() ) / 2;
			var positiontop = ( $(this).parent().height() - $(this).height() ) / 2;
			
			//$(this).css('position','absolute');
			$(this).css('left',positionleft);
			$(this).css('top',positiontop);
		});
	});
});
