$(document).ready(function() {
	setMainHeight();

	$(".photoGallery li a").attr("rel", "event_photos");

	$('.photoGallery li a').lightBox({
		imageBlank: 'http://www.risiinfo.com/events/images/lightbox/lightbox-blank.gif',
		imageLoading: 'http://www.risiinfo.com/events/images/lightbox/lightbox-ico-loading.gif',
		imageBtnClose: 'http://www.risiinfo.com/events/images/lightbox/lightbox-btn-close.gif',
		imageBtnPrev: 'http://www.risiinfo.com/events/images/lightbox/lightbox-btn-prev.gif',
		imageBtnNext: 'http://www.risiinfo.com/events/images/lightbox/lightbox-btn-next.gif'
		});


	// Activate Global Nav
	$(".gnav li").hover(function (){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});


	var sponsorCount = 0;
	$(".sideBarBox .sponsors").each(function (){
		sponsorCount++;
		$(this).attr("id", "imageRotator"+sponsorCount);
		$(this).find("img").hide();
		$(this).find("img:first").show();
		$(this).find("img:last").addClass("last");
		$(this).children("div").show();

		setInterval("loopSponsorLogo("+sponsorCount+");", 2000);
	});

});
function loopSponsorLogo(id){
	var foundActive = false;
	var activatedNew = false;
	var animationTime = 500;
	$("#imageRotator"+id).find("img").each(function(){
		if (!activatedNew){
			if (foundActive){
				$(this).fadeIn(animationTime);
				activatedNew = true;
			} else {
				if ($(this).is(':visible')){
					$(this).fadeOut(animationTime);
					foundActive = true;
					if($(this).hasClass("last")){
						$("#imageRotator"+id).find("img:first").fadeIn(animationTime);
					}
				}
			}
		}
	});
}


$(window).resize(function(){
  setMainHeight()
});

function setMainHeight(){
	$("#risiEvents").css("height", $(window).height());
}


