$(document).ready(function()
{
  $('.navi li').hover(function(){
     //   $(this).find('ul').show();
        $(this).addClass('hover');
        
        if($(this).parent('ul').hasClass('navi'))
            $(this).children('ul:first').show();
        else
            $(this).children('ul:first').css('left', $(this).width()+1).show();
        
    }, function(){
        $(this).find('ul').hide();
        $(this).removeClass('hover');
        
    });
  
  $('#splasher img:first').addClass('active');
  $('.navi li:last').css({position: "absolute", top: 0, right: 0}).addClass('last');
  $('#splasher #hilights .column:last').addClass('red');
  setInterval('switchSplasher()', 8000);
  
  $('#reseller-documents h2').click(function(){
    $ul = $(this);
    $(this).next('ul').toggleClass('active');
  });
  
  var searchText = $('#search input').val(), searchChanged = false;
  $('#search input').focus(function() {
    if (!searchChanged)
      $(this).val('');
  }).blur(function() {
    if (!searchChanged)
      $(this).val(searchText);
  }).change(function() {
    searchChanged = true;
  });
});

function switchSplasher()
{
  var $current = $('#splasher img.active');
  var $next = $current.next('img');

  if(!$next.size())
    $next = $('#splasher img:first');

  $next.css('opacity',0).css('z-index',2);
  $current.css('z-index', 1);
  
  $next.animate({opacity: 1}, 3000, function(){
    $next.addClass('active');
    $current.css('opacity',0).removeClass('active');
  });  

}
