
$(document).ready(function(){
	var loaded_imgs=Array();


	
	//START KLIKNIĘCIA
	
	$('.full').click(function() {
		$(this).parent().parent().parent().find('.white').hide();
		$(this).parent().parent().parent().find('.black').hide();

		$(this).parent().parent().parent().find('.white').show();
		$(this).parent().parent().parent().find('.black').show();
		
			var id=make_random_name();
			var _anchor=$(this).parent().parent().find('.anchor');
			
			if ($(this).hasClass('clicked'))
				return false;
			
			$('.clicked').removeClass('clicked');
			$(this).addClass('clicked');
			if ($(this).parent().parent().find('.show').hasClass('current')==false)
				$('.current').slideUp('normal').removeClass('current');

			if ($(this).parent().parent().find('.show img').length>0)
				$(this).parent().parent().find('.show img').animate({opacity : 0},'fast').attr('src', $(this).attr('href')).attr('id', id);
			else
			{
				$(this).parent().parent().find('.show').html('<img id="'+id+'" src="'+$(this).attr('href')+'" />');
				$("#"+id).css('opacity', '0');
			}
		
			$(this).parent().parent().find('.show').addClass('current');

			$("#"+id).parent().slideDown('normal', function(){
				var target_offset = $(_anchor).offset();
				var target_top = target_offset.top;
				$('html, body').animate({scrollTop:target_top}, 500);
			});
			
			if ($.inArray($("#"+id).attr('src'), loaded_imgs)>=0)
			{
				$("#"+id).animate({opacity : 1},'fast');
				$("#"+id).click(function(){
					$('.current').slideUp('normal').removeClass('current');
				});
			}
			else
			{
				$("#"+id).load(function(){
					$(this).animate({opacity : 1},'fast');
					$(this).unbind('load');
					$(this).click(function(){
						$('.current').slideUp('normal').removeClass('current');
					});
					loaded_imgs.push($(this).attr('src'));
				});
				
			}
		return false;
		});

	
	//KONIEC KLIKNIĘCIA

	function make_random_name()
	{
		return "img_"+(1 + Math.floor(9999 * Math.random()));
	}

	
	$("div.black").click(function(){
	$('body').css("background" , 'black');
		//$(body).css('background' , 'black') ;
		});

	$("div.white").click(function(){
		$('body').css("background" , 'white');
			//$(body).css('background' , 'black') ;
			});
});


$("ul li ul.menu").hide();

$("ul li").hover(function(){
     $("ul" , this).show() ;
     
} , function(){ 
     $("ul" , this).hide() ;
    
}) ;

/* obsługa klikniecia ZAPISZ*/
$(document).ready(function() {
	$('#signup').submit(function() {
		$('#response').html('Trwa zapisywanie adresu ... ');
		var email =escape( $('#email').val()) ; 
		$.post('http://www.greencarrot.pl/ajax/add_mail/', {email: email} ,  function(data) {
			$('#response').html(data);
			});

		return false; 
	});
});
/*  koniec obsługi klikniecia zpisu maila*/
