function slideshow()
{
	$('#slideshow').cycle({
		timeout: 6000
	});
}

//////////////////////////////////////////////////////////////////////

function activate_menu()
{
	if ($('#wrapper').hasClass('inner') && !$('#wrapper').hasClass('edchomepage') && !($('#wrapper').hasClass('info')))
	{
		$('#nav_main li.active').siblings().each( function() {
			$(this).css({ 'opacity' : '0.3'});
		});
		
		$('#nav_main li').hover( function() {
			$(this).stop().animate({
				opacity: '1'
			}, 200);
		},
		function() {
			if (!$(this).hasClass('active'))
			{
				$(this).stop().animate({
					opacity: '0.3'
				}, 200);
			}
		});
	}
	else
	{
		$('#nav_main li').hover( function() {
			$(this).stop().animate({
			 opacity: '1'
			}, 200);
			
			$(this).siblings().each( function() {
				$(this).stop().animate({
				 opacity: '0.2'
				}, 200);
			});
		}, function() {
			$(this).siblings().each( function() {
				$(this).stop().animate({
				 opacity: '1'
				}, 200);
			});
		});
	}
}

//////////////////////////////////////////////////////////////////////

function hovers()
{
	$('.inner ul#latest_news li p.more a').hover( function() {
		$(this).stop().animate({
			color: '#7f498f'
		}, 250);
	},
	function() {
		$(this).stop().animate({
			backgroundColor: '#A56AB6'
		}, 250);
	});
}


//////////////////////////////////////////////////////////////////////

function tooltips()
{
	$('.event a.trigger').click( function(e) {
		
		if(($.browser.msie && $.browser.version=="6.0") || ($.browser.msie && $.browser.version=="7.0"))
		{
			
		}
		else
		{
			var classes = $(this).parent('div').attr('class');
			var event_id = classes.split(' ');
			event_id = event_id[1];


			if ($('.' + event_id + '_desc').hasClass('shown'))
			{
				$('.event_desc')
				.stop()
				.animate({
					opacity: 0
				}, 100, 'swing', function() {
					$(this).hide().removeClass('shown').css({ 'top' : '20px' });
				});
			}
			else
			{
				if ($('.event_desc').hasClass('shown'))
				{
					$('.event_desc')
					.stop()
					.animate({
						opacity: 0
					}, 100, 'swing', function() {
						$(this).hide().removeClass('shown').css({ 'top' : '20px' });

						$('.' + event_id + '_desc')
						.show()
						.stop()
						.animate({
							top: '+=10px',
							opacity: 1
						}, 100, 'swing', function() {
							$(this).addClass('shown');
						});

					});
				}
				else
				{
					$('.' + event_id + '_desc')
					.show()
					.stop()
					.animate({
						top: '+=10px',
						opacity: 1
					}, 100, 'swing', function() {
						$(this).addClass('shown');
					});
				}
			}

			return false;
		}		
	});
}

//////////////////////////////////////////////////////////////////////

function equalHeight(group)
{
  var tallest = 0;
  group.each(function() {
   var thisHeight = $(this).outerHeight();
   if(thisHeight > tallest) {
     tallest = thisHeight;
   }
  });
  group.height(tallest);
}

//////////////////////////////////////////////////////////////////////

function css3_selectors()
{
	$('.calendar tr td div:last-child').css({ 'marginBottom' : '2px' });
	$('img[align=right]').addClass('flr');
	$('img[align=left]').addClass('fll');
}

//////////////////////////////////////////////////////////////////////

function news_archive()
{
	$('#nav_sub li a').click( function() {
		if ($(this).siblings('ul').hasClass('archive'))
		{
			if ($(this).siblings('ul.archive').hasClass('open'))
			{
				$(this).siblings('ul.archive').slideUp(100).removeClass('open');
			}
			else
			{
				$(this).siblings('ul.archive').slideDown(100).addClass('open');
			}
			
			return false;
		}
	});
}

//////////////////////////////////////////////////////////////////////

function gallery_slide()
{	
	$('.inner #content .col2 #album_slide_wrap').after('<ul id="album_slide_controls">').cycle({
		timeout: 4000, 
		pager:  '#album_slide_controls',
		pagerAnchorBuilder: function(idx, slide)
		{
			var img = slide.src;
			
			return '<li><a href="#"><img src="' + slide.src + '" height="60" /></a></li>'; 
		}
	});
}

//////////////////////////////////////////////////////////////////////

$(document).ready( function () {
	// hovers();
	slideshow();
	tooltips();
	activate_menu();
	css3_selectors();
	news_archive();
	// gallery_slide();
	
	$('*').each(function() {
	  if ($(this).css('float') !== 'none') {
	    $(this).css('display', 'inline');
	  }
	});
});
