$(document).ready(function(){
  $("tr.listaproduktow:odd").addClass( "tlo" );
  
  // usuwanie ca�ej zawarto�ci koszyka
  $( "#koszyk_all_1" ).click( function(){
    $( "input[@type='checkbox']" ).not( "#koszyk_all_1" ).each( function(){
        this.checked=!this.checked;
      });
  });
  // wygl�da na powt�rzony kod, ale dzi�ki temu oba czekboksy na stronie dzia�aj� prawd�owo.
  $( "#koszyk_all_2" ).click( function(){
    $( "input[@type='checkbox']" ).not( "#koszyk_all_2" ).each( function(){
        this.checked=!this.checked;
      });
  });

  $("a:not(.thickbox2)", "a:not(#f-calendar-trigger-1)", "a:not(#f-calendar-trigger-2)").click( function() {
    if( navigator.appName != "Opera" )
    {
      if( $(this).attr( "target" ) == undefined )
      {
        scroll(0,0);
        $("#col2_content").fadeTo( "fast", 0.25 );
        $("#magazyn_overlay").fadeIn(); 
      }
    }
  });

  $("#pokaz_zamienniki").click( function(){
    $("#zamienniki").slideDown();
    $(this).attr( "disabled", "disabled" );
  });
  
  $("span.node").hover( function(){
    id = $(this).attr( "id" ).substr( 2 );
    if( $("#ul"+id).css( "display" ) == "block" )
    {
      $(this).css( "background", "url('../images/minus_menu.gif') no-repeat scroll 10px 10px transparent" );
    }
    else
    {
      $(this).css( "background", "url('../images/plus_menu.gif') no-repeat scroll 10px 10px transparent" );
    }
  }, function(){
    id = $(this).attr( "id" ).substr( 2 );
    if( $("#ul"+id).css( "display" ) == "block")
    {
      $(this).css( "background", "url('../images/minus_menu.gif') no-repeat scroll 10px 10px transparent" );
    }
    else
    {
      $(this).css( "background", "url('../images/plus_menu.gif') no-repeat scroll 10px 10px transparent" );
    }
  });
  
    $("span.node").click( function(){
            id = $(this).attr( "id" ).substr( 2 );
            if( $("#ul"+id).css( "display" ) == "block" )
            {
                    $("#ul"+id).hide("fast", function(){$("#li"+id).attr("class", $("#li"+id).attr("class").replace("rozwiniete", "zwiniete"))});                    
                    $(this).css( "background", "url('../images/plus_menu.gif') no-repeat scroll 10px 10px transparent" );
            }
            else
            {
                    $("#ul"+id).show("fast");                    
                    $("#li"+id).attr("class", $("#li"+id).attr("class").replace("zwiniete", "rozwiniete"));
                    $(this).css( "background", "url('../images/minus_menu.gif') no-repeat scroll 10px 10px transparent" );
            }            
            return false;
    });
});
