jQuery(document).ready(function(){
	
    var speed = 400;
	
    $('#tabela_rozmiarow').tooltip({
        delay: 0,
        showURL: false,
        bodyHandler: function() {
            return $("#tabka").html();
        }
    });
	
	
    var isMSIE = /*@cc_on!@*/false;
	
    if (isMSIE==false) {
	
        //$('#kom_ukryj').show();
	
        // poczatek
        $('.wksz2full').removeClass('wksz2full');
        $('input[name=przelicz_koszyk]').hide();
        $('input[name=zmien_wysylke]').hide();
	
        $('.form_przelicz input').live('change',function() {
            $('input[name=zamowienie]').attr('disabled','disabled');
            // pokaz loader
            $('<div />').addClass('lightbox_bg').appendTo('body').show();
            $('<div />').html('<img src="pluginy/images/loader.gif" alt="" />').addClass('modal').appendTo('body');
            // koniec loadera
            ilosc = $(this).parent().children('input[name=ilosc]').val();
            id_kosz = $(this).parent().children('input[name=id_kosz]').val();
            rozmiar = $(this).parent().children('input[name=rozmiar]').val();
		
            $.ajax({
                type: "POST",
                global: false,
                url: "index.php?podstrona=koszyk",
                data: "przelicz_koszyk=true&ilosc="+ilosc+"&id_kosz="+id_kosz+"&rozmiar="+rozmiar,
                success: function(msg){
                    jQuery('#koszykb').load('index.php?podstrona=koszyk #newsylp',function(){
                        $('.wksz2full').removeClass('wksz2full');
                        $('input[name=zmien_wysylke]').hide();
                        $('input[name=przelicz_koszyk]').hide();
                        //$('#kom_ukryj').show();
                        $('input[name=zamowienie]').removeAttr('disabled');
                        // ukrywanie
                        $('div.modal').fadeOut("fast",function(){
                            $('div.lightbox_bg').fadeOut("fast");
                        });
                    // koniec
	 
                    });
                }
            });
		
        //alert(ilosc+" : "+id_kosz+" : "+rozmiar);
        });
	
        $('.form_przelicz select').live('change',function() {
            $('input[name=zamowienie]').attr('disabled','disabled');
            // pokaz loader
            $('<div />').addClass('lightbox_bg').appendTo('body').show();
            $('<div />').html('<img src="pluginy/images/loader.gif" alt="" />').addClass('modal').appendTo('body');
            // koniec loadera
		
            id_wysylka = $(this).parent().children('[name=id_wysylka]').val();
		
            $.ajax({
                type: "POST",
                global: false,
                url: "index.php?podstrona=koszyk",
                data: "zmien_wysylke=true&id_wysylka="+id_wysylka,
                success: function(msg){
                    jQuery('#koszykb').load('index.php?podstrona=koszyk #newsylp',function(){
                        $('.wksz2full').removeClass('wksz2full');
                        $('input[name=zmien_wysylke]').hide();
                        $('input[name=przelicz_koszyk]').hide();
                        //$('#kom_ukryj').show();
                        $('input[name=zamowienie]').removeAttr('disabled');
                        // ukrywanie
                        $('div.modal').fadeOut("fast",function(){
                            $('div.lightbox_bg').fadeOut("fast");
                        });
                    // koniec
                    });
                }
            });
		
        });
	
	
    }
	  
    jQuery("a.powrot").live("click",function() {
        history.back();
        return false;
    });
	
    jQuery("#wyslij_formularz").validationEngine();

    jQuery("#produkt_foto_male img").click(function(){
        jQuery("#produkt_foto_duzy li").fadeOut(speed);
        var klasa = jQuery(this).parent().attr('class');
        jQuery("#produkt_foto_duzy li."+klasa).fadeIn(speed);
        return false;
    });
	
});
