function switchItems() {
	var $active = jQuery('#rotator .item_thumb div.active');
	
	if($active.length == 0) {
		$active = jQuery('#rotator .item_thumb div.item:last');
	}
	
	var $next = $active.next().length ? $active.next() : jQuery('#rotator .item_thumb div.item:first');
	
	//Set variables
	var imgAlt = $next.find('img').attr("alt"); //Get Alt Tag of Image
    var imgSrc = $next.find('img').attr("src"); //Get Main Image src
    var imgDesc = $next.find('.desc').html();  //Get HTML of the "block" container
    var imgDescHeight = jQuery('#rotator .main_item').find('.desc').height(); //Find the height of the "block"
    var aHref = $next.find('a').attr('href');//Get URL of the item
    
    //Animate the Description
    jQuery("#rotator .main_item .desc").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250,

   	function() { //Pull the block down (negative bottom margin of its own height)
    	jQuery("#rotator .main_item .desc").html(imgDesc).animate({ opacity: 0.85,  marginBottom: "0" }, 250 ); //swap the html of the block, then pull the block container back up and set opacity
    	jQuery("#rotator .main_item img").attr({ src: imgSrc , alt: imgAlt}); //Switch the main image (src and alt tag)
    	jQuery("#rotator .main_item a").attr({ href: aHref});//Set up new URL
    });
    
    //Show active list-item
    jQuery("#rotator .item_thumb div.item").removeClass('active'); //Remove class of 'active' on all list-items
    $next.addClass('active');  //Add class of 'active' on the selected list
    
    return false;
}

//switch partners' logos
function switchLogoItems() {
	var $activeItem1 = jQuery('#logo-rotator-1 .item_thumb div.active');
	var $activeItem2 = jQuery('#logo-rotator-2 .item_thumb div.active');
	
	if($activeItem1.length == 0) {
		$activeItem1 = jQuery('#logo-rotator-1 .item_thumb div.item:last');
	}
	if($activeItem2.length == 0) {
		$activeItem2 = jQuery('#logo-rotator-2 .item_thumb div.item:last');
	}
	
	var $nextItem1 = $activeItem1.next().length ? $activeItem1.next() : jQuery('#logo-rotator-1 .item_thumb div.item:first');
	var $nextItem2 = $activeItem2.next().length ? $activeItem2.next() : jQuery('#logo-rotator-2 .item_thumb div.item:first');
	var $divContent1 = $nextItem1.html();
	var $divContent2 = $nextItem2.html();
	
	jQuery('#logo-rotator-1 .item_thumb div.item').removeClass('active');
	jQuery('#logo-rotator-2 .item_thumb div.item').removeClass('active');
	$nextItem1.addClass('active');
	$nextItem2.addClass('active');
	jQuery('#logo-rotator-1 .main_item').html($divContent1);
	jQuery('#logo-rotator-2 .main_item').html($divContent2);
	
	return false;
}

jQuery(document).ready(function() {
	jQuery("#rotator .main_item .desc").show(); //Show Banner
	jQuery("#rotator .main_item .desc").animate({ opacity: 0.85 }, 1 ); //Set Opacity

	jQuery("#rotator .item_thumb div.item:first").addClass('active'); //Add the active class (highlights the very first list item by default)
	
	//logo rotators
	jQuery('#logo-rotator-1 .main_item').show();
	jQuery('#logo-rotator-2 .main_item').show();
	jQuery('#logo-rotator-1 .item_thumb div.item:first').addClass('active');
	jQuery('#logo-rotator-2 .item_thumb div.item:first').addClass('active');

	var slideShow = setInterval("switchItems()", 7000);
	var logoShow = setInterval("switchLogoItems()", 4000);
	
	jQuery("#rotator .item_thumb div.item").hover(function(){
		clearInterval(slideShow);
		//Set variables
		var imgAlt = jQuery(this).find('img').attr("alt"); //Get Alt Tag of Image
	    var imgSrc = jQuery(this).find('img').attr("src"); //Get Main Image src
	    var imgDesc = jQuery(this).find('.desc').html();  //Get HTML of the "block" container
	    var imgDescHeight = jQuery('#rotator .main_item').find('.desc').height(); //Find the height of the "block"
	    var aHref = jQuery(this).find('a').attr('href');//Get URL of the item

	    if (jQuery(this).is(".active")) {  //If the list item is active/selected, then...
	        return false; // Don't click through - Prevents repetitive animations on active/selected list-item
	    } else { //If not active then...
	        //Animate the Description
	    	jQuery(".main_item .desc").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250,

		   	function() { //Pull the block down (negative bottom margin of its own height)
	    		jQuery("#rotator .main_item .desc").html(imgDesc).animate({ opacity: 0.85,  marginBottom: "0" }, 250 ); //swap the html of the block, then pull the block container back up and set opacity
	    		jQuery("#rotator .main_item img").attr({ src: imgSrc , alt: imgAlt}); //Switch the main image (src and alt tag)
	    		jQuery("#rotator .main_item a").attr({ href: aHref});//Set up new URL
	        });
	    }
	    //Show active list-item
	    jQuery("#rotator .item_thumb div.item").removeClass('active'); //Remove class of 'active' on all list-items
	    jQuery(this).addClass('active');  //Add class of 'active' on the selected list
	    return false;
	},
	
	function() {
		slideShow = setInterval("switchItems()", 7000);
	}
	); 
	
	$('#rotator .main_item').hover(function(){
		clearInterval(slideShow);
	},
	
	function() {
		slideShow = setInterval("switchItems()", 7000);
	}
	);
});//close function
