$(document).ready(function(){
						   
	cT = parseInt($('div#Container').css('top'));
	
	$('div#Container').animate({ top: cT + 560 }, "slow", "swing");
						   
						   
	$('#ShowAppEn').click(function(){
			
			$('div#ApplicationBg').fadeIn('fast', function(){ $('div#ApplicationEn').fadeIn('fast'); });
			/** Ustaw stan 0 dla nutek */
			$('div.spoon').each(function(index) {
					 if($(this).hasClass('active'))
					 {
						 $(this).removeClass('active');
						 bg($(this));
					 }
			});
			$('div.spoon2').css('z-index', 1);
						/* Ukryj wszystkie contenty */
			$('div.content').hide();
			$('div.contentBox').css({'visibility' : 'hidden'});
	});
	
	$('div#CloseApp').click(function(){
								  $('div#ApplicationEn').fadeOut('fast', function(){ $('div#ApplicationBg').fadeOut('fast'); });
								  $('div.spoon2').css('z-index', 999);
								  });
						   
function bgHover(obj)
{
   bgPos = obj.css('background-position');
   // Hack on ie
   if(typeof(bgPos) === 'undefined') bgPos = obj.css('background-position-x') + ' ' + obj.css('background-position-y');
   
   obj.css({'background' : 'url(img/spoonHover.gif)', 'background-position' : bgPos});
   obj.children('h2').css('color', '#be1e2d');	
											  topP = obj.css('top');
											  topP = parseInt(topP);
											  bottomP = obj.css('bottom');
											 //obj.animate({ top: topP + 6 }, "normal", "swing", obj.animate({ top: topP - 6 }, "normal", "swing", 'stop'));
}
function bg(obj)
{
	if(obj.hasClass('active')) { return; }
	bgPos = obj.css('background-position');
	// Hack on ie
	if(typeof(bgPos) === 'undefined') bgPos = obj.css('background-position-x') + ' ' + obj.css('background-position-y');
	
	obj.css({'background' : 'url(img/spoon.gif)', 'background-position' : bgPos});
	obj.children('h2').css('color', '#ccc');
}
	
$('div.spoon').hover(function(){
								bgHover($(this));
							}, function(){
								bg($(this));
							});



	$('div.spoon').click(function(){
			if($(this).hasClass('active') || $(this).hasClass('spoon4')) return;
			
			/** Ustaw stan 0 dla nutek */
			$('div.spoon').each(function(index) {
					 if($(this).hasClass('active'))
					 {
						 $(this).removeClass('active');
						 bg($(this));
					 }
			});
			
			$(this).addClass('active'); /** Ustaw stan 1 dla nutki */
			
			/* Ukryj wszystkie contenty */
			$('div.content').hide();
			$('div.contentBox').css({'visibility' : 'hidden'});
		
			if($(this).children('#Logos').length == 1)
			{
				$(this).children('#Logos').fadeIn('normal');
				$(this).children('div.CloseSpoon').fadeIn('slow');
				return;
			}		
		
		
			$(this).children('div.content').slideDown('fast', function(){
					$(this).children('div.CloseSpoon').fadeIn('slow');
					box = $(this).children('div.contentBox');
					boxParent = box.parent('div.content');
					boxW = boxParent.width();
					boxH = boxParent.height();
					boxParent.css({'width' : boxW, 'height' : boxH});
					
					box.css('visibility', 'visible').hide();
					box.show("slide",{ direction: "left" }, 600);
			});		

	});
	
	/* Zamknij okno */
	$('div.CloseSpoon').click(function(){
		if($(this).parent('div.content').length == 1)
		{
			toHide = $(this).parent('div.content');
		}
		else if($(this).parent('div.spoon').children('div#Logos').length == 1)
		{
			$(this).hide();
			toHide = $(this).parent('div.spoon').children('div#Logos');
		}
		toHide.fadeOut('fast', function(){
																 
			/** Ustaw stan 0 dla nutek */
			$('div.spoon').each(function(index) {
					 if($(this).hasClass('active'))
					 {
						 $(this).removeClass('active');
						 bg($(this));
					 }
			});																 
																 
		});
		

	});
});
