    function swap()
    {
      if (!stopanimation)
      {
        if ($('#promo1').css('opacity') == 1)
        {
          ph1 = $('#promo1');
          ph2 = $('#promo2');
        }
        else
        {
          ph1 = $('#promo2');
          ph2 = $('#promo1');
        }
  
        ph2.show();
        ph1.fadeTo(1000, 0, function() {
          ph1.hide();
          });
        ph2.fadeTo(1000, 1, function()
        {
          cur++;
          if (cur>ln)
            cur = 0;          
          bcur = cur-1;
          if (bcur < 0)
            bcur = ln;
          $('.nav').removeClass('act');
          $('#nav'+bcur).addClass('act');
          ph1.css('background-image', 'url('+images[cur]+')');
          if (hrefs[cur].length > 0)
            ph1.html('<a href="'+hrefs[cur]+'"><img src="application/images/spacer.gif" style="width:1000px; height:394px;" alt="promo"></a>');
          else
            ph1.html('<img src="application/images/spacer.gif" style="width:1000px; height:394px;" alt="promo">');


        
          timeoutid = setTimeout (swap, 3000);
        });
      }
      else
        timeoutid = setTimeout (swap, 3000);
    }

(function($){
  initiateswap = function() {
  };

    $('.nav').click(function() {
      ph1.stop(true, true);
      ph2.stop(true, true);
      clearTimeout(timeoutid);
      cur = $(this).attr('id').substr(3);
      $('.nav').removeClass('act');
      $('#nav'+cur).addClass('act');
      
      if ($('#promo1').css('opacity') == 1)
        pht = $('#promo1');
      else
        pht = $('#promo2');
        
        pht.css('background-image', 'url('+images[cur]+')');
        
        if (hrefs[cur].length > 0)
          pht.html('<a href="'+hrefs[cur]+'"><img src="application/images/spacer.gif" style="width:1000px; height:394px;" alt="promo"></a>');
        else
          pht.html('<img src="application/images/spacer.gif" style="width:1000px; height:394px;" alt="promo">');

        
      window.location.hash = '#panel-'+cur;
  
      return false;
  
    });
    
    $('#promoholder').hover(
      function () {
        stopanimation = true;
      },
      function () {
        stopanimation = false;
      }
    ); 

})(jQuery);

