/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options = $.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // NOTE Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

function MM_reloadPage(init){  //reloads the window if Nav4 resized
if(init==true) with(navigator){if((appName=="Netscape")&&(parseInt(appVersion)==4)){
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if(innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d){ //v4.0
var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length){
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for(i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers(){ //v3.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for(i=0; i<(args.length-2); i+=3) if((obj=MM_findObj(args[i]))!=null){ v=args[i+2];
if(obj.style){ obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
obj.visibility=v; }
}

function MM_swapImgRestore(){ //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages(){ //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if(a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage(){ //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function zoom(plik){
config='toolbar=no,location=no,directories=no,status=no,menubar=no,width=520,height=520'
config += 'scrollbars=yes,resizable=no'
pop = window.open("","pop",config)
pop.document.write('<script language="javascript">');
pop.document.write('setTimeout(');
pop.document.write('"self.close()');
pop.document.write(';",30000)');
pop.document.write('</script>');
pop.document.write('<body><table height=100% align=center valign=middle><tr><td>');
pop.document.write('<img src="http://www.max24.pl/foto_max/'+plik+'" onclick="window.close()">');
pop.document.write('</td></tr></table></body>');
pop.focus();
pop.document.close();
}

function zoom_aukcja(plik){
config='toolbar=no,location=no,directories=no,status=no,menubar=no,width=520,height=520'
config += 'scrollbars=yes,resizable=no'
pop = window.open("","pop",config)
pop.document.write('<script language="javascript">');
pop.document.write('setTimeout(');
pop.document.write('"self.close()');
pop.document.write(';",30000)');
pop.document.write('</script>');
pop.document.write('<body><table height=100% align=center valign=middle><tr><td>');
pop.document.write('<img src="../'+plik+'" onclick="window.close()">');
pop.document.write('</td></tr></table></body>');
pop.focus();
pop.document.close();
}

function kopiuj(){
var f1 = document.forms.f;
f1.data[f_imie].value = f1.data[imie].value;
}

function noweokno(plik,wdth,hght,scrollbrs){
var wx = Math.ceil((window.screen.width-wdth) / 2 );
var wy = Math.ceil((window.screen.height-hght) / 2 );
var nwo;
if(scrollbrs==1){nwo=window.open(plik,'','width='+wdth+',height='+hght+',resizable=0,scrollbars=yes,menubar=no');}
else{nwo=window.open(plik,'','width='+wdth+',height='+hght+',resizable=0,scrollbars=no,menubar=no');}
}

function sprawdz(){
var p4=document.checkout.p4;
if(p4.value.length<9){alert("Proszę podać swój numer telefonu");p4.focus();return false}}

function sprawdz_szukaj(){
var slowo=document.szukaj.q
if(slowo.value.length<2){alert("Proszę wpisać co najmniej 2 znaki");slowo.focus();return false}}

function sprawdz_negocjacje(){
var slowo=document.negocjuj.cena.value;
if(slowo.length<2){alert("Prosze zaproponować cenę");return false}}

function drukuj(){
if(((navigator.appName.indexOf("Microsoft Internet Explorer")>=0) && (parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE")+5, navigator.appVersion.indexOf("MSIE")+8))>4.0)) || (navigator.appName.indexOf("Netscape")>=0))
this.window.print();
else alert('Przegladarka nie umożliwia drukowania');
}

function getElement(el){
return (document.all) ? document.all[el] : document.getElementById(el);
}

function checkBtnOnOff(){
if(document.searcher.o.checked==true) document.searcher.o.checked=false;
else document.searcher.o.checked=true;
}

function showMore(id,id2){
var d=document.getElementById(id);
var e=document.getElementById(id2);
for(var i=1;i<=10;i++){
if(document.getElementById('hidden'+i)){document.getElementById('hidden'+i).style.display='none';}
if(document.getElementById('a'+i)){document.getElementById('a'+i).style.display='block';}
}
if(d){d.style.display='block';}
if(e){e.style.display='none';}
}

/* Popupowe obrazki */

var a=document.getElementsByTagName('a');

function showFoto(img){
var foto=new Image();
foto.src=img;
control(img);
}

function control(img){
if((foto.width!=0)&&(foto.height!=0)) goFoto(img);
else{func="control('"+img+"')";setTimeout(func,20);}
}

function goFoto(img){
var iwidth=foto.width+20;
iheight=foto.height+20;
parametr="width="+iwidth+",height="+iheight;
newWin=window.open("",'Obrazek',parametr);
newWin.document.open();
newWin.document.clear();
newWin.document.write("<html><head><title>Obrazek<\/title><\/head><BODY><a title='Zamknij...' href='javascript:window.close()'><img src="+img+" alt=' Zamknij ' border=0><\/a><\/body><\/html>");
newWin.document.close();
newWin.focus();
}

function getPopup(){
for(i=0; i < a.length; i++) if(a[i].className.indexOf('popup') != -1){
path1 = a[i].href;
a[i].href="javascript:showFoto('"+path1+"');";}
}

function Chmurka(T,t){
T.title='';
T.parentNode.lastChild.style.display=t?'block':'none';
}

function info(id){
var no=window.open('./?a=sklep.informacjaOpis&id='+id,'info','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=360,height=210,top=0,left=0')
no.focus()
return false
}

function info2(id){
var no=window.open('./?a=sklep.informacjaOpisCechy&id='+id,'info','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=360,height=210,top=0,left=0')
no.focus()
return false
}

function info_tech(id){
var no=window.open('./?a=sklep.informacjaOpisTech&id='+id,'info','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=360,height=210,top=0,left=0')
no.focus()
return false
}

function zoom_rpc(id){
var no=window.open('./?a=sklep.viewPhoto&id='+id,'foto','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=800,top=0,left=0')
no.focus()
return false
}

function js_mail(a,z){var m='mail',d='.';a=a+'@'+'max'+'24'+d+'pl';var za=(typeof(z)=='string')?('<'+z+'>'+a+'</'+z+'>'):a;document.write('<a href="'+m+'to:'+a+'">'+za+'</a>')}

function okno_konsultant() {
window.open("zamow_rozmowe.php?id=0&nazwa=PYTANIE O TRANSPORT MAX24","PYTANIE O TRANSPORT MAX24","toolbar=no,height=470px,width=420px");
}




$(document).ready(function(){


	if($.browser.msie){

		$('td:empty,p:empty').addClass('empty');
	}



		$('#wybor-kat').hover(function()
			{
				$(this).click(function()
				{
					$('#kategorie').show();
				});
			},
		function()
			{ $('#kategorie').hide(150); });


		$("#pomoc #pomoc-content").children("p").hover(
		function()
		{
			$(this).addClass(" aktywny");
			$("#pomoc #pomoc-content").children("p").not(this).removeClass("aktywny");
			$(this).next("ul").slideDown("fast");
			$("#pomoc #pomoc-content").find("p").not(this).next("ul").slideUp("fast");

		}, function() {  }
		);

		$("#wydarzenia ul").children("li").mouseover(
		function()
		{
			$(this).addClass(" active").children(".wydarzenia-img").show();
			$("#wydarzenia ul").children("li").not(this).removeClass("active").children(".wydarzenia-img").hide();
		});

		$('#info-miasta').hover(function(){$('#info-miasta div').show(); $('#info-miasta').addClass("active-miasta"); }, function(){$('#info-miasta div').hide(150); $('#info-miasta').removeClass("active-miasta");});



		/* Slidery */
		$("#banner-top").slider({slideAnimate:true,slideHide: 1750,slideShow: 500});
		$(".banner-start").slider({slideAnimate:true,slideHide: 500,slideShow: 500});

		//$(".product-tabs").children(".tab-content:first").show();
		//$(".product-tabs ul.tabs").children("li:first").children("a").addClass("active");
		$(".product-tabs ul.tabs").children("li").click(function()
			{
				var karta = $(this).attr("id");
				$(".product-tabs").children("div."+karta).show();
				$(".product-tabs").children(".tab-content").not("."+karta).hide();
				$(this).children("a").addClass("active");
				$(".product-tabs ul.tabs").children("li").not(this).children("a").removeClass("active");
				return false;
			}
			);

		$(".ceny ul li span").children("a").click(function()
			{
				var link = $(this).attr("class");
				$(".product-tabs").children("div."+link).show();
				$(".product-tabs").children(".tab-content").not("."+link).hide();
				$(".product-tabs ul.tabs").children("li#"+link).children("a").addClass("active");
				$(".product-tabs ul.tabs").children("li").not("li#"+link).children("a").removeClass("active");
			}
			);

		$(".dostawa").children("a").click(function()
			{
				var link2 = $(this).attr("class");
				$(".product-tabs").children("div."+link2).show();
				$(".product-tabs").children(".tab-content").not("."+link2).hide();
				$(".product-tabs ul.tabs").children("li#"+link2).children("a").addClass("active");
				$(".product-tabs ul.tabs").children("li").not("li#"+link2).children("a").removeClass("active");
			}
			);

		$(".product-tabs ul.tabs li:nth-child(6n)").addClass("last");

		$(".lista-produktow-2kol .product:nth-child(2n)").after("<div class='clear-line'></div>");
		$(".lista-produktow-2dkol .product:nth-child(2n)").after("<div class='clear-line'></div>");
		$(".lista-produktow-3kol .product-line .product:nth-child(3n)").addClass("product-last").after("<div class='clear-line'></div>");
		$(".lista-produktow-content div.clearer").prev(".clear-line").remove();
		$(".top10 .product-line .product:nth-child(3n)").addClass("product-last").after("<div class='clear-line'></div>");

		$(".products-container .tabela-porownanie tr td:nth-child(2n)").addClass("odd");

		$(".container-cart .dane").children("#lnewsletter").hide();

		$(".container-cart .select3 input.radio").click( function(){
			if($(this).is("#flogin2") == true){
				$(".container-cart").find(".ukrywane").hide();
			}
			else if($(this).is("#flogin3") == true){
				$(".container-cart").find(".ukrywane").show();
				$("#bezlog_email").show();
			}
			else {
				$(".container-cart").find(".ukrywane").show();
				$("#bezlog_email").hide();
			}
		});

		$(".container-cart .select3 input#flogin1").click( function(){
			$(".dane-content").addClass("nowyklient");
			$(".container-cart .dane").children("#lnewsletter").show();
		});

		$(".container-cart .select3 input.radio").not("#flogin1").click( function(){
			$(".dane-content").removeClass("nowyklient");
			$(".container-cart .dane").children("#lnewsletter").hide();
		});

		$("input#fdaneinvoice").click( function(){
			if($(this).is("input:checked") == true){
				$("#invoiceForm").hide();
			} else { $("#invoiceForm").show(); }
		});

		$(".box-left .box-left-content").children("ul.category-expanded").find("li:last").children("h5").children("a").addClass("last");
		$("#dostepne-kategorie #dostepne-kategorie-content ul#dostepne-kategorie-lista").children("li:last").not(".clearer-line").addClass("last");
		$("#dostepne-kategorie #dostepne-kategorie-content ul#dostepne-kategorie-lista").children("li:nth-child(5n)").prev("li").addClass("last");
		$(".product-right .best").children("li:last").addClass("last");
		$(".mapa").children(".mapa-cat:last").addClass("last");
		$(".cart-top ul.cart li.item1 span").css({"margin-top":((65-$(".cart-top ul.cart li.item1 span").height())/2)});
		$("#nav-aukcje div:nth-child(7n)").addClass("ost");

		$("ul.wyszukane li").children("span").click(function () {
      		$(this).next("ul").children("li").toggle();
    	});

    	$(".advleft ul li").children("span").children("b").click(function () {
      		$(this).parent("span").next("ul").toggle();
      		$(this).hide();
			$(this).parent("span").children("b").not(this).show();
    	});

    	$("ul.wyszukane li").children("span").children("b").click(function () {
      		$(this).parent("span").next("ul").toggle();
      		$(this).hide();
			$(this).parent("span").children("b").not(this).show();
    	});

		for(i = 0; i < $(".promotion-products-content").children(".promotion-product").size(); i++) {
			$(".promotion-products-content").children(".promotion-product").eq(i).addClass("item" + i);
			$("#promotion-products").children("ul").children("li").children("a").eq(i).addClass("item" + i);
		}

		$("#promotion-products ul li:first").addClass("active");

		$("#promotion-products ul li").children("a").mouseover(function()
		{
			var promproduct = $(this).attr("class");
			$(".promotion-products-content").children("."+promproduct).show();
			$(".promotion-products-content").children(".promotion-product").not("."+promproduct).hide();
			$("#promotion-products ul").children("li").removeClass("active");
			$(this).parent("li").addClass("active");

		});

    	$(".promotion-products-cat").css({"margin-top":((158-$(".promotion-products-cat").height())/2)});

    	$(".promotion-products-content .promotion-products-img").children('a').wrap('<table><tr><td></td></tr></table>');

    	$("#dostepne-kategorie-lista").css({"padding-left":((758-$("#dostepne-kategorie-lista").width())/2)});

		$('.info-tbl-mod table tbody').each(function(){
			$(this).children('tr').each(function(t){
				$(this).addClass('item-'+t%2);
			});

		});



		/* Przeładowanie i powiększanie zdjęć na karcie produktu */

		$('#zdjecie_href').ready(function(){

			var
				root = $('#zdjecie_href');
				chain = $(document).find('.gallery');
				chainItem = chain.children('li');

				/* dobiera się do każdego zdjęcia z galerii */
				chainItem.each(function(cnt){

					var
						iLink = $(this).children('a');
						iHref = iLink.attr('href');
						iSrc = iLink.children().attr('rel');
						iAlt = iLink.children().attr('alt');

					/* wstawia średnie zdjęcia do pośrdniego powiekszenia */
					if(cnt>0){
						root.append('<a class="produkt-img" href="'+iHref+'"><img src="'+iSrc+'" alt="'+iAlt+'" /></a>');
						root.children('a').eq(cnt).hide();
					}

					/* ustawia proste odwołanie */
					root.children('a').eq(cnt).attr('callback',cnt);

					/* wywołuje średniej wielkości zdjęcia */
					iLink.mouseover(function(){
						root.children('a').hide();
						root.children('a').eq(cnt).show();
					});
				});

				/* wywołuje powiększenie na zdjęcie z galerii */
				root.children('a').click(function(e){
					e.preventDefault();
					cnt = $(this).attr('callback')

					chainItem.eq(cnt).children('a').trigger('click');

				});

				/* ustawia powiększenie na zdjęcia z galerii */
				chainItem.children().fancybox({
					'padding': 0,
					'imageTitle': false,
					'imageScale': true,
					'zoomOpacity' : true,
					'zoomSpeedIn' : 500,
					'zoomSpeedOut' : 500,
					'centerOnScroll': false
				});
		});



		/* raty */


		var ratyCena = $('#item-price').val();
		if(ratyCena){
			ratyCena = ratyCena.replace('zł','');
			ratyCena = ratyCena.replace(/\s+/,'');
			$('#rata-wolumen').val(ratyCena);
		}

		function raty(id, firma, procent_widelki, prog){

			var c, o,p,qp,r,s,t,u,w;
			empty_id = id;
			id = '#'+id;
			c = $('#item-price').val();
			if(c){
				c = c.replace('zł','');
				c = c.replace(/\s+/,'');


				o = 100;
				//o = parseInt(o);// minimalna wartość towaru objęta ratami
				p = $(id+'-wolumen').val();
				p = parseInt(p);// wartość produktu
				q = $('#rata-ilosc').attr('value');
				//q = parseInt(q);// ilość rat
				r = $(id+'-kwota-bazowa').val();
				r = parseInt(r);// wpłata własna
				s = p-r;
				if (s < 0)
					s = 0;
				//s = parseInt(s);// różnica wartości towaru od wpłaty własnej - podstawa ratalna
				//t = 10;
				//t = parseInt(t);// oprocentowanie rat
				//u = 1;
				//u = parseInt(u);// prowizja od rat

				//u = (s/q)/100*t; // prowizja dla jednej raty
				//u =+ u.toFixed(2);

				//w = (s/q)+u; // kwota raty
				//w =+ w.toFixed(2);

				if(q < 20){
					pu = 5;
					pk = 8;
				}else if(q >= 30){
					pu = 5;
					pk = 11;
				}else{
					pu = 3;
					pk = 9;
				}

				u = 1+q*pu/1000;
				w = s*u*(1+pk/1000*q*u)/q;
				w =+ w.toFixed(2);

				/* usun podstawowe anomalia */
				if(w == r || r >= p)
					w = 0;

				if(!(isNaN(w) || q == 0)) {
					/* pokaż raty jeżeli wartość towaru jest większa od wymaganego progu ratalnego */
					if(c > o){
						id= '#raty-kalkulator';
						$(id+' .rata strong').remove();
						$(id+' .rata strong span').remove();
						$(id+' .rata').append('<strong> zł</strong>');
						$(id+' .rata strong').prepend('<span> '+w+'</span>');
						$(id+' input').attr('disabled','');
						if($('#raty-kalkulator div>p').is(id+'-error') == true)
							$('#raty-kalkulator div '+id+'-error').remove();
					}
					else {
						id= '#raty-kalkulator';
						$(id+' .rata strong').remove();
						$(id+' .rata').append('<strong>Niedostępna</strong>');
						$(id+' input').attr('disabled','disabled');
						if($('#raty-kalkulator div>p').is('.error') == false)
							$('#raty-kalkulator div').prepend('<p id="'+empty_id+'-error" class="error">Żeby móc skorzystać z rat w systemie '+firma+' minimalna wartość towaru musi wynosić '+prog+'zł</p>');
					}
				}
			} // if(c)
		} // raty()

		/* prog jest ustawiony na zero, żeby klient mogł swobodnie dokonywać obliczeń cena/rata */

		$('#raty-kalkulator .text').bind('keyup', function(){
			raty('rata','LUKAS', 0, 0); return false;
		});
		$('#raty-kalkulator select').bind('change', function(){
			raty('rata','LUKAS', 0, 0); return false;
		});
		raty('rata','LUKAS', 0, 0);

	$('#infolinia').ready(function(){
		$('#infolinia dl').each(function(){
			$(this).children('dt').each(function(t){
				if(t%2 == 0)
					$(this).addClass('odd');
				else
					$(this).addClass('even');
			});
		});
	});

	$('#konsultanci').ready(function(){
		$('#konsultanci ul').each(function(){
			$(this).children('li').each(function(l){
				l = l%3;

				$(this).addClass('i-'+l);
			});
		});
	});

	$('#obsluga-sklepu').ready(function(){
		$('#obsluga-sklepu ul li.col').each(function(l){
				l = l%4;

				$(this).addClass('col-'+l);
		});
	});

	/* wyświetlanie opisu dostepnosci */
	$('#dostepnosc_info').mouseover( function() {
		$('#dostepnosc_opis').css('display', 'block');
	});
	$('#dostepnosc_info').mouseout( function() {
		$('#dostepnosc_opis').css('display', 'none');
	});
	$('#dostepnosc_info').bind('mousemove', function(e) {
		$('#dostepnosc_opis').css('top', e.pageY - 10);
		$('#dostepnosc_opis').css('left', e.pageX + 20);
		//$('#dostepnosc_opis').text("e.pageX: " + e.pageX + ", e.pageY: " + e.pageY);
	});

});

jQuery.fn.slider = function(option) {
	option = jQuery.extend({
		slideAnimate: false,
		slideInterval: 6000,
		slideHide: 1750,
		slideShow: 1000
	}, option);

	return this.each(function(i){

		a = $(this);
		b = a.find('.navi');
		c = b.find('a');
		d = c.size();

		e = a.find('.prevPage');
		e.attr('href',d-1);
		f = a.find('.nextPage');
		f.attr('href',1);

		g = a.find('.items');
		h = g.find('.item');

		/*
		*/
		h.hide();
		h.eq(0).show().addClass('act');

		i=0;
		/*
		h.eq(0).attr('id','act');
		element = document.getElementById('act');

		element.style.opacity = '.1';
		*/


		c.click(function(e){
			e.preventDefault();
			i = $(this).attr('href');
			animSlider(i);
		});

		e.click(function(e){
			e.preventDefault();
			i = $(this).attr('href');
			animSlider(i);
		});

		f.click(function(e){
			e.preventDefault();
			i = $(this).attr('href');
			animSlider(i);
		});

		function setAnimation(){
			i = f.attr('href');
			animSlider(i);
		}


		function animSlider(i){

			i = parseInt(i);

			if(i == d){
				i=0;
				iPrv = d-1;
				iNxt = i+1;
			}
			if(i == 0){
				iPrv = d-1;
				iNxt = 1;
			}
			else{
				iPrv = i-1;
				iNxt = i+1;
			}

			c.removeClass('active');
			c.eq(i).addClass('active');



			g.find('.act').fadeOut(option.slideSpeed, function(){
				$(this).removeClass('act');
				h.eq(i).fadeIn(option.slideSpeed, function(){
					$(this).addClass('act');
				});
			});

			e.attr('href',iPrv);
			f.attr('href',iNxt);

		} // function

		if(option.slideAnimate){
			si = setInterval(setAnimation, option.slideInterval);
		} // if(option.slideAnimate)

		if(si){
			a.mouseover(function(){
				clearInterval(si);
			});

			a.mouseout(function(){
				si = setInterval(setAnimation, option.slideInterval);
			});
		}// if(si)
	}); // each
}


	function dotb(title, url)
		{
			$(document).ready(function(){ tb_show(title, url, null); });
		}

function _$(id){var D=document;return D.getElementById?D.getElementById(id):D.all?D.all[id]:null;}
function cartWindowDisplay(hstr,cstr){
	tb_show('', '#TB_inline?height=200&width=500&inlineId=windowcart', null);
	var h=_$('windowcart-head'),c=_$('windowcart-prod');
	if(h){h.innerHTML=hstr;}else{alert(h);}
	if(c){c.innerHTML=cstr;}
}
var cart_ajax_sending=false;
function cartAddAjax(action,product_id){
	if(cart_ajax_sending){
		return false;
	}
	var i,n,el,fr=document.forms['fparametry'],ir=0,p='';
	if((typeof(fr)!='undefined')&&(typeof(fr.parametr_id)!='undefined')){
		el=fr.parametr_id;
		if ((typeof(el.type)=='string')&&(el.type=='select-one')){ //select
			p+='&parametr_id='+el.options[el.selectedIndex].value;
		}
		else{ //radio
			for(i=0,n=el.length;i<n;++i){
				if(el[i].checked){ir=el[i].value;break;}
			}
			p+='&parametr_id='+ir;
		}
	}
	$.ajax({
		type: 'GET',
		url: './',
		data: 'a=cart.'+action+'Ajax&produkt='+product_id+p,
		dataType: 'xml',
		cache: false,
		beforeSend: function(request){cart_ajax_sending=true;cartWindowDisplay('Proszę czekać','Odczytywanie danych z serwera. Proszę czekać ...');},
		error: function(request,textStatus,errorThrown){cart_ajax_sending=false;cartWindowDisplay('Błąd przy odczycie danych z serwera','');},
		success: function (response){
			cart_ajax_sending=false;
			var odp=response.getElementsByTagName('odp'),e,b,k,p,cp=_$('cartPanel');
			if(odp){
				e=response.getElementsByTagName('blad');
				b=e[0].childNodes[0].nodeValue;
				e=response.getElementsByTagName('komunikat');
				k=e[0].childNodes[0].nodeValue;
				if(b!='0'){
					cartWindowDisplay('Błąd',k);
				}
				else{
					e=response.getElementsByTagName('koszyk');
					k=e[0].childNodes[0].nodeValue;
					e=response.getElementsByTagName('produkt');
					p=e[0].childNodes[0].nodeValue;
					cartWindowDisplay('Dodano produkt do koszyka',p);
					if(cp){cp.innerHTML=k;}
				}
			}
		}
	});
	return false;
}
function addProductToCompare(id){
	var i,n,c=[],tc=jQuery.cookie('to_compare');
	if(tc!=null){c=tc.split('.');}else{tc='';}
	if(c.length>=3){for(i=c.length;i>=3;--i){n=c.shift();}tc=c.join('.');}
	for(i=0,n=c.length;i<n;++i){if(c[i]==id){id='';break;}}
	if((c.length>=3)&&(id!='')){alert('Można wybrać maksymalnie 3 produkty do porównania');}
	else{if(tc!=''){tc+='.';}tc+=id;jQuery.cookie('to_compare',tc);window.location.href='./?a=sklep.porownaj&prid='+tc;}
	return false;
}
