	var anim = 0;
	var zk = null;
	var sub_pos = 0;
	
	function getMouseXY(e) {
	  if (IE) { // grab the x-y pos.s if browser is IE
	    tempX = event.clientX + document.body.scrollLeft
	    tempY = event.clientY + document.body.scrollTop
	  } else {  // grab the x-y pos.s if browser is NS
	    tempX = e.pageX
	    tempY = e.pageY
	  }  
	  // catch possible negative values in NS4
	  if (tempX < 0){tempX = 0}
	  if (tempY < 0){tempY = 0}  
	  return [tempX, tempY];
	}

	if (navigator.appName == "Microsoft Internet Explorer") var IE = true;
																		else var IE = false;
	if (IE) var speed = 100;
		else var speed = 300;
		
			$(document).ready(function() {
				function WczytajZakladke(id) {
					$.ajax({
						type: "POST",
						url: "inc/zakladka.php",
						data: "id=" + zk,
						success: function(odp){
							odp = odp.split('b6ba4b60e0ad0d540995efd2534b50af');
							$("#zakladki_loading").css("display", "none");
							$("#zakladki_tresc").html(odp[0]);
							$("#sciezkaTabName").html('&nbsp;&nbsp;/&nbsp;&nbsp;' + odp[1]);
					 		$("#zakladki_tresc").prepend('<div class="pusty"></div>');
							$("#zakladki_tresc").animate({height: 'show', opacity: 'show'}, "slow", null, function(){});
																																		if (odp[2] == 'cen') {
																																				$(document).ready(function(){
																																					if ($.browser.msie) {
																																						$('#zakladki_tresc .cennik_prod').css('float', 'left');
																																						$('#zakladki_tresc .cennik_tab').css('float', 'left');
																																					}
																																				});
																																		}
						}
					});
				}
				
				function Pozycja(obj) {
					tab = obj.parent().children('a');
					p = 0;
					for (i=0;i<tab.length;i++) {
//						alert(obj.prev().attr('name'));
						if (obj.prev().attr('name') == tab[i].name) p = i + 1;
					}
					return p;
				}
				
				$("#zakladki_loading").ajaxStart(function(){
						$(this).css("display", "block");
						$("#zakladki_tresc .pusty").remove();
				});
				if (IE) $("#zakladki_tresc").css("width", "565px");
				
				/* LightBox */
				
				$("#tresc_p A IMG").parent().lightBox();
				$("#tresc_p A IMG").parent().attr("title", "Kliknij z boku zdjęcia aby zobaczyć następne.");
				
				/* Wstępna aktywacja zakładki */
				
				zk = $("#zakladki_menu a:first-child").attr("name");
				$("#zakladki_menu a:first-child").css({backgroundColor: "#D8EBF9", color: "#013976"});
				$("#zakladki_menu a:first-child .tab_text").wrap('<p class="tab_corner3a"></p>');
				$("#zakladki_menu a:first-child .tab_text").wrap('<p class="tab_corner2b"></p>');
				$("#zakladki_menu a:last-child .tab_text").wrap('<p class="tab_corner1b"></p>');
				$("#zakladki_tresc").each(function(){WczytajZakladke(zk);});
				
				/* Aktywacja aktualnej pozycji menu głównego */

				if ($("#menu .bt_akt").length > 0) {
					$("#menu .buttons a:last-child").css("background-image", "url()");
					$("#menu .bt_akt").css("background-image", "url('img/" + $("#menu .bt_akt").attr("class").substr(0, 4) + ".gif')");
					$("#menu .bt_akt").prev().css("background-image", "url()");
				}
				
				/* Obsługa Podmenu Oferty */
				
				$(".menu2_sub A").css("color", "yellow");
				$(".menu2_sub A").hover(function(){$(this).css("color", "#F79027")}, function(){$(this).css("color", "yellow")});
				$(".button, .button2").mouseover(function(e){
					var obj = $("#menu2_sub" + $(this).attr("name"));
					poz = getMouseXY(e);
					obj.css({left: (poz[0] - 20) + "px", top: (poz[1] - 20) + "px"});
					obj.css("display", "block");
				});
				$(".menu2_sub").hover(function(e){}, function(){
						$(".menu2_sub").css("display", "none");
					}
				);
				
				/* Obsługa zakładek produktu */
				
				$("#zakladki_menu A").click(function(){
					if (zk != $(this).attr("name")) {
						tab_first = $("#zakladki_menu A:first-child").attr("name");
						tab_last = $("#zakladki_menu A:last-child").attr("name");
						
							/* Wyłączanie aktywności zakładki */
							
						$('#zakladki_menu A[name="' + zk + '"]').css({backgroundColor: "", color: "#FEFEFE"});
						$('#zakladki_menu A[name="' + zk + '"]').html($('#zakladki_menu A[name="' + zk + '"] span').parent().html());
							if (zk == tab_first) {
								$('#zakladki_menu A[name="' + zk + '"] .tab_text').wrap('<p class="tab_corner1a"></p>');
							} else if (zk == tab_last) {
								$('#zakladki_menu A[name="' + zk + '"] .tab_text').wrap('<p class="tab_corner1b"></p>');
							}
							
							/* Aktywowanie nowej zakładki */
							
						$(this).css({backgroundColor: "#D8EBF9", color: "#013976"});
						zk = $(this).attr("name");
							if (zk == tab_first) {
								$('#zakladki_menu A[name="' + zk + '"] .tab_text').wrap('<p class="tab_corner3a"></p>');
							} else {
								$('#zakladki_menu A[name="' + zk + '"] .tab_text').wrap('<p class="tab_corner2a"></p>');
							}
							if (zk == tab_last) {
								$('#zakladki_menu A[name="' + zk + '"] .tab_text').wrap('<p class="tab_corner3b"></p>');
							} else {
								$('#zakladki_menu A[name="' + zk + '"] .tab_text').wrap('<p class="tab_corner2b"></p>');
							}
						$("#zakladki_tresc").animate({height: 'hide', opacity: 'hide'}, "slow", null, function() {WczytajZakladke(zk);});
					}
				});
				
				/* Obsługa formularza kontaktowego */
				
				$('#formAlert').ajaxStart(function(){$(this).html('<img src="img/preload2.gif">')});
				$('#formularz').submit(function(){
					$.ajax({
						type: "POST",
						url: "inc/sendMail.php",
						data: "nazwisko=" + $('input[name=nazwisko]').val() + "&firma=" + $('input[name=firma]').val() + "&telefon=" + $('input[name=telefon]').val() + "&mail=" + $('input[name=mail]').val() + "&tresc=" + $('textarea[name=tresc]').val(),
						success: function(odp) {
							if (odp == 'OK') {
								$('#formAlert').text('Wiadomość została wysłana');
								$('#formAlert').css('color', '#DBF556');
								
							} else if (odp == '<!01!>') {
								$('#formAlert').css('color', '#F2522E');
								$('#formAlert').text('Nie wszystkie pola zostały wypełnione');
							} else if (odp == '<!02!>') {
								$('#formAlert').css('color', '#F2522E');
								$('#formAlert').text('Błąd wysyłania maila');
							}
						},
						error: function() {
							$('#formAlert').css('color', '#F2522E');
							$('#formAlert').text('Błąd ogólny!');
						}
					});
					return false;
				});
				
				
				if ($('#top').children().length == 0) {
					kat = $("#top").attr('name');
				   if (!kat) var so = new SWFObject("fla/baumatt_8.swf", "mymovie", "962", "260", "8", "#000000");
							  else if (kat == 69) var so = new SWFObject("fla/baumatt_69.swf", "mymovie", "962", "260", "8", "#000000");
							  else var so = new SWFObject("fla/top.swf?kat=" + kat, "mymovie", "962", "260", "8", "#000000");
				   so.addParam("wmode", "transparent");
				   so.write("top");
				}
			});
