var partners = [];
partners[0]= {'title': 'Acore', 'image': '/gleb_images/think/logo_acore.png', 'url': 'http://www.acore.org/'};
partners[1]= {'title': 'AASHE', 'image': '/gleb_images/think/logo_AASHE.png', 'url': 'http://www.aashe.org/'};
partners[2]= {'title': 'GreenDimes', 'image': '/gleb_images/think/logo_greenDimes.png', 'url': 'http://www.greendimes.com/'};
//partners[3]= {'title': 'Green-e Climate', 'image': '/gleb_images/think/logo_greene.png', 'url': 'http://www.green-e.org/'};
partners[3]= {'title': 'American Wind Energy Association', 'image': '/gleb_images/think/logo_AWEA.png', 'url': 'http://www.awea.org/'};
partners[4]= {'title': 'Solar Energy Industries Association', 'image': '/gleb_images/think/logo_seia.png', 'url': 'http://www.seia.org/'};
partners[5]= {'title': 'Apollo Alliance', 'image': '/gleb_images/think/logo_apollo.gif', 'url': 'http://www.apolloalliance.org/'};

var partner_num = Math.floor(Math.random()*7);

function imageSwitch() {
	
	partner_num = (partner_num + 1)%7;
	
	var $logo_holder = $('.logo_holder > a');
	var img = new Image();
   
	  $(img)
	    .load(function () {/*
	      $logo_holder.fadeOut(100, function () {
			$logo_holder.empty().attr({ 
			          href: partners[partner_num].url,
			          title: partners[partner_num].title,
			          alt: partners[partner_num].title
			        }).append(img).fadeIn(300);
			}); */
			
	    	$(this).css({ opacity: 0});

		      // with the holding div #loader, apply:
		      $logo_holder
		        .empty()
				.attr({ 
				          href: partners[partner_num].url,
				          title: partners[partner_num].title,
				          alt: partners[partner_num].title
				        })
		        .append(this);

		      // fade our image in to create a nice effect
		      $(this).animate({opacity: 1}, 800);
		}) 
	 
	    // if there was an error loading the image, react accordingly
	    .error(function () {
	    })
	    // *finally*, set the src attribute of the new image to our image
	    .attr('src', partners[partner_num].image);
}

$(document).ready(function(){
	$(".off").hover(
		function () {
			$(this).removeClass("off");
        	$(this).addClass("over");
      	}, 
      	function () {
        	$(this).removeClass("over");
        	$(this).addClass("off");
      	}
	);

	$(function() {
	    setInterval( "imageSwitch()", 3000);
	});
});
