$(document).ready(function() {
	$('.menu a').hover(function() {
		$(this).find('img').animate({
				marginLeft: '+=15'
			  }, 200, function() {});
	}, function() {
		$(this).find('img').animate({
			marginLeft: '-=15'
		}, 200, function() {});
	}).each(function() {
		var uri = $(this).attr('href');
		$(this).click(function() {
			follow(uri);
			return false;
		});
	});
	swapLinks();
});

function follow(uri) {
	if($('.menu').hasClass('hello')) {
		pageOpen(uri);
		$('.menu').animate({
			left: '+=329'
		}, 800, function() {
			$('#blackbox').slideDown(300, function() {
			});
		});
		$('.menu').removeClass('hello').addClass('content');
	} else {
		pageOpen(uri);
	}
}

function pageOpen(uri) {
	$('#container').fadeOut(50, function() {
		$('#loading').show();
		$.post('get.php', {uri: uri}, function(dx) {
			$('#container').html(dx);
			$('#container').fadeIn(50);
			$('#loading').hide();
			swapLinks();
		});
	});
}

function swapLinks() {
	$('#container').find('a').each(function() {
		var uri = $(this).attr('href');
		if(typeof(uri) != 'undefined' && uri.search(':') < 0) {
			$(this).click(function() {
				follow(uri);
				return false;
			});
		}
	});
}

function mapka() {
	window.open('mapka.php', '', "width=800,height=700,statusbar=0,menubar=0,location=0,scrollbars=0");
}

