// Modified jQuery for Fade Functions which fixes the ClearType bug in IE

jQuery.fn.fadeIn = function(speed, callback) { 
    return this.animate({opacity: 'show'}, speed, function() { 
        if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 
 
jQuery.fn.fadeOut = function(speed, callback) { 
    return this.animate({opacity: 'hide'}, speed, function() { 
        if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 
 
jQuery.fn.fadeTo = function(speed,to,callback) { 
    return this.animate({opacity: to}, speed, function() { 
        if (to == 1 && jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
};

// Start Random Quotes

jQuery(document).ready(function(){	
	showing = jQuery('#rotating_items div.rotating_item:first'); // Initiate the 'showing' variable as the first rotating_item
	showing.show();
	showing.siblings('div').hide(); // Hide all other rotating_items
	setInterval("show_next_rotating_item(showing)", 10000); // Set the rotate time to 10 seconds
});
 
// Below is the code that picks an item at random to display
jQuery.jQueryRandom = 0;  
jQuery.extend(jQuery.expr[":"],  
{  
    random: function(a, i, m, r) {  
        if (i == 0) {  
            jQuery.jQueryRandom = Math.floor(Math.random() * r.length);  
        };  
        return i == jQuery.jQueryRandom;  
    }  
}); 

// The below function repeatedly gets called, to do the rotating
function show_next_rotating_item(t){
	jQuery(t).fadeOut('slow');

 var next_rotating_item = jQuery(t).siblings('.rotating_item:random');
	if(!next_rotating_item.attr('class')){
		next_rotating_item = jQuery('#rotating_items div.rotating_item:first');
	}
	next_rotating_item.fadeIn('slow');

	showing = next_rotating_item;	
}
