$(document).ready(function() {

	
	$('a.postpopup').click(function(){
		
		id = $(this).attr('rel');
		
		$("#more-content-" + id ).fadeToggle('slow', alter);
		
		
		function alter() {
			$('#more-' + id).fadeToggle("slow", "linear");
			$('#less-' + id).fadeToggle("slow", "linear");
			
			var display_prop = $("#more-content-" + id ).css('display');
			
			if ( display_prop=="none" ) {
				$('html, body').animate({
                        scrollTop: $("#post-" + id).offset().top
                    }, 1200,'easeInOutExpo');

			}
		}

	});//end .click
	
	$('a.fensi').fancybox({
		'titlePosition'	:	'over',
		'padding'		:	0,
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	300, 
		'speedOut'		:	300, 
		'overlayShow'	:	true,
		'onComplete'	:	function () { $('#fancybox-img').bind('contextmenu', function(e){return false;}); }
		
	}); // end .fancybox
	
	/*
	//test rezolucija
	$('body').append('<div id="debug"></div>');
	$(window).resize(function() {
	
		$("#debug").html( 'Doc:' + $(document).width() + '<br />Window:' + $(window).width());	
	
	}) 
	.resize();
	*/
	
	//Hide (Collapse) the toggle containers on load
	//$("#portfolio-cont").hide(); 
	
	$("#portfolio-toggle").click(function () {
	
		$("#portfolio-cont").fadeToggle('slow',alter2);
		
		function alter2() {
			$('#portfolio-more').fadeToggle("slow", "linear");
			$('#portfolio-less').fadeToggle("slow", "linear");
		}
		
		//$("#portfolio-cont").animate({height: 'toggle'});
		/*
		var $lefty = $("#portfolio-cont");
		$lefty.animate({
			top: parseInt($lefty.css('top'),10) == 0 ?
			-$lefty.outerHeight() :
			0
		});
		*/
	});
	
});
