$(document).ready(function(){

	// var wizualizacje = $('#menu .page-item-8.current_page_item');
	// if (wizualizacje.length == 1) {
	// 	wizualizacje.append('<ul><li><a href="#">interior</a></li><li><a href="#">exterior</a></li></ul>');
	// }
	
	Cufon.replace('#menu li a', {
		hover: 'true'
	});

	Cufon.replace('h1, h2, h3, h4, .home #slider .project .description a');
	
	$('#top-news .nav a').click(function(){
		var inner = $('#top-news .inner');
		offset = inner.css('left');
		offset = parseInt(offset.substring(0, offset.length-2, offset));
		var news_no = $('#top-news .news').length;
		
		if ($(this).hasClass('left')) {
			if (offset >= 0) 
				inner.stop().animate({left: (news_no-3)*-300}, 150);
			else
				inner.animate({left: '+=300'}, 300);
		} else {
			if (offset <= (news_no-3)*-300)
				inner.animate({left: 0}, 100);
			else
				inner.animate({left: '-=300'}, 350);
		}
		return false;
	});
	
	$('#breadcrumbs .toggle-up').click(function(){
		if ($('#top-news').css('height') != '33px') {
			$('#top-news').animate({height: '33px'}, 250);
			$(this).text('rozwiń');
		} else {
			$('#top-news').animate({height: '122px'}, 250);
			$(this).text('zwiń');
		}
		return false;
	});
	
	$('.home #content .dynamic-col-1').append('<a href="#" class="toggle-up">zwiń</a>');
	$('.home #content .toggle-up').click(function(){
		// $(this).parent().animate({height: 0}, 250);
		$(this).hide();
		if ($(this).text() == 'zwiń') {
			$(this).text('rozwiń');
			$(this).appendTo('.dynamic-col-2').delay(250).fadeIn(250);
		} else {
			$(this).text('zwiń');
			$(this).appendTo('.dynamic-col-1').delay(250).fadeIn(250);
		}
		$('.dynamic-col-1').slideToggle(250);
		return false;
	});
	
/*	$('.ngg-gallery-thumbnail img').click(function(){
		var next_item = $(this).parent().parent().next();
		if (next_item.hasClass('ngg-gallery-thumbnail-box')) {
			$.scrollTo($(this).parent().parent().next(), 200);
		} else {
			$.scrollTo($('#header'), 600);
		}
	});
	
	$('.ngg-gallery-thumbnail-box:last img').css({cursor: 'n-resize'});
*/
	
	$('.ngg-gallery-thumbnail .more').click(function(){
		var max_height = $(this).prev().prev().attr('height');
		if ($(this).parent().css('height') != max_height+'px') {
			$.scrollTo($($(this).attr('href')).parent().parent(), 200);
			$(this).parent().animate({height: max_height}, 200);
			$(this).text('zwiń');
		} else {
			$(this).parent().animate({height: 380}, 200);
			$(this).text('pokaż całość');
		}
		return false;
	});
	
	
	$('#to-top').click(function(){
		$.scrollTo('#menu', 500);
		return false;
	});
	
	
	
	
	
	
	

});
