// This script outputs the accordion panel and all it's support.
// It is intended to be called INLINE with a <script src=""> call.
// It outputs everything it needs, but requires an include file (see below)
// with the HTML to be present and accessible via a URL!

	// Attach our handler for document ready.
    jQuery.noConflict();
    jQuery(document).ready(formatAccordion);
	
    // formatPage takes care of global formatting for items and page specific formatting, if needed.
    function formatAccordion() {
	
	//
	// Display the accordion effect on the right pane BUT only if not on the home page
	// Eric 2011-02-08
	//
		if (typeof(homePageFlag)=='undefined' || homePageFlag!=true )
		{
			// We are not on the home page, so we activate the accordion.
			
			// Accordian menu for RightTopContent pane (DNN version).
			jQuery("#lfda_accordion .titleBarInactive").click(function() {
				// Show the right object but only if not already shown!
				if (jQuery(this).next().css("display") == 'none') {
					// Close all the boxes in the RightTopContent pane
					jQuery("#lfda_accordion .containerBox").hide();

					// Remove the active title bar background but first add the inactive background.
					jQuery("#lfda_accordion .titleBarActive").addClass("titleBarInactive");
					jQuery("#lfda_accordion .titleBarActive").removeClass("titleBarActive");

					// Show the box right after the clicked object
					jQuery(this).next().show('fast');

					// Remove the inactive title bar background
					jQuery(this).removeClass("titleBarInactive");
					// Add the active title bar background
					jQuery(this).addClass("titleBarActive");
					
					// Fire off GA for the accordion expand click
					pageTracker._trackEvent("accordion", "expand", jQuery(this).text());
				}
			});
			
			// Hide all the elements except the first one
			jQuery("#lfda_accordion .containerBox:gt(0)").hide();		
			// Show the first container in the RightTopContent
			jQuery("#lfda_accordion .titleBarInactive:first").addClass("titleBarActive");
			jQuery("#lfda_accordion .titleBarInactive:first").removeClass("titleBarInactive");
			jQuery("#lfda_accordion .containerBox:first").show();		
		
		}
		else
		{
			// We are on the home page, so we just set some heights since the accordion is not active.
			
			// For the "non-accodion" layout, we specifically configure the height of the areas
			jQuery("#blogsContainer .containerBoxInner").height(100);
			jQuery("#inTheNewsContainer .containerBoxInner").height(100);
		}
		// Load the content via AJAX - will not work locally because of URL
		jQuery("#blogsContainer .containerBoxInner").load("/rAjaxGW/rget.aspx?action=ning-blog-hp-summary");
		jQuery("#whosOnlineContainer .containerBoxInner").load("/rAjaxGW/rget.aspx?action=ning-activity-hp-summary");
		jQuery("#inTheNewsContainer .containerBoxInner").load("/News/tabid/70/Default.aspx #newsList");
		
		// Add GA Event tracking to the accordion
		jQuery("#whosOnlineContainer a").live("click", function(){
			pageTracker._trackEvent("accordion", "town hall click", "news feed");
		});
		jQuery("#blogsContainer a").live("click", function(){
			pageTracker._trackEvent("accordion", "town hall click", "blog");
		});
		jQuery("#inTheNewsContainer a").live("click", function(){
			pageTracker._trackEvent("accordion", "news click", "news");
		});		

    }
	


