$(document).ready(function() { 
        	
	$('table#wp-calendar tbody tr td .cal-tooltip, .set-container').hide();		
  
  	//var n = $(".page .right img").length;
  	
  	/*
  	$('.tooltip').hover(function(){
  		$('.cal-tooltip').fadeIn('fast');
  	});
  	*/
  	//$('.clickme').live('click', function() {
  	
  	/*
$('.tooltip').hover(function(){
  		$(this).next().fadeIn('fast');
  	},function() {
  		$(this).next().fadeOut('fast');
  	});
*/
  	
  	$('.tooltip').live('mouseover mouseout', function(event) {
  	if (event.type == 'mouseover') {
    	$(this).next().fadeIn('fast');
  	} else {
    	$(this).next().fadeOut('fast');
 	}
	});

  	/*
$('.tooltip').live('hover', function(){
  		$(this).next().fadeIn('fast');
  	},function() {
  		$(this).next().fadeOut('fast');
  	});
*/
  	 
  	/*
  	var duration = 5000;

	$('.set-container').each(function(n) {
    $(this).delay(n * duration).fadeIn().delay(3500).fadeOut();
	});
	*/
	
		/*
function sidebarAnimation() {
  			var duration = 5000;
  			//var containers = $('.set-container').length;
  			//alert(containers);
  			
			$('.set-container').each(function(n) {
    			$(this).delay(n * duration).fadeIn().delay(3500).fadeOut();
			});
		}
	
  		sidebarAnimation();
*/
 		
	var InfiniteRotator =
    {
        init: function()
        {
            //initial fade-in time (in milliseconds)
            var initialFadeIn = 1000;
 
            //interval between items (in milliseconds)
            var itemInterval = 5000;
 
            //cross-fade time (in milliseconds)
            var fadeTime = 1000;
 
            //count number of items
            var numberOfItems = $('.set-container').length;
 
            //set current item
            var currentItem = 0;
 
            //show first item
            $('.set-container').eq(currentItem).fadeIn(initialFadeIn);
 
            //loop through the items
            var infiniteLoop = setInterval(function(){
                $('.set-container').eq(currentItem).fadeOut(fadeTime);
 
                if(currentItem == numberOfItems -1){
                    currentItem = 0;
                }else{
                    currentItem++;
                }
                $('.set-container').eq(currentItem).fadeIn(fadeTime);
 
            }, itemInterval);
        }
    };
 
    InfiniteRotator.init();
	
	
	
	/*
	FROM: http://stackoverflow.com/questions/4178017/force-jquery-function-to-infinite-repeat-loop/4178212#4178212
	
	var x = $('.set-container');
	
	function animateImage() {
  		var duration = 3500;
		$(x).each(function(n) {
    	$(this).delay(n * duration).fadeIn().delay(2500).fadeOut();
		});
	x.queue(function(n) { animateImage(); x(); })
	}
	
	animateImage();
	*/
	
	
	/* FROM http://stackoverflow.com/questions/1058158/can-somebody-explain-jquery-queue-to-me/1096257#1096257 
	function nonStopAnimation()
	{
    //These multiple animate calls are queued to run one after
    //the other by jQuery.
    //This is the reason that nonStopAnimation method will return immeidately
    //after queuing these calls. 
    $('#box').animate({ left: '+=500'}, 4000);
    $('#box').animate({ top: '+=500'}, 4000);
    $('#box').animate({ left: '-=500'}, 4000);

    //By calling the same function at the end of last animation, we can
    //create non stop animation. 
    $('#box').animate({ top: '-=500'}, 4000 , nonStopAnimation);
	}
	*/
	
	/*
  	for (i=1;i<=n;i++)
	{
	$('.set-' + i).delay(1800).fadeIn(300).delay(1800).fadeOut(400);
	//break;
	}
	*/
	
  	//$('.set-1').delay(1800).fadeIn(300).delay(1800).fadeOut(400);

	//$('image)
  	  	
  	//alert(n);
  	//$('.page .right img').hide();

  	//$("table#wp-calendar td:has(a)").css("color","#123456");
  	
  	/*
  	if ( $('table#wp-calendar td').children().size() > 0 ) {
     $('table#wp-calendar td a').parent().css("backgroundColor","#8c4593");
	} 
	*/ 	
});
