// 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() {
		
        // 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();		
	
		// 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");
		});		

    }
	

