function theRotator() {
   $('div#rotator a').css({opacity: 0.0});
   $('div#rotator a:first').css({opacity: 1.0});
   var current = $('div#rotator a:first');
   $('#bannerA').attr('href',current.attr('href'));
   setInterval('rotate()',5000);
}

function rotate() {
   var current = ($('div#rotator a.show')?  $('div#rotator a.show') : $('div#rotator a:first'));
   var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator a:first') :current.next()) : $('div#rotator a:first'));
   next.css({opacity: 0.0})
         .addClass('show')
            .animate({opacity: 1.0}, 1000);
   current.animate({opacity: 0.0}, 1000)
         .removeClass('show');
   $('#bannerA').attr('href',next.attr('href'));
};
 
function log(element) {  
       //console.log("a[" + index + "] = " + element.src);
   $('div#rotator').append('<a href="/id/' + element.id + '"><img width="900" height="352" src="' + element.src + '" /></a>');
} 

$(document).ready(function() {
   if (!$.browser.msie) 
      $('#gallery-button').corner();
   var images = jQuery.parseJSON($('#imagesJSONSource').html());
   for(i=0;i < images.length; i++) {
      log(images[i]);
   }
   $('div#rotator a:first').addClass('show');
   theRotator();
   //Nifty('#gallery-button','big');
});

