/*
+--------------------------------------------------------------------------
|   (SnS) AJAX Toggle Visibility
|   for IP.Board 2.1.x
|   ========================================
|   (Ñ) 2007 Sannis
|   http://www.ibresource.ru/forums/index.php?showuser=36662
|   http://ibpower.ru/index.php?showuser=33
|   ========================================
|   Based on (SE22) Toggle Visibility
|   (Ñ) Sean Ellis
+---------------------------------------------------------------------------
*/

function toggle_visibility()
{
	//----------------------------------
	// Using fancy js?
	//----------------------------------

	if ( ! use_enhanced_js )
	{
		return false;
	}

	/*--------------------------------------------*/
	// Main function to do on request
	// Must be defined first!!
	/*--------------------------------------------*/

	do_request_function = function()
	{
		//----------------------------------
		// Ignore unless we're ready to go
		//----------------------------------
		
		if ( ! xmlobj.readystate_ready_and_ok() )
		{
			// Could do a little loading graphic here?
			return;
		}

		var returned = xmlobj.xmlhandler.responseText;
		
		if ( returned != "error" )
		{
			document.getElementById( 'togvis_link' ).innerHTML = returned;
		}
		else
		{
			document.getElementById( 'togvis_link' ).innerHTML = "!!!";
		}
	}

	//----------------------------------
	// LOAD XML
	//----------------------------------

	xmlobj = new ajax_request();
	xmlobj.onreadystatechange( do_request_function );

	xmlobj.process( ipb_var_base_url + 'act=xmlout&do=togglevisibility&md5check='+ipb_md5_check );

	return false;
}