jQuery.noConflict();
var showing2;

jQuery(document).ready(function(){	
	showing2 = jQuery('#rotating_items2 div.rotating_item2:first'); // Initiate the 'showing2' variable as the first rotating_item
	showing2.siblings('div').hide(); // Hide all other rotating_items
	setInterval("show_next_rotating_item2(showing2)", 9000); // Set the rotate time to 5 seconds
	
	
	jQuery('#rotating_items2').show();
	
	// When a link in the rotating_item is clicked
	// we want to instead treat it as if the whole
	// box was clicked.
	jQuery('#rotating_items2 a').click(function(){
		jQuery('#rotating_items2').click();
		return false;
	});
	
	
	// Now, when the box is clicked, track the click
	// as an event in Google Analytics and then direct
	// the user to the intended URL.
	jQuery('#rotating_items2').click(function(){
		var link = showing2.contents().find('a').attr('href');
		if(!link) return false; // if there is no link, theres nothing to do here
		var testi_title = showing2.find('h3').html();

		if(link!=''){
			window.open(link);
		}
		try {
			pageTracker._trackEvent('rotating_item2','click','Following link for ' + testi_title); 
		} catch(err) {
		}							
	}).mouseover(function(){
		jQuery(this).addClass('hover');
	}).mouseout(function(){
		jQuery(this).removeClass('hover');
	});
});


// 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_item2(t){
	jQuery(t).fadeOut('slow');

	var next_rotating_item2 = jQuery(t).siblings('.rotating_item2:random');
	if(!next_rotating_item2.attr('class')){
		next_rotating_item2 = jQuery('#rotating_items2 div.rotating_item2:first');
	}
	next_rotating_item2.fadeIn('slow');
	
	showing2 = next_rotating_item2;	
}
