function initHideIntroLinks(){
	$(".hide-intro-link").click(function(){
		var elem = $(this).parent().next();
		if (elem.is(':hidden')){
			elem.slideDown('fast');	
			$(this).text('Hide Intro');
		}
		else{
			elem.slideUp('fast');	
			$(this).text('Show Intro');
		}		
		return false;
	})	
}
function initMyAtgEvents(){		
	$('.collapse-heading-link').click(function(){
		var toggleItem = $(this).parent().parent().find('.toggle-area')
				
		if (toggleItem.is(':hidden')){			
			toggleItem.slideDown('fast');
			$(this).parent().addClass('expanded');
			$(this).parent().parent().find('p.intro').addClass('expanded');
		}
		else{
			toggleItem.slideUp('fast');
			$(this).parent().removeClass('expanded');
			$(this).parent().parent().find('p.intro').removeClass('expanded');			
		}	
		return false;		
	});		
}
function initDashboardEvents(){	
	$('dl dt a:not(.rss)').click(function(){		
	  var featuredItem = $(this).parents('dl').find('dd:first');
		var otherItems = $(this).parents('dl').find('dd.other');				
		var link = $('a#see-all-webinars');
		if (otherItems.is(':hidden')){			
			otherItems.slideDown('fast');
			$(this).parent().addClass('expanded');
			featuredItem.removeClass('featured').addClass('expanded');
			link.css('margin-left','40px');
		}
		else{
			otherItems.slideUp('fast');
			$(this).parent().removeClass('expanded');	
			featuredItem.removeClass('expanded').addClass('featured');				
			link.css('margin-left','360px');
		}													
		return false;		
	});		
}

function showDetail(items, detail, index){		
	detail.html($(items[index]).find('span').html());
	items.eq(index).addClass("focus");
	items.live('mouseover', function() {
  	$(this).addClass('focus').siblings().removeClass('focus');
		detail.html($(this).find('span').html());	  		
		return false;			
	});
}

function initDashboardPressReleases(){
	$('#pr-collapse-link').click(function(){			  
		var otherItems = $("#releases");				
		if (otherItems.is(':hidden')){			
			otherItems.slideDown('fast');
			$(this).parent().addClass('expanded');			
			$(".dropdown-container").fadeIn('fast');
		}
		else{
			otherItems.slideUp('fast');
			$(this).parent().removeClass('expanded');
			$(".dropdown-container").fadeOut('fast');				
		}													
		return false;		
	});			
	showDetail($("#releases ul li"),$("#pr-detail"),0)	
}

$(document).ready(function(){	
	initDashboardEvents();
	initDashboardPressReleases();
	initMyAtgEvents();
	initHideIntroLinks();
});