$.ajaxSetup(
  {
    contentType: "application/x-www-form-urlencoded; charset=utf-8"
  });

(function($)
  {
    $.fn.menu = function(ustawienia)
      { 
        var el, rozwLinkAkt;
        ustawienia=jQuery.extend(
          {
	          szybkosc	: 120,
            off		: "_images/arrow_right.png",
	          on		: "_images/arrow_down.png" 
          },ustawienia);  
        el = $(this);
        el.children("ul").parent("li").children("a").addClass("aktywzakladka");
        el.children("ul").addClass("aktywpodzakladka");
        rozwLinkAkt = el.children("a.aktywzakladka");
        rozwLinkAkt.css(
          {
  	        "background":	"url("+ustawienia.off+") center right no-repeat"
          });
      //Klik w zakładkę
      rozwLinkAkt.click(function ()
        {
	    	  var klik = $(this); 
	    	  rozwLinkAkt.parent("li").children("ul").slideUp(ustawienia.szybkosc/1.2, function()
            {
	    		    $(this).removeAttr("class");
	    		    $(this).attr("class", "aktywpodzakladka");
	    		    rozwLinkAkt.css(
                {
	    		  	    "background":	"url("+ustawienia.off+") center right no-repeat"
	    	        });	
	    	    });         
	    	  klik.removeAttr("class");
	    	  klik.attr("class", "naktywzakladka");
	    	  klik.parent("li").children("ul.aktywpodzakladka").slideDown(ustawienia.szybkosc, function ()
            {
	    		    $(this).removeAttr("class");
	    		    $(this).attr("class", "naktywpodzakladka");	
	    			  klik.css(
                {
	    			  	  "background":	"url("+ustawienia.on+") center right no-repeat"                 
	    		      });	
	    	    });
	        return false;
        }); 
      }
  })(jQuery);  
  
$(document).ready(function()
  {
    $("#menu_left ul li").menu();
    $("#content").hide();
    $("#content").fadeIn();

    $("#menu_top ul li").click(function()
      {
        var activeTab = $(this).find("a").attr("href");
        $("#content").hide();
        $.ajax(
          {
            type: 'POST',
            url: '_content.php',
            data: ({module : activeTab}),
            cache: false,
            success: function(html)
              {
                $("#content").html(html);
              }
          });
        $("#content").fadeIn();
        return false;
      });
      
    $("#menu_left ul li").click(function()
      {
        var activeTab = $(this).find("a").attr("href");
        $("#content").hide();
        $.ajax(
          {
            type: 'POST',
            url: '_content.php',
            data: ({module : activeTab}),
            cache: false,
            success: function(html)
              {
                $("#content").html(html);
              }
          });
        $("#content").fadeIn();
        return false;
      });      

    //kliniecia w inne linki
    $("a.keys").click(function()
      {
        $("#content").hide();
        $.ajax(
          {
            type: 'POST',
            url: '_login.php',
            data: ({action : "login"}),
            cache: false,
            success: function(data)
              {
                $("#content").html(data);
              }
          });
        $("#content").fadeIn();
        return false;
      });  

  });

