// JavaScript Document

function swapImages(){
  var $active = $('#adlink .active');
  var $next = ($('#adlink .active').next().length > 0) ? $('#adlink .active').next() : $('#adlink img:first');
  $active.fadeOut("slow", function(){
	if ($next.closest('a').attr("href") == "index.php?category=new") {
	  $(this).closest('a').attr("href", "color.php");
	} else if ($next.closest('a').attr("href") == "color.php") {
	  $(this).closest('a').attr("href", "index.php?category=new");
	} else {
	}
    $active.removeClass('active');});
  
  $next.fadeIn("slow").addClass('active');
}

$(document).ready(function(){
	setInterval('swapImages()', 5000);
});
