// Ajatix Advanced CSS Drop Down Menu
// Copyright (C) 2009 Ajatix. All rights reserved.
// http : // www.ajatix.com
// Unregistered copy.
// Any usage except for the purpose of evaluation is strictly prohibited.
(function()
{
   var menu, onLoad = function()
   {
      var divs = document.getElementsByTagName("div");
      for(var i = 0; i < divs.length; i ++ )
      {
         if(divs[i].className == "AJXCSSMenueDFaTFD")
         {
            menu = divs[i];
            var lis = menu.getElementsByTagName("li");
            for(var n = lis[0]; n; n = n.nextSibling)if(n.tagName == "LI")
            {
               n.ajxtop = true;
            }
            for(var j = 0; j < lis.length; j ++ )
            {
               lis[j].className = lis[j].className;
               lis[j].style.position = "static";
               var uls = lis[j].getElementsByTagName("ul");
               if(uls.length > 0)uls[0].style.display = "none";
               lis[j].shown = lis[j].show = false;
               lis[j].onmouseover = function()
               {
                  clearTimeout(menu.timer);
                  if(this.className.indexOf("ajxover") == - 1)this.className += " ajxover";
                  this.show = true;
                  menu.timer = setTimeout(update, 160);
               }
               ;
               lis[j].onmouseout = function()
               {
                  clearTimeout(menu.timer);
                  if( ! this.shown)this.className = this.className.replace(new RegExp(" ?ajxover\\b"), "");
                  this.show = false;
                  menu.timer = setTimeout(update, 600);
               }
               ;
            }
         }
      }
   }
   , update = function()
   {
      var lis = menu.getElementsByTagName("li");
      for(var i = lis.length - 1; i >= 0; i -- )
      {
         if(lis[i].show)
         {
            if( ! lis[i].shown)
            {
               var uls = lis[i].getElementsByTagName("ul");
               if(uls.length > 0)
               {
                  lis[i].style.position = "relative";
                  uls[0].style.clip = "rect(0 0 0 0)";
                  uls[0].style.display = "block";
                  slide(uls[0], lis[i].ajxtop);
                  lis[i].shown = true;
               }
            }
         }
         else
         {
            var uls = lis[i].getElementsByTagName("ul");
            if(uls.length > 0)
            {
               uls[0].style.display = "none";
               lis[i].style.position = "static";
               lis[i].shown = false;
               if(lis[i].className.indexOf("ajxover") != - 1)lis[i].className = lis[i].className.replace(new RegExp(" ?ajxover\\b"), "");
            }
         }
      }
   }
   , slide = function(o, d)
   {
      var h = d ? o.offsetHeight : o.offsetWidth;
      var t = d ? o.offsetTop : o.offsetLeft;
      o.tstart = new Date;
      if( ! o.timer)o.timer = setInterval(function()
      {
         var s = (new Date - o.tstart) / 200;
         if(s < 1)
         {
            var v = h * (s < 1 / 2.75 ? 7.5625 * s * s : s < 2 / 2.75 ? 7.5625 * (s -= 1.5 / 2.75) * s + .75 : s < 2.5 / 2.75 ? 7.5625 * (s -= 2.25 / 2.75) * s + .9375 : 7.5625 * (s -= 2.625 / 2.75) * s + .984375);
            o.style[d ? "top" : "left"] = v - h + t + "px";
            o.style.clip = "rect(" + (d ? h - v : "-9999") + "px 9999px 9999px  " + (d ? "-9999" : h - v) + "px)";
         }
         else
         {
            clearInterval(o.timer);
            o.timer = undefined;
            o.style[d ? "top" : "left"] = t + "px";
            o.style.clip = "rect(-9999px 9999px 9999px -9999px)";
         }
      }
      , 13);
   }
   , addOnReady = function(f, fu)
   {
      var isReady = false, ready = function()
      {
         if( ! isReady)
         {
            isReady = true;
            f();
         }
         ;
      }
      ;
      if(document.addEventListener)
      {
         document.addEventListener('DOMContentLoaded', ready, false);
         window.addEventListener("load", ready, false);
         window.addEventListener("unload", fu, false);
      }
      if(window.attachEvent)window.attachEvent("onload", ready);
      if(document.documentElement.doScroll && window == top)
      {
         (function()
         {
            if( ! isReady)
            {
               try
               {
                  document.documentElement.doScroll("left");
               }
               catch(E)
               {
                  setTimeout(arguments.callee, 0);
                  return;
               }
               ready();
            }
         }
         )()
      }
   }
   ;
   addOnReady(onLoad, onLoad);
}
)();

