jQuery.silMenuTabs = function(opt) {

  var opt = opt || {};
  opt.delay = opt.delay || 1500;
  opt.active = opt.active || "";
  opt.priv = {
    timeout:null,
    hover:false
  };

  function setactive() {
    if(opt.active=="") return;
    if(!opt.priv.hover) {
      $("*[sil_menutabs*='[hover=true]'][sil_menutabs*='[id="+opt.active+"]']").children("img").attr("src", function() { return this.src.replace( /\.(gif|jpg|jpeg|png)$/gi , '1.$1') } );
      $("*[sil_submenutabs*='[id_rodzica="+opt.active+"]']").show();
    }//if(!opt.priv.hover) {
  }//function setactive() {
  function cleardelayhide() {
    if(opt.priv.timeout) clearTimeout(opt.priv.timeout);
    $("*[sil_menutabs*='[hover=true]']").children("img").attr("src", function() { return this.src.replace( /1\.(gif|jpg|jpeg|png)$/gi , '.$1') } );
    $("*[sil_submenutabs]").hide();
  }//function cleardelayhide() {
  function delayhide() {
    if(!opt.priv.hover) {
      cleardelayhide();
      setactive();
    }
    else
      opt.priv.timeout = setTimeout(delayhide,opt.delay);
  }//function delayhide() {

  //------------------------------------------------
  //Stworzenie atrybutów pomocniczych
  //------------------------------------------------
  $("*[title^=sil_menutab]").attr("sil_menutabs",function(){ return $(this).attr("title") }).attr("title","");
  $("*[rel^=sil_menutab]").attr("sil_menutabs",function(){ return $(this).attr("rel") }).attr("rel","");
  $("*[title^=sil_submenutab]").attr("sil_submenutabs",function(){ return $(this).attr("title") }).attr("title","");
  $("*[rel^=sil_submenutab]").attr("sil_submenutabs",function(){ return $(this).attr("rel") }).attr("rel","");

  //------------------------------------------------
  //Odsłoń tylko warstwę aktywną sil_submenutabs[active=true]
  //------------------------------------------------
  $("*[sil_submenutabs]").hide();
  $("*[sil_menutabs][sil_menutabs*='[active=true]']:first").map(function() {
    tmp = $(this).attr("sil_menutabs");
    if(tmp.match(/\[id=([^\]]+)\]/)) {
      tmp = tmp.match(/\[id=([^\]]+)\]/)[1];
      $("*[sil_submenutabs][sil_submenutabs*='id_rodzica="+tmp+"']").show();
      opt.active=tmp;
    }
  });

  //------------------------------------------------
  //Podepnij zdarzenia hover
  //------------------------------------------------
  $("*[sil_menutabs]").hover(function(e) {
    cleardelayhide();
    opt.priv.hover = true;
    tmp = $(this).attr("sil_menutabs");
    if(tmp.match(/\[hover=true\]/))
      $(this).children("img").attr("src", function() { return this.src.replace( /\.(gif|jpg|jpeg|png)$/gi , '1.$1') } );
    $("*[sil_submenutabs]").hide();
    if(tmp.match(/\[id=([^\]]+)\]/)) {
      tmp2=tmp.match(/\[id=([^\]]+)\]/)[1];
      $("*[sil_submenutabs*='[id_rodzica="+tmp2+"]']").show();
    }//if(tmp.match(/\[id=([^\]]+)\]/)) {
  }, function(e) {
    opt.priv.hover = false;
    opt.priv.timeout = setTimeout(delayhide,1000);
    tmp = $(this).attr("sil_menutabs");
  });//$("*[sil_menutabs]").hover(function(e) {
  $("*[sil_submenutabs]").hover(function(e) {
    opt.priv.hover = true;
  }, function(e) {
    opt.priv.hover = false;
    opt.priv.timeout = setTimeout(delayhide,1000);
  });//$("*[sil_submenutabs]").hover(function(e) {

  //------------------------------------------------
  //Ustaw aktywna zakładkę
  //------------------------------------------------
  setactive();
  
}

