google.setOnLoadCallback(function() { 
	/*
	 * DOM and Event selectors go here....just like CSS
	 * First you select an object and/or event...
	 * Then you specify jquery properties for that object/event...
	 * Or a function you'd like to execute...
	 */ 
	 $("a[href=#network-links]").click(function() {
	     $(this).blur();
	     $("#network-links").toggle();
	     return false;
	 });
	 $(document).click(function(e) {
         var array_location = $.inArray($("#more-network-links").get(0), $(e.target).parents());
         if (array_location < 0) {
             $("#network-links").hide();
         }
	 });
	 
	 
     // meebo revelaer
     $("a#meebo-revealer").click(function() {
         $(this).hide();
         $("#conference-live-chat-meebo-widget").show();
         return false;
     });
     
     
     // conference article rotater
     $(".rotating-container").each(function() {
        var rotating_timeout = null;
        var poll_timeout = null;
        var the_container = this;
        var current_contents = $(the_container).html();
        var new_contents = current_contents;
        var url_root = 'http://' + location.host;
        
        function display_next_article(lines, next_to_display, is_dynamic) {
            lines.hide();
            if (is_dynamic && (next_to_display == 0)) {
                if (current_contents != new_contents) {
                    the_container = $(the_container).empty().prepend(new_contents);
                    lines = $("span.rotating", the_container);
                    current_contents = new_contents;
                    display_next_article(lines, next_to_display, true);
                }
            }
            $(lines.get(next_to_display)).fadeIn("slow");
            if (next_to_display >= (lines.length-1)) {
                next_to_display = 0;
            } else {
                next_to_display += 1;
            }
            if (rotating_timeout) clearTimeout(rotating_timeout);
            rotating_timeout = setTimeout(function() {
                display_next_article(lines, next_to_display, is_dynamic);
            }, 5000);
        }
        display_next_article($("span.rotating", the_container), 0, true);
        
        function poll_for_updated_content() {
            $.ajax({
                type: "GET",
                url: url_root,
                data: "ere_live_template=presentation-info",
                dataType: "json",
                cache: false,
                success: function(data) {
                    new_contents = data.html;
                },
                complete: function() {
                    if (poll_timeout) clearTimeout(poll_timeout);
                    poll_timeout = setTimeout(function() {
                        poll_for_updated_content();
                    }, 30000);
                }
            });
        }
        poll_for_updated_content();
     });
     
     
     // conference expander stuff
     $(".expand-controller.expand").click(function() {
         $("#conference-live-elements").show();
         $(this).hide();
         $(this).siblings(".retract").show();
         return false;
     });
     
     $(".expand-controller.retract").click(function() {
         $("#conference-live-elements").hide();
         $(this).hide();
         $(this).siblings(".expand").show();
         return false;
     });
     
     
     // auto scroll to
     $(".scroll-to-bottom").each(function() {
         $(this).attr({ scrollTop: $(".scroll-to-bottom").attr("scrollHeight") });
         $("body").attr({ scrollTop: 0 });
     });
     
     // De-initialize input box on focus
     $("input.text.initial").focus(function() {
         $(this).val('');
         $(this).removeClass('initial');
         $(this).unbind('focus');
     });
     
     // explainer text revealer
     $("#login-explainer-reveal").click(function() {
         $("#login-explainer-text").toggle("blind", { direction: "vertical" }, 1000);
         return false;
     });
     
     $("#login-explainer-close").click(function() {
         $("#login-explainer-text").hide("blind", { direction: "vertical" }, 1000);
         return false;
     });
     
     
     // Javascript tabs
     $("#sidebar ul.js-tabs li").each(function() {
         var the_widget = $(this).parents(".widget");
         $(this).show();
         $(this).children("a").click(function() {
             var the_id = $(this).attr("href");
             the_widget.children(".js-tab-pane:not("+the_id+")").hide();
             the_widget.children(".js-tab-pane"+the_id).show();
             $(this).parents("ul.js-tabs").children("li").each(function() {
                 $(this).removeClass('selected');
             });
             $(this).parent("li").addClass('selected');
             the_widget.children(".js-tab-pane"+the_id).show();
             return false;
         });
     });
     
     // tag cloud revealer
     $("#navigation-tag-cloud-revealer").click(function() {
         $("#navigation-tag-cloud-container").toggle();
         return false;
     });
     
     $("#navigation-tag-cloud-closer").click(function() {
         $("#navigation-tag-cloud-container").hide();
         return false;
     });
});