		// wait for the DOM to be loaded 
       $(document).ready(function() { 
           // bind 'ajax_box' and provide a simple callback function 
								
			$(".produkty td").bind('mouseenter', function(){
				//alert('juhu!');
				$(this).find('.minimenu').show();
			});
			
			$(".produkty td").bind('mouseleave', function(){
				//alert('juhu!');
				$(this).find('.minimenu').hide();
			});
			
			$(".produkty td span.foto img").bind('mouseenter', function(){
				//alert('juhu!');
				$('.autozoom').hide();
				var src = $(this).attr('src');
				src = src.replace("small", "autozoom");
				//$(this).parent().parent().find('.autozoom').show();
				$(this).parent().parent().find('.autozoom').addClass('autoi');

				var img = new Image();

				// zamieniamy tła dopiero po załadowaniu obrazka.
				$(img).load(function () {
					//alert(src);
					//alert($('.autoi').attr('class'));
					$('.autoi').css('background-image', 'url('+ src +')');
					
				})
				.attr('src', src)	
			});
			
			$(".produkty td span.foto img").bind('mouseleave', function(){
				//alert('juhu!');
				$(this).parent().parent().find('.autozoom').hide();
			});
			
			$("#rela").bind('click', function(){
				//alert('juhu!');
				$("#dokoszyka").hide();			
				$('div.tlo').hide();	
				$('#rela').hide();
			});
			
			$("#dokoszyka .content, #zoomek .content").bind('click', function(event){
				event.stopPropagation();
			});
			
			$("div.advanced, h2.advanced, div.dymek").bind('click', function(){
				if ($('#szukajka').hasClass('down')) {
					$('#szukajka').removeClass('down');
					//$('.cecha').removeClass('selected');
					$('.cecha input:hidden').attr('checked', false);
					$('input.szukaj').fadeOut(500);
					$('div.dymek').fadeIn(700);
					$('div.advanced span.strzalka').addClass('down');
					$('#szukajka').animate({
						height: '36px'
					}, 500);
					$.scrollTo("div#content", 500);
				}
				else {
					$('#szukajka').addClass('down');
					$('div.dymek').fadeOut(500);
					$('input.szukaj').fadeIn(700);
					$('div.advanced span.strzalka').removeClass('down');
					//zaznaczamy wybrane elementy
					$('#szukajka').animate({
						height: '226px'
					}, 500);
					$.scrollTo("div#content", 500);
				}
			});
			
			$(".szukajka_schowaj").bind('click', function(){
				if ($('#szukajka').hasClass('down')) {
					$('#szukajka').removeClass('down');
					//$('.cecha').removeClass('selected');
					$('.cecha input:hidden').attr('checked', false);
					$('input.szukaj').fadeOut(500);
					$('#szukajka').animate({
						height: '36px'
					}, 500);
				}
				else {
					$('#szukajka').addClass('down');
					$('input.szukaj').fadeIn(500);
					//zaznaczamy wybrane elementy
					$('#szukajka').animate({
						height: '226px'
					}, 500);
				}
			});
			
			$("div.cecha").bind('click', function(){
				$(this).toggleClass('selected');
				if ($(this).hasClass('selected')) {				
					$(this).find('input:hidden').attr('checked', true);
				} else {
					$(this).find('input:hidden').attr('checked', false);
				}
			});
			
			$("h2.k2f, h2.d2").bind('click', function(){
				$(this).toggleClass('up');
				$('div.rozwin').toggle();
			});
			
			$("#menu div.menu").bind('mouseenter', function(){				
				$(this).find('div.submenu').show();				
			});
			
			$("#menu div.menu").bind('mouseleave', function(){				
				$(this).find('.submenu').hide();
			});
			
			$("#profil div.pp").bind('mouseenter', function(){				
				if ($(this).width() < 10) {
					$(this).animate({
						width: '200px'
					}, 100);
				}		
			});
			
			$("#profil div.pp").bind('mouseleave', function(){				
				$(this).animate({
						width: '0px'
					}, 0);
			});
			
			$("input.rabat").bind('focus', function(){
				if ($(this).attr('value') == 'wprowadź kod rabatowy' ) $(this).attr('value', '');				
			});
			
			$("input.rabat").bind('blur', function(){
				if ($(this).attr('value') == '' ) $(this).attr('value', 'wprowadź kod rabatowy');				
			});
			
			$("input.error").bind('focus', function(){
				$(this).removeClass('error');				
			});
			
			$("span.przelicz").bind('click', function(){
				var kod = $('input.rabat').attr('value');
				$.post("index.php/ajax/pobierzRabat", {kodrabatowy: kod}, function(data){
					if (data != 0) {
						$('#rabat').attr('value', data['wartosc']);
						$('span.rabat_info').removeClass('rabat_nok');
						$('span.rabat_info').addClass('rabat_ok');
						$('span.rabat_info').html('Kod OK!');
						usunPozycje(0);
					} else {
						$('#rabat').attr('value', data['wartosc']);
						$('span.rabat_info').removeClass('rabat_ok');
						$('span.rabat_info').addClass('rabat_nok');
						$('span.rabat_info').html('Błędny kod!');
						usunPozycje(0);
					}
					
				}, "json");
			});
			
			$("img.newsletter_plus, img.newsletter_minus").bind('click', function(){
				// ustawiamy ajaxowe tło
				$('input#news_email').addClass('ajax');
				// dodajemy maila do newslettera
				var email = $('input#news_email').attr('value');
				// uwuamy tekst pod ajaxowe tło
				$('input#news_email').attr('value', '');
				// Sprawdzamy, czy kliknięto dodawanie czy usuwanie
				if ($(this).hasClass('newsletter_plus')) var dodaj = 1;
				else var dodaj = 0;
				
				$.post("index.php/ajax/doNewslettera", {email: email, dodaj: dodaj}, function(data){
					// usuwamy ajaxowe tło
					$('input#news_email').removeClass('ajax');
					// Jeżeli wszystko OK to wpisujemy w pole newslettera tekst
					$('input#news_email').attr('value', data['odp']);										
				}, "json");
			});

			$(".showbasket").bind('mouseenter', function(){

				// trzeba wczytać mini koszyk
				// Obrazek / nazwę (producent/model) / cena 1 sztuki / ilość sztuk / id
				$('tr.mo').remove();
				$('.showbasket .ajax').show();
				$('#minikoszyk').show();
				$.post("index.php/ajax/wczytajMiniKoszyk", function(data){
					//alert('ojo');
					$('.showbasket .ajax').hide();
					var i = 0;										
					var pr = data;
					$.each(data, function(index, value){
						i++;
						//if (isset(data[index]['plik'])) foto = data[index]['plik'];
						//else foto = 'nofoto.gif';
						foto = data[index]['plik'];
						$('#minikoszyk table').append($('<tr class="mo"></tr>').html("<td class='foto'><a href='/zegarek-w-koszyku,prod," + index + ".html' ><img src='/media/gallery/thumb/" + foto + "' alt='Zegarek' /></a></td><td class='nazwa'><a href='/zegarek-w-koszyku,prod," + index + ".html'><span class='producent'>" + data[index]['producent'] + "</span><br/><span class='model'>" + data[index]['nazwa'] + "</span></a></td><td class='cena'>" + data[index]['cena'] + " PLN</td><td class='ile'>" + data[index]['sztuk'] + " szt.</td><td class='usun'><a href='javascript:usunPozycje("+ index +")' class='usun' id='usun"+ index +"'></a></td>"));
					});
					if (i) {
						$('.mo:last td').addClass('last');
						$('#minikoszyk').show();
					} else {
						$('#minikoszyk table').append($('<tr class="mo"></tr>').html("<td>Koszyk jest pusty!</td>"));
					}
				}, "json");																
			});
			
			$(".showbasket").bind('mouseleave', function(){				
				$('#minikoszyk').hide();				
			});
			
			$("a.zoomer").bind('click', function(){				
				var id = $(this).attr('zoom');
				
				$('a.szczegoly').attr('href', 'info,prod,'+ id +'.html');
				$('#zoomek a.dokoszyka').attr('tag', id);
				
				$("#dokoszyka").hide();
				$('div.tlo').show();
				
				$('#zoomek div.big').css('background', 'url(/media/gfx/admin/ajax_loader.gif) no-repeat center center #ffffff');
				$('#bigimg').parent().attr('href', '');
				$('#bigimg').attr('src', '');
				
				$('#minifoto1').css('background-image', 'url(/media/gfx/admin/ajax_loader.gif)');		
				$('#minifoto2').css('background-image', 'url(/media/gfx/admin/ajax_loader.gif)');
				$('#minifoto3').css('background-image', 'url(/media/gfx/admin/ajax_loader.gif)');
				$('.minifoto').css('border-width', '0');
				$('#cloud-zoom-big').css('background-image', 'url()');
									
				$('#rela').show();
				
				var top = (($(window).height() + $(window).scrollTop() * 2) - $('#rela').height() - 15) / 2;
				if (top < 0) top = 0;
				$('#rela').css('top', top);
				
				var href = $(this).parents('.foto').find('a:first').attr('href');			
				$('.szczegoly').attr('href', href);
				
				$('.cloud-zoom').CloudZoom();
				
				var top = (($(window).height()) - $('#zoomek').height() - 15) / 2;
				
				if (top < 0) top = 0;
				$('#zoomek').css('margin-top', top);
				
				$("#zoomek").show();
				
				// trzeba wczytać obrazek produktu
				$.post("index.php/ajax/pobierzFotki", {id: id}, function(data){
				// wszystko OK!
				
					var img = new Image();
  
					// zamieniamy tła dopiero po załadowaniu obrazka.
					$(img).load(function () {
						$('#big').css('background', 'url(/media/gallery/medium/'+ data[0]['plik'] + ') no-repeat center center #ffffff');
						$('#bigimg').parent().attr('href', '/media/gallery/big/' + data[0]['plik']);
						$('#bigimg').attr('src', '/media/gallery/medium/' + data[0]['plik']);
						$('.cloud-zoom').CloudZoom();
					})
					.attr('src', '/media/gallery/medium/'+ data[0]['plik']);

					for(var i = 0; i < 3; i++) {						
						if (typeof(data[i]) != 'undefined') {
							var imga = new Image();

							// zamieniamy tła dopiero po załadowaniu obrazka.							
							$(imga).load(function () {
								var nr = $(this).attr('tag');								
								//alert('#minifoto'+ nr + ' url: ' + $(this).attr('src'));
								$('#minifoto' +nr).css('background-image', 'url('+ $(this).attr('src') +')');
								$('#minifoto' +nr).attr('tag', data[nr-1]['plik']);
								//$('#minifoto' +nr).css('border-width', '1px');
							})
							.error(function(){
								alert('Błąd!');
							})
							.attr('tag', (i+1))
							.attr('src', '/media/gallery/small/'+ data[i]['plik']);
						} else {
							$('#minifoto'+ (i + 1)).css('background-image', 'url()');
							$('#minifoto'+ (i + 1)).attr('tag', '');
							//$('#minifoto'+ (i + 1)).css('border-width', '0');
						}
					}
				}, "json");
			});
			
			$("a.dokoszyka").bind('click', function() {
				
				var id = $(this).attr('tag');				
				var ob = $(this);
				
				$.post("index.php/ajax/dodajDoKoszyka", {id: id}, function(data){
					// udało się dodanie do koszyka
					if (data['status'] == 1) {
						
						if ($('#rela').css('display') == 'block') {
							var src = $('#minifoto1').css('background-image');
							//alert('src: '+ src);
						} else {
							if (ob.parents('.foto').find('img:first').attr('src')) {
								var src = 'url(' + ob.parents('.foto').find('img:first').attr('src') + ')';
							}
							else {
								var src = 'url(/media/gallery/small/' + $('div.mini').find('span:first').attr('tag') + ')';
							}
						}
						
						$("#zoomek").hide();
						$('a.koszykfoto').css('background-image', 'url(/media/gfx/admin/ajax_loader.gif)');
						$('div.tlo').show();
						$('#rela').show();
						
						var top = (($(window).height() + $(window).scrollTop() * 2) - $('#rela').height() - 15) / 2;
						if (top < 0) top = 0;
						$('#rela').css('top', top);
						
						var href = ob.parents('.foto').find('a:first').attr('href');
						$('a.koszykfoto').css('background-image', src);
						$('a.koszykfoto').attr('href', href);
												
						var top = (($(window).height()) - $('#dokoszyka').height() - 15) / 2;
						
						if (top < 0) top = 0;
						
						$('#dokoszyka').css('margin-top', top);
						
						$('span.topilosc').html(data['sztuk'] + ' szt. / '+ data['suma'] + ' PLN');
						$('span.ilosc').html(data['sztuk'] + ' szt. / '+ data['suma'] + ' PLN');						
						$('span.model').html(data['nazwa']);
						$('span.producent').html(data['producent']);
						$('td.cena').html(data['cena'] + ' PLN');
										
						$("#dokoszyka").show();
					// nie udało się dodanie do koszyka
					} else {
						alert('Nie udało się dodać produtu dokoszyka!')
					}					
				}, "json");
			})
			
			$(window).scroll(function() {
				if ($('#zoomek:visible')) {
					var top = (($(window).height() + $(window).scrollTop() * 2) - $('#rela').height() - 15) / 2;
					if (top < 0) top = 0;
					$('#rela').css('top', top);
				}
				
				if ($('#dokoszyka:visible')) {
					var top = (($(window).height() + $(window).scrollTop() * 2) - $('#rela').height() - 15) / 2;
					if (top < 0) top = 0;
					$('#rela').css('top', top);
				}
			});
			
			$(".minifoto").bind('click', function(){
				
				var tag = $(this).attr('tag');
				if (tag != 'undefined' && tag != '') {
					
					$('.mousetrap').remove();
					$('#zoomek div.big').css('background-image', 'url(/media/gfx/admin/ajax_loader.gif)');
					$('#bigimg').parent().attr('href', '');
					$('#bigimg').attr('src', '');
					$('.cloud-zoom').CloudZoom();					
										
					var img = new Image();
					
					$(img).load(function(){
						//alert(tag);
						$('div.big').css('background-image', 'url(/media/gallery/medium/' + tag +')');
						$('#bigimg').parent().attr('href', '/media/gallery/big/' + tag);
						$('#bigimg').attr('src', '/media/gallery/medium/' + tag);
						$('.cloud-zoom').CloudZoom();
					}).attr('src', '/media/gallery/medium/' + tag);
				}				
			});			
			
			/*$("#rel").bind('click', function(){
				$(this).hide();
			});*/
			
			var options = {
					target:     '#login_ajax_box', 
					dataType:   'text',
					success:    function(komunikat) {
						if (komunikat == 'OK!') {
							if ($('#redirect').attr('value') != '') window.location = "<?php echo url::site(); ?>" + $('#redirect').attr('value');							
							else window.location = "<?php echo url::site('/admin'); ?>";
						}
						$('#login_ajax_box span').html(komunikat);
						var top = ( $('#loginForm #login').height() - $('#ajax_box span').height() - 15 ) / 2;
						$('#login_ajax_box span').css('margin-top', top);
						$('#login_ajax_box').fadeIn(200).delay(1500).fadeOut(200);
					}
				};
				
			var options2 = {
				dataType:   'json',
				beforeSubmit: function() {
					$('#register_ajax_box span').html('<img class="noframe" src="/media/gfx/ajax-loader.gif" alt="loading.." />');
					var top = ( $('#registerForm #register').height() - $('#ajax_box span').height() - 15 ) / 2;
					$('#register_ajax_box span').css('margin-top', top);
					$('#register_ajax_box').fadeIn(200);
				},
				success:    function(komunikat) {
					//if (komunikat['status'] == 1) window.location = "<?php echo url::site('/admin/'); ?>";
					$('#register_ajax_box span').html(komunikat['odp']);
					var top = ( $('#registerForm #register').height() - $('#ajax_box span').height() - 15 ) / 2;
					$('#register_ajax_box span').css('margin-top', top);
					$('#register_ajax_box').fadeIn(200).delay(1500).fadeOut(200);
				},
				error: function(odp){
					$('#register_ajax_box span').html('Nieznany błąd AJAX! ' + odp);
					var top = ( $('#registerForm #register').height() - $('#ajax_box span').height() - 15 ) / 2;
					$('#register_ajax_box span').css('margin-top', top);
					$('#register_ajax_box').fadeIn(200).delay(1500).fadeOut(200);
				}
			};
			
			var options3 = { 
					target:     '#daneForm .ajax_box',
					dataType:   'text',
					success:    function(komunikat) { 
						$('#daneForm .ajax_box span').html(komunikat);						
						var top = ( $('#daneForm .dane_dane').height() - $('#daneForm .ajax_box span').height() ) / 2;
						$('#daneForm .ajax_box span').css('margin-top', top);
						$('#daneForm .ajax_box').fadeIn(200).delay(2500).fadeOut(200);
					}
				};
			
			var optionsDaneF = { 
				target:     '#daneFormFaktura .ajax_box',
				dataType:   'text',
				success:    function(komunikat) { 
					$('#daneFormFaktura .ajax_box span').html(komunikat);						
					var top = ( $('#daneFormFaktura .dane_dane').height() - $('#daneFormFaktura .ajax_box span').height() ) / 2;
					$('#daneFormFaktura .ajax_box span').css('margin-top', top);
					$('#daneFormFaktura .ajax_box').fadeIn(200).delay(2500).fadeOut(200);
				}
			};  

			var optionsHaslo = { 
				target:     '#daneFormHaslo .ajax_box',
				dataType:   'text',
				success:    function(komunikat) { 
					$('#daneFormHaslo .ajax_box span').html(komunikat);						
					var top = ( $('#daneFormHaslo .dane_dane').height() - $('#daneFormHaslo .ajax_box span').height() ) / 2 - 20;
					$('#daneFormHaslo .ajax_box span').css('margin-top', top);
					$('#daneFormHaslo .ajax_box').fadeIn(200).delay(1500).fadeOut(200);
				}
			};
			
			var optionsEmail = { 
				target:     '#daneFormEmail .ajax_box',
				dataType:   'text',
				success:    function(komunikat) { 
					$('#daneFormEmail .ajax_box span').html(komunikat);						
					var top = ( $('#daneFormEmail .dane_dane').height() - $('#daneFormEmail .ajax_box span').height() ) / 2;
					$('#daneFormEmail .ajax_box span').css('margin-top', top);
					$('#daneFormEmail .ajax_box').fadeIn(200).delay(1500).fadeOut(200);
				}
			};
			
			var options_danew = {
				dataType: 'json',
				beforeSubmit: function() {
					$('#zapiszDaneWForm').find('.submit').addClass('ajax');
				},
				success:    function(odp) {
					$('#zapiszDaneWForm').find('.submit').removeClass('ajax');
					$('#zapiszDaneWForm').find('span.ajax').html(odp['email'] + '<br/>' + odp['dane']);
					$('#zapiszDaneWForm').find('span.ajax').fadeIn(200).delay(2500).fadeOut(200);
				},
				error: function (xhr, ajaxOptions, thrownError){
					$('#zapiszDaneWForm').find('.submit').removeClass('ajax');
                    alert(xhr.status);
                    alert(xhr.responseText);
					$('.ajax_b').css('display', 'none');
					$('.ajax_b2').css('display', 'none');
                }
			};
			
			var options_danef = {
				dataType: 'json',
				beforeSubmit: function() {
					$('#zapiszDaneFForm').find('.submit').addClass('ajax');
				},
				success:    function(odp) {
					$('#zapiszDaneFForm').find('.submit').removeClass('ajax');					
					$('#zapiszDaneFForm').find('span.ajax').html(odp['dane']);
					$('#zapiszDaneFForm').find('span.ajax').fadeIn(200).delay(2500).fadeOut(200);
				},
				error: function (xhr, ajaxOptions, thrownError){
					$('#zapiszDaneFForm').find('.submit').removeClass('ajax');
                    alert(xhr.status);
                    alert(xhr.responseText);
					$('.ajax_b').css('display', 'none');
					$('.ajax_b2').css('display', 'none');
                }
			};
			
			var options_daneh = {
				dataType: 'json',
				beforeSubmit: function() {
					$('#zapiszHasloForm').find('.submit').addClass('ajax');
				},
				success:    function(odp) {
					$('#zapiszHasloForm').find('.submit').removeClass('ajax');					
					$('#zapiszHasloForm').find('span.ajax').html(odp['haslo']);
					$('#zapiszHasloForm').find('span.ajax').fadeIn(200).delay(2500).fadeOut(200);
				},
				error: function (xhr, ajaxOptions, thrownError){
					$('#zapiszHasloForm').find('.submit').removeClass('ajax');
                    alert(xhr.status);
                    alert(xhr.responseText);
					$('.ajax_b').css('display', 'none');
					$('.ajax_b2').css('display', 'none');
                }
			};
			
			$('#loginForm').ajaxForm(options);
			$('#daneForm').ajaxForm(options3);
			$('#daneFormEmail').ajaxForm(optionsEmail);
			$('#daneFormHaslo').ajaxForm(optionsHaslo);
			$('#daneFormFaktura').ajaxForm(optionsDaneF);
			$('#registerForm').ajaxForm(options2); 
			$('#zapiszDaneWForm').ajaxForm(options_danew);
			$('#zapiszDaneFForm').ajaxForm(options_danef);
			$('#zapiszHasloForm').ajaxForm(options_daneh);
			
			
			// Wyłączarka banera Imperium
			$("div.bezryzyka a").bind('click', function(){
				$("div.bezryzyka").hide();
				$.post("index.php/ajax/wylaczBaner");
			});
			
        });
	    
		$.fn.delay = function( time, name ) {

			return this.queue( ( name || "fx" ), function() {
				var self = this;
				setTimeout(function() { $.dequeue(self); } , time );
			} );		
		};
		
		// nie tylko zmieniamy sumę, ale też wczytujemy dostępne dla tej formy
		// wysyłki, formy płatności 
		function changeSum(id) {
			// pokazujemy Ajax loader
			$("#ajax_dostawa").show();
			
			$.post("index.php/ajax/zmienKoszty", {id: id}, function(data){
				// wszystko OK!
				
				if (data['status'] == 1) {
					$('#suma').html(data['kosztp']);
					$('#kosztd').html(data['kosztdp']);
					$('#koszt').attr('value', data['koszt']);
					$('#koszt_d').attr('value', data['kosztd']);
					
					
					// usuwamy formy płatności i wczytujemy dostępne
					// ze zmiennej platnosci tworzymy tablicę (albo dwie)
					// musimy mieć id i nazwę formy płatnośći
					//dane = 'cos1;cos2;cos3;cos4';
					//tablica = dane.split(";");
							
					$('#platnosc_options').empty();
					for(i in data['platnosci']) {
						//e = e + data['platnosci'][i]['nazwa'] + '\n';						
						$('#platnosc_options').append('<option value="' + data['platnosci'][i]['id'] +'">' + data['platnosci'][i]['nazwa'] + '</option>');
					}
					//alert(e);
				// nie udało się coś.
				} else {
					alert(data['odp']);
				}
				// chowamy ajax loader
				$("#ajax_dostawa").delay(1500).hide();				
			}, "json");
		}
		
		function usunPozycje(id) {		
			
			var rabat = 0;
			if ($("input#rabat").attr('value') != 'undefined' && $("input#rabat").attr('value') != '' && $("input#rabat").attr('value') != 0) {
				var rabat = $("input#rabat").attr('value');
			}		
			var idz = $('input#idz').attr('value');
			
			$.post("index.php/ajax/usunPozycje", {id: id, rabat: rabat, idz: idz}, function(data){
				if (data['status'] == 1) {
					$('#usun'+id).parent().parent().remove();				
					$('#usunk'+id).parent().parent().remove();
					$('#suma').html(data['sumap'] + ' PLN');
					$('#sumai').attr('value', data['suma']);
					if (data['idz'] == 0) $('span.topilosc').html(data['sztuk'] + ' szt. / '+ data['sumap'] + ' PLN');
					$("#minikoszyk").hide();
				// nie udało się dodanie do koszyka
				} else {
					alert('Nie udało się usunąć produktu z koszyka!')
				}					
			}, "json");			
		}
				
		function zmienIlosc(ob, id) {
			var rabat = $("input#rabat").attr('value');
			if (rabat != 'undefined' && rabat != '') {
				rabat = rabat;
			} else {
				rabat = 0;
			}				
						
			var sztuk = $(ob).attr('value');
			$.post("index.php/ajax/zmienIlosc", {id: id, sztuk: sztuk, rabat: rabat}, function(data){
				$('#koszt'+id).html(data['koszt'] + ' PLN');
				$('#suma').html(data['sumap'] + ' PLN');
				$('#sumai').attr('value', data['sumap']);
				$('span.topilosc').html(data['sztuk'] + ' szt. / '+ data['sumap'] + ' PLN');												
			}, "json");		
		}
		
		function edytujPozycje(id, ile) {
			$.post("index.php/ajax/edytujPozycje", {id: id, ile: ile}, function(data){
				// wszystko OK!
				if (data['status'] == 1) {
					$('#suma').html(data['koszt']);
					$('#kosztd').html(data['kosztd']);
					$('.count2').html(data['sztuk']);
					$('.suma2').html(data['suma']);
					$('#sztuk'+id).html(data['ile']);
					
					// o ile zmienił się koszt
					//$('#koszt').attr('value', ($('#koszt').attr('value') + (data['cena'] * ile)));
					
					if (data['ile'] == 0) {
						$('#pozycja' + id).hide();
					}
					else {
						$('#sztuk' + id).html(data['ile']);
						$('#wartosc' + id).html(data['wartosc']);
					}
					
					// sprawdzamy forme przesyłki
					var przesylka = $("input[@name='dostawa']:checked").val();
					changeSum(przesylka);
				// nie udało się coś.
				} else {
					alert(data['odp']);
				}				
			}, "json");
		}
		
		function UkryjRel() {
			$('#rela').hide();
			$('div.tlo').hide();	
		}
		
		function UkryjSwieta() {
			$("#swieta").hide();
			var id = 0;
			$.post("index.php/ajax/ukryjSwieta");	
		}

		
		function Odkoduj(kod) {
			var kodzik = $.base64Decode(kod);
			alert(kodzik);
		}

