//this part ensures that any open dialog boxes will be closed if the user clicks anywhere on the body
$(document).ready(function(){
  $('body').click(function() { 
    $('[id^=header_menu]:visible').css("display","none") 
  });
});

$(document).ready(function() {
	
  $("[id^=header_nav]").click(function(event){
   toggle_nav( $(this).attr("id"), event );
  });
  
  //function toggles the display of all navigation menus
  function toggle_nav( button_id , event )
  {
  	var menu_id=button_id.replace("header_nav","header_menu");
  	if( $("#"+menu_id).css("display")=="block" )
  	{
  		$("[id^=header_menu]").css("display","none");
  	}
  	else
  	{
  		$("[id^=header_menu]").css("display","none");
  		$("#"+menu_id).css("display","block");
  		event.stopPropagation();
  	}
  }
  
  //this ensures that the body code is halted if the user click on the menu itself
  $("[id^=header_menu]").click(function(event){
  	event.stopPropagation();
  });
  
  $(".brand_control").click(function(){
    var brand_id=$(this).attr("id");
    brand_id=brand_id.replace("brand_control_","");
    //check if we're open or closed
    if( $(this).is(".leftnav_drop_label_off") )
    {
   	  //closed!
      $(this).removeClass('leftnav_drop_label_off');
      $(this).addClass('leftnav_drop_label_on');
      $(".brand_child_"+brand_id).css("display","block");
      	
    }
    else
    {
      //open!
      $(this).removeClass('leftnav_drop_label_on');
      $(this).addClass('leftnav_drop_label_off');
      $(".brand_child_"+brand_id).css("display","none");
    }
      
  });
  
  $("#leftnav_post_button").click(function(){
  	//toggle display of the posting buttons
  	if( $("#leftnav_post_control").hasClass("invisible") )
  	{
  	  $("#leftnav_post_control").removeClass("invisible");
  	}
  	else
  	{
  	  $("#leftnav_post_control").addClass("invisible");
  	}
  });
  
});

$(document).ready(function() {
	
});


