/*
*
* Online list
*
*/   
jQuery(function( $ ){
	var online_listRoot = $( "#online_list-root" );
	var online_list = $( "#online_list" );

	// Hook up online_list root click event.
	online_listRoot
		.attr( "href", "javascript:void( 0 )" )
		.click(
			function(){
				// Toggle the online_list display.
				online_list.toggle("slow");

				// Blur the link to remove focus.
				online_listRoot.blur();

				// Cancel event (and its bubbling).
				return( false );
			}
		)
	;

	// Hook up a click handler on the document so that
	// we can hide the online_list if it is not the target of
	// the mouse click.
	$( document ).click(
		function( event ){
			// Check to see if this came from the online_list.
			if (
				online_list.is( ":visible" ) &&
				!$( event.target ).closest( "#online_list" ).size()
				){

				// The click came outside the online_list, so
				// close the online_list.
				online_list.hide("slow");
			}
		}
	);

});

/*
*
* Login
*
*/   
jQuery(function( $ ){
	var loginboxRoot = $( "#login-root" );
	var loginbox = $( "#loginbox" );

	// Hook up loginbox root click event.
	loginboxRoot
		.attr( "href", "javascript:void( 0 )" )
		.click(
			function(){
				// Toggle the loginbox display.
				loginbox.toggle("slow");

				// Blur the link to remove focus.
				loginboxRoot.blur();

				// Cancel event (and its bubbling).
				return( false );
			}
		)
	;

	// Hook up a click handler on the document so that
	// we can hide the loginbox if it is not the target of
	// the mouse click.
	$( document ).click(
		function( event ){
			// Check to see if this came from the loginbox.
			if (
				loginbox.is( ":visible" ) &&
				!$( event.target ).closest( "#loginbox" ).size()
				){

				// The click came outside the loginbox, so
				// close the loginbox.
				loginbox.hide("slow");
			}
		}
	);

});

/*
*
* Google Search
*
*/   
jQuery(function( $ ){
	var searchboxRoot = $( "#search-root" );
	var searchbox = $( "#searchbox" );

	// Hook up searchbox root click event.
	searchboxRoot
		.attr( "href", "javascript:void( 0 )" )
		.click(
			function(){
				// Toggle the searchbox display.
				searchbox.toggle("slow");

				// Blur the link to remove focus.
				searchboxRoot.blur();

				// Cancel event (and its bubbling).
				return( false );
			}
		)
	;

	// Hook up a click handler on the document so that
	// we can hide the searchbox if it is not the target of
	// the mouse click.
	$( document ).click(
		function( event ){
			// Check to see if this came from the searchbox.
			if (
				searchbox.is( ":visible" ) &&
				!$( event.target ).closest( "#searchbox" ).size()
				){

				// The click came outside the searchbox, so
				// close the searchbox.
				searchbox.hide("slow");
			}
		}
	);

});

/*
*
* New posts
*
*/   
jQuery(function( $ ){
	var newboxRoot = $( "#new-root" );
	var newbox = $( "#newbox" );

	// Hook up newbox root click event.
	newboxRoot
		.attr( "href", "javascript:void( 0 )" )
		.click(
			function(){
				// Toggle the newbox display.
				newbox.toggle("slow");

				// Blur the link to remove focus.
				newboxRoot.blur();

				// Cancel event (and its bubbling).
				return( false );
			}
		)
	;

	// Hook up a click handler on the document so that
	// we can hide the newbox if it is not the target of
	// the mouse click.
	$( document ).click(
		function( event ){
			// Check to see if this came from the newbox.
			if (
				newbox.is( ":visible" ) &&
				!$( event.target ).closest( "#newbox" ).size()
				){

				// The click came outside the newbox, so
				// close the newbox.
				newbox.hide("slow");
			}
		}
	);

});

/*
*
* Private messages
*
*/   
jQuery(function( $ ){
	var pmboxRoot = $( "#pm-root" );
	var pmbox = $( "#pmbox" );

	// Hook up pmbox root click event.
	pmboxRoot
		.attr( "href", "javascript:void( 0 )" )
		.click(
			function(){
				// Toggle the pmbox display.
				pmbox.toggle("slow");

				// Blur the link to remove focus.
				pmboxRoot.blur();

				// Cancel event (and its bubbling).
				return( false );
			}
		)
	;

	// Hook up a click handler on the document so that
	// we can hide the pmbox if it is not the target of
	// the mouse click.
	$( document ).click(
		function( event ){
			// Check to see if this came from the pmbox.
			if (
				pmbox.is( ":visible" ) &&
				!$( event.target ).closest( "#pmbox" ).size()
				){

				// The click came outside the pmbox, so
				// close the pmbox.
				pmbox.hide("slow");
			}
		}
	);

});