$(function() {

  // tree navigation
  $("ol#tree-nav a").click(function() {
    window.location = $(this).attr("href");
    return false;
  });
  
  $("ol#tree-nav li:has(ol)").each(function() {
    var toggle = "<a href=\"#\" class=\"toggle\"></span>";
    $(this).append(toggle).children("a:not(.toggle)").click(function() {
      $(this).parent().addClass("expanded");     
      return false;
    });
  });
  
  $("ol#tree-nav li a.toggle").live("click", function() {
    $(this).parent().toggleClass("expanded");  
    return false;
  });

  // keep current section expanded in tree 
  $(".products a[href='/products.php'], .about-us a[href='/about.php'], .applications a[href='/applications.php'], .news a[href='/current-news.php']").parent().addClass("expanded");


 
   $("a").each(function(){
     if ($(this).attr("href") == window.location.pathname){
        $(this).addClass("selected");
     }
   });

   $('.fadein img:gt(0)').hide();
    setInterval(function(){
      $('.fadein :first-child').fadeOut()
         .next('img').fadeIn()
         .end().appendTo('.fadein');}, 
      3000);

  $('#logo_home').flash({
      src: 'flash/logo.swf',
      width: 266,
      height: 100
  });


    
});

