/* utils */
$(function() {
	stretchArmstrong();
	window.onresize = stretchArmstrong;
	
	//Login
	$('a.login').click(function() {
		$('#overlay').fadeIn('fast');
		$('#login-box').show();
		$('#pass-box').hide();
	});
	$('#overlay a.close').click(function() {
		$('#overlay').fadeOut('fast');
	});
	
	$('a.pass').click(function() {
		$('#overlay').fadeIn('fast');
		$('#login-box').hide();
		$('#pass-box').show();
	});
	$('#promo-flash').cycle({
		fx:			'fade',
		speed:		1000, 
		timeout: 10000
	});
	
	//Pagination
	$('.pagination a').click(function() {
		$('.item-page').hide();
		$('.item-page.page' + $(this).text()).fadeIn('slow');
		$(this).addClass('current').siblings().removeClass('current');
	});
	
	//Filtering
	$(':input.filter').change(function() {
		var append = '';
		
		$(':input.filter').each(function(i,element) {
			append = append + '/';
			
			if (String($(element).val()).length == 0) append = append + '0';
			else append = append + $(element).val();
		});
			
		window.location = whoAmIVerbose() + append;
	});
	
	$('#gallery-please-open-up').click(function() {
		jQuery.slimbox(VMRPhotos, 0, {
			loop: false,
			counterText: 'Zdjęcie {x} z {y}'
		});
	});
});

//Vertical site stretching
function stretchArmstrong() {
 var stretchMe = $("#content");
 var offset = $(window).height() - $("#promo-flash").height() - 100 - 10 - 25 - $("#footer").height();
 if (offset > 0) stretchMe.css("min-height", offset);
}
