$(document).ready(function(){
	var domain = $('body').attr('domain');
	var baseUrl = $('body').attr('baseUrl');
	
	$('#main').show().animate({
		left: 0
	}, 700);
	
	$('#blog-content').hover(function() {
		if ($('#blog').css('right') == "-474px") {
			$('#blog').animate({
				right: -100
			}, 1000);
		}
	}, function() {
		$('#blog').animate({
			right: -474
		}, 1000);
	});
	
	$('#language').click(function() {
		var url = $(this).attr('url');
		if (url == null) {
			url = "";
		}
		window.location = domain + baseUrl + url;
	});
	
	$('#navigation li').click(function() {
		var url = $(this).find('a').attr('href');
		if (url == null) {
			url = "";
		}
		if ($(this).attr('class') != "selected") {
			$('#main').animate({
				left: -2000
			}, 700, function() {
				window.location = url;
			});
		}
	});
	
	$('#navigation li').mouseover(function() {
		$(this).css('margin-top', '2px');
	});
	$('#navigation li').mouseout(function() {
		$(this).css('margin-top', '0px');
	});
	
	$('#language').mouseover(function() {
		$(this).css('top', '0px');
	});
	$('#language').mouseout(function() {
		$(this).css('top', '-4px');
	});
	
	$('ul#buttons li').mouseover(function() {
		$(this).css('margin-top', '2px');
	});
	$('ul#buttons li').mouseout(function() {
		$(this).css('margin-top', '0px');
	});
	
	$('.downbutton').mouseover(function() {
		$(this).css('margin-top', '2px');
	});
	$('.downbutton').mouseout(function() {
		$(this).css('margin-top', '0px');
	});


	if ($(window).height() < 650) {
		/*$('#footer').hide();*/
		$('#footer').animate({
			bottom: -60
		}, 1500);
	}
	if ($(window).height() >= 650) {
		/*$('#footer').show();*/
		$('#footer').animate({
			bottom: 0
		}, 1500);
	}
	
	$(window).resize(function() {
		if ($(window).height() < 650) {
			/*$('#footer').hide();*/
			var pos = $('#footer').css('bottom').split('px');
			if (parseInt(pos[0]) == 0) {
				$('#footer').animate({
					bottom: -60
				}, 100);
			}
		}
		if ($(window).height() >= 650) {
			/*$('#footer').show();*/
			var pos = $('#footer').css('bottom').split('px');
			if (parseInt(pos[0]) < 0) {
				$('#footer').animate({
					bottom: 0
				}, 100);
			}
		}
	});
	
	$('#popup-close').click(function() {
		$('#popup-inner').html('');
		$('#popup').fadeOut('fast', function() {
			$('#popup-bg').fadeOut('fast');
		});
	});

});
