var JS = {};

JS.dom = 
{
$ : function(d) 
{
 if (d) 
 {
  return document.getElementById(d) || null;
 }
},

$$ : function(e) 
{
 if (e) 
 {
  return document.createElement(e);
 }
},

txt : function(t) 
{
 return document.createTextNode(t);
},

css : function(o, c) 
{
 if (o.nodeType == 1) 
 {
  for (i in c) 
  {
   if (i == 'opacity') 
   {
    if (JS.browser.ie()) 
    {
     o.style['filter'] = 'Alpha(Opacity=' + parseInt(c[i] * 100) + ')';
    }
   }
   
   o.style[i] = c[i];
  }
  
  c = null;
 }
 
 return o;
},

attr : function(o, a) 
{
 if (o.nodeType == 1) 
 {
  for (i in a) {
   o[i] = a[i];
  }
  
  a = null;
 }
 
 return o;
},

tag : function(o) 
{
 if (o.nodeType == 1) 
 {
  return o.tagName.toLowerCase();
 }
},

x : function(o) 
{
 if (o.nodeType == 1) 
 {
  var x = o.offsetLeft;
  
  while (o.offsetParent && o.offsetParent != document.body) 
  {
   o = o.offsetParent;
   x += o.offsetLeft;
  }
  
  return x;
 }
},

y : function(o)
{
 if (o.nodeType == 1) 
 {
  var y = o.offsetTop;
  
  while (o.offsetParent && o.offsetParent != document.body) 
  {
   o = o.offsetParent;
   y += o.offsetTop;
  }
  
  return y;
 }
},

getElementsByClassName : function(n, t, r)
{
 var a = [];
 
 var d = document.body;
 
 if (t)
 {
  d = t;
 }
 
 var c = d.getElementsByTagName('*');
 
 if (c)
 {
  for (var i = 0, len = c.length; i < len; i++)
  {
   var o = c[i];
   
   if (o.className)
   {
    var cl = o.className.split(' ');
    
    for (var t = 0, l = cl.length; t < l; t++)
    {
     if (r && cl[t].match('^' + n))
     {
      a.push(o);
     }
     else
     {
      if (cl[t] == n)
      {
       a.push(o);
      }
     }
    }
   }
  }
 }

 c = null;
 
 return a;
}
};









var navBar = {};
navBar.className = 'ms-pages-menu-js';
navBar.divName = 'ms-pages-menu';
navBar.init = function()
{
var navList = null;

// pobieramy liste linków
if (!(navList = JS.dom.getElementsByClassName(this.className,  
document.getElementById(this.divName))))
{
return;
}

for (var i = 0, sizeOfNav = navList.length; i < sizeOfNav; i++)
{
// aktyne zakładki nie posiadaja animacji
if (navList[i].id == 'active')
{
continue;
}

// ustawiamy płynne opadanie obrazka tła
navList[i].bgPos = 35;
navList[i].onmouseout = function()
{
return function()
{
navBar.out(this);
};
}();

// resetujemy plynne opadane obrazka
// i ustawiamy plynne wznoszenie
navList[i].onmouseover = function()
{
return function()
{
navBar.hover(this);
};
}();
}
};
navBar.out = function(obj)
{
// zablokuj wznoszenie
if (obj.timeHover)
{
clearTimeout(obj.timeHover);
}

if (obj.bgPos < 35)
{
obj.style.backgroundPosition = '0 '+(obj.bgPos+=1)+'px';
obj.timeOut = setTimeout(function()
{
navBar.out(obj);
}, 10);
}
};
navBar.hover = function(obj)
{
// zablokuj opadanie
if (obj.timeOut)
{
clearTimeout(obj.timeOut);
}

if (obj.bgPos > 0)
{
obj.style.backgroundPosition = '0 '+(obj.bgPos-=2)+'px';
obj.timeHover = setTimeout(function()
{
navBar.hover(obj);
}, 10);
}
};

