$(document).ready(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...
	 */ 
	 // De-initialize input box on focus
     $("input.text.initial").focus(function() {
         $(this).val('');
         $(this).removeClass('initial');
         $(this).unbind('focus');
     });
	 
	 // box closer
     $("a.close-box").each(function() {
         $(this).click(function() {
             $(this).blur();
             $(this).parent().fadeOut(500);
 			return false;
         });
     });
     
	 // generic revealer
	 $("a.revealer").each(function() {
         $(this).click(function() {
             $(this).blur();
             the_id = $(this).attr("href");
             $(the_id).toggle();
             return false;
         });
     });
	 
	 // meebo revelaer
      $("a#meebo-revealer").click(function() {
          $("a#meebo-revealer").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;
      });
	
	// Rounded corners for navigation tabs
	//$(".tabs li").corner("tl round 10px");
    $(".expander.expanded").siblings(".expanded-info").show();
	
	$(".expander:not(.expanded)").toggle(
	    function () {
            $(this).siblings(".expanded-info").slideDown();
            $(this).toggleClass("expanded");
        },
        function () {
            $(this).siblings(".expanded-info").slideUp();
            $(this).toggleClass("expanded");
        }
	);
	
	$(".expander.expanded").toggle(
	    function () {
            $(this).siblings(".expanded-info").slideUp();
            $(this).toggleClass("expanded");
            
        },
        function () {
            $(this).siblings(".expanded-info").slideDown();
            $(this).toggleClass("expanded");
        }
	);
	
	$(".tag-help-text").hide();
	$("a.tag-help").click(function () {
	    $(".tag-help-text").show();
	    return false;
	});
	$("a.tag-help-close").click(function () {
	    $(".tag-help-text").hide();
	    return false;
	});
});

