$(document).ready(function(){
	
	//howanie i wyciaganie promocji index
	
	
	$('.old').hide();
	
	$('#promocje h3').toggle(function(){
		
			$('.old').slideDown('slow');
			$('#promocje .link').html('ZWIŃ PANEL')
	},
	function(){
		
			$('.old').slideUp('slow');
			$('#promocje .link').html('POKAŻ WIECEJ PROMOCJI')
	}
	)
	
	
	// klikanie
	$('.promo-content').css('display','none');
	
		$('.promo').click(function(){
			
			var toClick = $(this).attr('href');
			
			
			
			var szerCon = $(toClick).width();
			var wysCon = $(toClick).height();
			var szerWin = $(window).width();
			var wysWin = $(window).height();
			
			var posWidth = (szerWin - szerCon)/2;
			var posHeight = (wysWin - wysCon)/2;
						
			$('.promo-content:visible').hide();
				
			
			$(toClick).fadeIn('slow');	
			$(toClick).css('position','fixed');
			$(toClick).css('left',posWidth);
			$(toClick).css('top',posHeight);
			
			
			return false;
	
		})
			
			$('.zamknij').click(function(){
			
				var conClick = '#'+$(this).attr('id');
				if(conClick != "#xtuning"){
				$(conClick).fadeOut('slow');
				}
			return false;
			
		})
		
	
	return false;
});
